Binance Spot launched the Time-Weighted Average Price (TWAP) trading algorithm for API users. Using Binance's in-house algorithmic trading capability, users can disperse large orders into smaller quantities and execute them at regular intervals automatically to minimize price impact.
Time-Weighted Average Price (TWAP) is an algorithmic trade execution strategy. It aims to achieve an average execution price close to the time-weighted average price of a specific period.
Traders usually deploy TWAP to mitigate the market impact for large orders. TWAP trading algorithms aim to optimize a trade’s average price by slicing order execution over a specific time duration.
TWAP is favored to provide a better execution price in the following scenarios:
Here is an example of TWAP algorithm execution patterns:
POST /sapi/v1/algo/spot/newOrderTwap
Parameters | Description |
symbol | Trading symbol (e.g., BTCUSDT) |
side | Trading side (e.g., BUY or SELL) |
quantity | Trading quantity (must be between 1,000 USDT and 100,000 USDT equivalent) |
duration | TWAP order duration in seconds (300 or 86,400)
|
limitPrice | TWAP order’s limit price (The order will be placed at market price by default) |
Endpoint | Description | Link |
DELETE /sapi/v1/algo/spot/order | Cancel an active order | https://binance-docs.github.io/apidocs/spot/en/#cancel-algo-order-trade-2 |
GET /sapi/v1/algo/spot/openOrders | Get all running orders | https://binance-docs.github.io/apidocs/spot/en/#query-current-algo-open-orders-user_data-2 |
GET /sapi/v1/algo/spot/historicalOrders | Get historical orders | https://binance-docs.github.io/apidocs/spot/en/#query-historical-algo-orders-user_data-2 |
GET /sapi/v1/algo/spot/subOrders | Get respective sub orders for a specified algo ID | https://binance-docs.github.io/apidocs/spot/en/#query-sub-orders-user_data-2 |
Transaction details won’t be available until all TWAP orders are filled. Only partially completed orders will be displayed. You can view the transaction quantity, average transaction price, and trading fee.
You may receive the following error responses following an inadequate query.
External code | External message |
0 | OK |
-1000 | An unknown error occurred while processing the request |
-1102 | A mandatory parameter was not sent, empty/null, or malformed |
-20121 | Invalid symbol |
-20130 | Invalid data sent for a parameter |
-2013 | Order does not exist |
-5007 | Quantity must be greater than zero |
-20124 | Invalid algo ID, or the algo ID has been completed |
-20132 | The client algo ID is duplicated |
-20194 | Duration is too short to execute all required quantity |
-20195 | The total size is too small |
-20196 | The total size is too large |
-20198 | You’ve reached the max open orders allowed |
TWAP orders do not guarantee execution. Orders will be filled with the best effort, subject to market liquidity and volatility.
If the market price moves considerably or liquidity is insufficient during order execution, the algorithm may not be able to execute all orders fully.
Thus, execution is and will always be liquidity-dependent with no guarantee for best price execution. For example, the algorithm may fail to complete the order before the specified end time if the market becomes distressed.
To check the status of a TWAP order, you can use the query order endpoints (GET /sapi/v1/algo/spot/openOrders or GET /sapi/v1/algo/spot/historicalOrders).
Please note: