Skip to content

Exchange mechanics

OKX spot market order size: tgtCcy, quote vs base currency

Updated Ninja Terminal team

Short answer

On OKX spot, the sz of a market order follows the tgtCcy parameter. The default is quote_ccy for a buy and base_ccy for a sell. A market buy with sz of 100 on BTC-USDT therefore spends 100 USDT, not 100 BTC. Set tgtCcy to base_ccy to buy a fixed amount of BTC. Bybit spot works the same way through marketUnit.

Spot market orders look simple, but the unit of the size field is easy to get wrong. A request that was meant to buy 0.01 BTC can spend 0.01 USDT, or one that was meant to spend 100 USDT can try to buy 100 BTC. Both exchanges that matter here, OKX and Bybit, default to a quote-currency amount for market buys.

How does tgtCcy work on OKX?

In POST /api/v5/trade/order, sz for a spot market order is set by tgtCcy. The OKX documentation says it applies to spot market orders only, and “Default is quote_ccy for buy, base_ccy for sell”.

For BTC-USDT:

Side tgtCcy sz Result
Buy quote_ccy (default) 100 Spend 100 USDT on BTC
Buy base_ccy 0.001 Buy 0.001 BTC at market
Sell base_ccy (default) 0.001 Sell 0.001 BTC
Sell quote_ccy 100 Sell BTC until you receive 100 USDT

Limit orders are different. For spot and margin limit orders, sz is always the quantity in base currency. Margin market buys use quote currency and margin market sells use base currency.

What happens if the amount does not fit the balance?

OKX documents two cases for the non-default combinations (a base-currency market buy or a quote-currency market sell):

  • If the amount you enter is greater than what you can buy or sell, OKX executes the order at your maximum buyable or sellable quantity. Use a limit order if you need the exact quantity.
  • If the price moves while the balance is locked, OKX adjusts the quantity on a best-effort basis from your balance. It tries to lock a little extra to avoid this.

Attaching TP/SL to the order is not supported for a market buy with tgtCcy=base_ccy or a market sell with tgtCcy=quote_ccy.

What do accFillSz and fillSz mean?

Order endpoints and the WebSocket order channel return both fields:

  • fillSz is the quantity of the most recent individual fill. It is not cumulative.
  • accFillSz is the running total of filled quantity since the order was created. In the WebSocket order channel it always holds the cumulative total, not the increment since the last push.

On spot and margin the unit of both fields is the base currency. On futures and swaps the unit is contracts. Order rows also carry tgtCcy, so read it together with sz: for a quote-sized market buy, sz is in USDT while accFillSz is in BTC, and the two numbers cannot be compared directly. For the filled amount of an order, use accFillSz.

Does Bybit work the same way?

Mostly. For Bybit V5 spot, the create-order documentation says a market buy is placed by value by default. The marketUnit parameter picks the unit for qty on spot market orders:

marketUnit qty unit
baseCoin Base coin, for example BTC on BTCUSDT
quoteCoin Quote coin, for example USDT

Set it explicitly when you want a fixed amount of the base coin. See the Bybit available balance guide for what balance a spot order can use.

How Ninja Terminal handles this

Ninja Terminal sends the unit explicitly instead of relying on exchange defaults:

  • OKX spot market orders are sent with tgtCcy set, to base_ccy unless a quote-sized market order is requested.
  • Bybit spot market orders are sent with marketUnit, set to baseCoin unless a quote-sized plain market order is requested.
  • Spot market orders from Quick Entry and the order ticket reach both exchanges in base-coin units by default.
  • Filled quantity on OKX orders is read from accFillSz, so partial fills show the running total.

A market order fills at the best available prices and can fill worse than the last price. See slippage. This guide is not investment advice.

Frequently asked questions

Is sz in base or quote currency for an OKX spot market buy?

By default sz is in quote currency for a market buy. With sz of 100 on BTC-USDT, OKX spends 100 USDT. Set tgtCcy to base_ccy if you want sz to be an amount of BTC instead.

What is the default tgtCcy for a market sell on OKX spot?

The default for a market sell is base_ccy, so sz is the amount of the coin you sell. You can set tgtCcy to quote_ccy to sell enough coin to receive a given amount of USDT.

What is the difference between accFillSz and fillSz on OKX?

fillSz is the quantity of the most recent fill only. accFillSz is the running total of all fills since the order was created. Use accFillSz for the filled amount of an order. On spot its unit is the base currency.

Does Bybit spot also use quote currency for market buys?

Yes. The Bybit documentation says spot market buy orders are placed by value by default. Set marketUnit to baseCoin to give qty in the base coin, or to quoteCoin to give it in the quote coin.

Sources

  1. OKX API v5 — Place order (sz, tgtCcy)
  2. OKX API v5 — Get order details (accFillSz, fillSz)
  3. Bybit V5 — Place order (marketUnit)

Trade every venue from one tab.

Binance, OKX, Bybit, and Hyperliquid with news, charts, and one-command orders. Included with Ninja Squad Pro membership.