Futures trading
USDⓈ-M perpetuals: leverage, orders, positions and TP/SL legs.
Futures routes live under https://bot.mywellat.com/fapi/v1, /fapi/v2 and /fapi/v3, matching Binance USDⓈ-M Futures. Every route here is signed. A key bound to a Spot strategy gets 400 -2010.
In CCXT set options.defaultType = 'future' and use the perpetual symbol form BTC/USDT:USDT. Plain BTC/USDT is the spot market and routes to /api/v3.
Endpoints
| Method | Path | CCXT | Weight |
|---|---|---|---|
| GET | /fapi/v3/account (alias /fapi/v2/account) | fetchBalance | 5 |
| GET | /fapi/v3/positionRisk (alias /fapi/v2/positionRisk) | fetchPositions | 5 |
| GET | /fapi/v1/leverageBracket | fetchLeverageTiers | 1 |
| GET | /fapi/v1/commissionRate | fetchTradingFee | 20 |
| POST | /fapi/v1/leverage | setLeverage | 1 |
| POST | /fapi/v1/marginType | setMarginMode | 1 |
| POST | /fapi/v1/order | createOrder (MARKET, LIMIT) | 1 (+1 order) |
| DELETE | /fapi/v1/order | cancelOrder | 1 |
| DELETE | /fapi/v1/allOpenOrders | cancelAllOrders | 1 |
| GET | /fapi/v1/order | fetchOrder | 1 |
| GET | /fapi/v1/openOrders | fetchOpenOrders | 1 with symbol, 40 without |
| GET | /fapi/v1/allOrders | fetchOrders | 5 |
| GET | /fapi/v1/userTrades | fetchMyTrades | 5 |
| POST | /fapi/v1/algoOrder | TP / SL legs | 1 (+1 order) |
| DELETE | /fapi/v1/algoOrder | cancel one leg | 1 |
| DELETE | /fapi/v1/algoOpenOrders | cancel all legs on a symbol | 1 |
| GET | /fapi/v1/algoOrder | query a leg | 1 |
| GET | /fapi/v1/openAlgoOrders | open legs | 1 with symbol, 40 without |
| POST | /fapi/v1/wellat/strategy/close | closeStrategy (fapiPrivatePostWellatStrategyClose) | 1 |
Account and positions
GET /fapi/v3/account returns the Binance futures account shape: totalWalletBalance, availableBalance, assets[] and positions[]. In demo the wallet is the strategy's virtual 1,000 USDT custodian.
GET /fapi/v3/positionRisk (optional symbol) returns one entry per position with positionAmt, entryPrice, markPrice, unRealizedProfit, liquidationPrice, leverage, marginType.
Leverage and margin type
await exchange.setLeverage(5, 'BTC/USDT:USDT'); // POST /fapi/v1/leverage { symbol, leverage }GET /fapi/v1/leverageBracketlists each pair's maximum leverage and maintenance-margin tiers. Leverage above the pair's bracket is clamped to the maximum. With no symbol it returns every pair, as on Binance, so stock CCXT fetchPositions works.- An open position pins the symbol's leverage; lowering it under an open position is answers 400 -4161 Leverage reduction is not supported in Isolated Margin Mode with open positions.
- Margin is ISOLATED only.
POST /fapi/v1/marginTypewithISOLATEDis a no-op;CROSSEDanswers400 -2010 "Only ISOLATED margin is supported…".
Placing an order
POST /fapi/v1/order
| Parameter | Required | Notes |
|---|---|---|
symbol | yes | e.g. BTCUSDT |
side | yes | BUY or SELL |
type | yes | MARKET or LIMIT only |
quantity | yes | Contract amount in base asset |
price, timeInForce | LIMIT | timeInForce is GTC only |
reduceOnly | no | true to only close exposure |
newClientOrderId | recommended | Idempotency key |
takeProfitPrice | no | Wellat extension. Attaches a TAKE_PROFIT_MARKET closePosition leg to this entry in the same request. |
stopLossPrice | no | Wellat extension. Attaches a STOP_MARKET closePosition leg to this entry in the same request. |
leverage | no | Wellat extension. Applies to this entry when no position is open on the symbol. |
Sending STOP_MARKET, TAKE_PROFIT_MARKET or any conditional type here answers 400 -4120: conditional orders belong to the algo-order family below, as on Binance since December 2025.
Positions are one-way (no hedge mode): a SELL against a long reduces or flips it.
quantity and price must satisfy the symbol's LOT_SIZE, PRICE_FILTER and MIN_NOTIONAL filters from exchangeInfo; a resting LIMIT entry locks its initial margin at placement. Copiers receive the same order scaled to their collateral fraction and snapped down, and a scaled order under the minimum is skipped for that copier. See Rate limits for the open-order cap and minimum-size rules.
await exchange.createOrder('BTC/USDT:USDT', 'market', 'buy', 0.01, undefined, {
takeProfitPrice: 70000,
stopLossPrice: 60000,
});Take-profit and stop-loss legs
To attach legs when opening, pass takeProfitPrice / stopLossPrice as extra params on createOrder as above. To add or replace a leg on an open position, post to the algo-order route:
POST /fapi/v1/algoOrder
| Parameter | Required | Notes |
|---|---|---|
symbol | yes | |
side | yes | Opposite of the position |
type | yes | STOP_MARKET or TAKE_PROFIT_MARKET |
stopPrice | yes | Trigger, compared against mark price. triggerPrice is accepted as an alias. |
closePosition | yes | true: closes the whole position when triggered |
clientAlgoId | recommended | Idempotency key for the leg |
await exchange.fapiPrivatePostAlgoOrder({
symbol: 'BTCUSDT', side: 'SELL', type: 'STOP_MARKET',
stopPrice: '60000', closePosition: 'true', clientAlgoId: 'btc-sl-1',
});
await exchange.fapiPrivatePostAlgoOrder({
symbol: 'BTCUSDT', side: 'SELL', type: 'TAKE_PROFIT_MARKET',
stopPrice: '70000', closePosition: 'true', clientAlgoId: 'btc-tp-1',
});Do not use stock CCXT's stopLossPrice / takeProfitPrice params on their own with ccxt.binance: that client posts a STOP_MARKET order to /fapi/v1/order and gets -4120. The wellat class routes them correctly.
Manage legs with GET /fapi/v1/openAlgoOrders, GET /fapi/v1/algoOrder (algoId or clientAlgoId), DELETE /fapi/v1/algoOrder, and DELETE /fapi/v1/algoOpenOrders (symbol). When one leg fires the other is cancelled.
Cancelling and querying
Same as spot, with Binance futures field names:
DELETE /fapi/v1/orderwithsymbolandorderIdororigClientOrderId.DELETE /fapi/v1/allOpenOrderswithsymbol.GET /fapi/v1/order,GET /fapi/v1/openOrders,GET /fapi/v1/allOrders,GET /fapi/v1/userTradeswith the usualsymbol,orderId,startTime,endTime,limitparameters.
Demo futures behaviour
The demo simulator is faithful enough to build a track record on:
- Isolated margin and leverage per symbol, as you set them.
MARKETfills cross the spread (taker 0.05%);LIMITfills at the limit price (maker 0.02%).- TP / SL legs trigger on mark price.
- Unrealised and realised PnL, funding at Binance's published rate each settlement, and liquidation at the bracket's maintenance-margin price.
Closing the strategy
POST /fapi/v1/wellat/strategy/close (signed, no parameters beyond timestamp).
Cancels resting orders and legs, closes every position at market, and closes the strategy for the trader and every copier. It cannot be undone; create a new strategy to trade again.
await exchange.closeStrategy(); // @wellat/ccxt
await exchange.request('wellat/strategy/close', 'fapiPrivate', 'POST'); // stock ccxt.binanceClosing an already-closed strategy answers 400 -2010.
Updated 9 days ago