Quickstart

Place a demo order from CCXT in five minutes.

You need an API key and a strategy from Account setup.

JavaScript / TypeScript

The @wellat/ccxt package ships a wellat class with Wellat's hosts and options built in. Install 0.1.9 or later; earlier releases either failed at loadMarkets() (before 0.1.5) or routed fetchBalance of a Futures key to spot or parsed it without a USDT key (0.1.5 to 0.1.6), or could not call closeStrategy() (0.1.7), or sent fetchTrades to aggTrades (0.1.8).

npm install ccxt @wellat/ccxt
import wellat from '@wellat/ccxt';

const exchange = new wellat({
  apiKey: process.env.WELLAT_API_KEY,
  secret: process.env.WELLAT_API_SECRET,
});

await exchange.loadMarkets();                   // GET /api/v3/exchangeInfo
const balance = await exchange.fetchBalance();  // GET /api/v3/account
console.log(balance.USDT);                      // { free: 200, used: 0, total: 200 } in demo

const order = await exchange.createOrder(
  'BTC/USDT', 'limit', 'buy', 0.001, 50000,
  { newClientOrderId: 'my-bot-0001' },          // makes the write idempotent
);
console.log(order.id, order.status);

await exchange.createMarketBuyOrderWithCost('BTC/USDT', 50); // quoteOrderQty: spend 50 USDT
const open = await exchange.fetchOpenOrders('BTC/USDT');
await exchange.cancelOrder(order.id, 'BTC/USDT');

Python

There is no Python build of the Wellat class yet. Use CCXT's binance class with these overrides:

pip install ccxt
import os, ccxt

BASE = 'https://bot.mywellat.com'

exchange = ccxt.binance({
    'apiKey': os.environ['WELLAT_API_KEY'],
    'secret': os.environ['WELLAT_API_SECRET'],
    'options': {
        'defaultType': 'spot',                 # 'future' for a Futures strategy
        'fetchMarkets': ['spot', 'linear'],    # no inverse (COIN-M) markets on Wellat
        'fetchCurrencies': False,              # no currency endpoint
        'fetchMargins': False,                 # no margin pairs
        'recvWindow': 10000,
    },
    'urls': {
        'api': {
            'public':        f'{BASE}/api/v3',
            'private':       f'{BASE}/api/v3',
            'fapiPublic':    f'{BASE}/fapi/v1',
            'fapiPrivate':   f'{BASE}/fapi/v1',
            'fapiPrivateV2': f'{BASE}/fapi/v2',
            'fapiPrivateV3': f'{BASE}/fapi/v3',
        },
    },
})

exchange.load_markets()
print(exchange.fetch_balance()['USDT'])

order = exchange.create_order('BTC/USDT', 'limit', 'buy', 0.001, 50000,
                              {'newClientOrderId': 'my-bot-0001'})
print(order['id'], order['status'])
exchange.cancel_order(order['id'], 'BTC/USDT')

All four options matter. Without fetchMarkets, stock CCXT also loads COIN-M markets from a host Wellat does not have and load_markets() fails. Without fetchMargins: False it calls Binance's margin endpoints during load_markets().

Futures strategy

Same class, defaultType: 'future'. CCXT names USDⓈ-M perpetuals BTC/USDT:USDT; plain BTC/USDT is the spot market and would route to /api/v3, where a futures key gets -2010.

const exchange = new wellat({ apiKey, secret, options: { defaultType: 'future' } });

await exchange.loadMarkets();                                          // GET /fapi/v1/exchangeInfo
await exchange.setLeverage(5, 'BTC/USDT:USDT');                        // POST /fapi/v1/leverage
await exchange.createOrder('BTC/USDT:USDT', 'market', 'buy', 0.01, undefined, {
  takeProfitPrice: 70000,                                              // Wellat extension: attached TP/SL legs
  stopLossPrice: 60000,
});
const positions = await exchange.fetchPositions(['BTC/USDT:USDT']);    // GET /fapi/v3/positionRisk
await exchange.closeStrategy();                                        // Wellat extension, see Futures trading

Margin mode is always isolated: setMarginMode('isolated', …) is a no-op and 'cross' answers -2010. See Futures trading for the full parameter list.

Without CCXT

Any Binance client library or hand-rolled HTTP works. The contract is in Authentication; the routes are in Spot trading, Futures trading and Market data.

What you will see in demo

  • fetchBalance returns the seeded virtual balance (200 USDT spot, 1,000 USDT futures) and tracks every fill.
  • Market orders fill by crossing the spread (buy at the ask, sell at the bid) with a 0.1% taker fee on spot. Limit orders rest and fill when the market crosses them.
  • Order sizes must satisfy the LOT_SIZE, PRICE_FILTER and NOTIONAL filters from exchangeInfo, exactly as on Binance. CCXT applies them for you through amountToPrecision and priceToPrecision.
  • Your strategy's track record on Wellat updates with every trade, and copiers mirror each order on their real accounts.

Did this page help you?