CashOrderQty on limit orders is available for both buy and sell orders despite the following example featuring a buy order.
Today, if you want to trade $30,000 worth of BTC, you might submit a market order:
OrdType=1|Side=1|CashOrderQty=30000
However, a market order leaves the executed price out of the client’s control.
With the following market state:
Bid Size
Bid
Ask
Ask Size
60,000
10
10
59,000
You can try to trade $30,000 of BTC by placing a limit buy order. To do this you must perform the notional/price division to calculate the necessary OrderQty. The resulting order would look like:
OrdType=2|Side=1|Price=60000|OrderQty=0.5
If this order is filled at $2,000, then everything works as intended. In actuality, the market may change from the time in between when the user submits the order and when it is received by the exchange.
To illustrate, consider the case where the market state has changed to the following at the time when the exchange receives your order:
Bid Size
Bid
Ask
Ask Size
59,000
10
10
58,999
Your order now fills at 59,000forquantity‘0.5‘.Theresultingnotionalforthistradeis29,500, which is less than what you originally wanted.
To solve this issue, you can specify CashOrderQty instead of OrderQty:
OrdType=2|Side=1|Price=60000|CashOrderQty=30000
Given the same market state:
Bid Size
Bid
Ask
Ask Size
59,000
10
10
58,999
The order will be filled as taker with quantity 0.50847457, making the total notional of this order $29,999.9996.
In a separate example, with the following market state:
Bid Size
Bid
Ask
Ask Size
60,500
1
59,500
0.3
10
59,999
Your order will fill as a taker at price 59,500withquantity‘0.3‘.Thusonly17850 notional will be filled. The remaining 12,150notionalwillthenrestonthebookatprice60,000 with quantity 0.2025.
OrderQty/CumQty/LeavesQty is supplied in all Execution Reports. In particular OrderQty is calculated after the order has been processed as a taker (i.e., it is NOT calculated with CashOrderQty / Price), such that all quantity tags are consistent with one another.
Size field is populated in all WebSocket feed messages. No changes are expected from the perspective of a WebSocket consumer.
Note that OrderQty is 0 in this case and this order will not be published in public WebSocket channels. It appears in the user channel only for this particular client.