Binance Futures has launched the Time-Weighted Average Price (TWAP) trading algorithm for API users on USDⓈ-M Futures contracts.
Part of the Binance Futures Execution Algorithm API solutions, TWAP trading algorithm allows users to programmatically leverage Binance’s in-house algorithmic trading capability in order to disperse a large order into smaller quantities and execute them at regular intervals automatically to minimize price impact.
TWAP (Time-Weighted Average Price) is an algorithmic trade execution strategy that aims to achieve an average execution price close to the time-weighted average price of the user-specified period.
TWAP trading algorithms aim to optimize a trade’s average price by slicing orders execution over a specific time duration. Traders usually deploy TWAP strategy to execute large orders while mitigating their significant market impact.
TWAP is favored to provide a better execution price in the following scenarios:
Illustration of TWAP Algorithm Execution Patterns
How to Set Up a TWAP strategy?
For more information about TWAP strategy, please refer to the dedicated FAQ
New TWAP Order Endpoint:
POST sapi/v1/algo/futures/newOrderTwap
Parameters | Description |
Duration | Duration for TWAP orders in seconds. [300, 86400] less than 5min => defaults to 5 min greater than 24h => defaults to 24h |
Quantity | Trading quantity (must be more than the equivalent of 1,000 USDT and less than the equivalent of 1,000,000 USDT) |
limitPrice | Order’s limit price if unspecified, the order will be placed at market price by default |
Endpoint | Description | Link |
DELETE sapi/v1/algo/futures/order | Cancel an active order | https://binance-docs.github.io/apidocs/spot/en/#cancel-algo-order-trade |
GET sapi/v1/algo/futures/openOrders | Get all running orders | https://binance-docs.github.io/apidocs/spot/en/#query-current-algo-open-orders-user_data |
GET sapi/v1/algo/futures/historicalOrders | Get historical orders | https://binance-docs.github.io/apidocs/spot/en/#query-historical-algo-orders-user_data |
GET sapi/v1/algo/futures/subOrders | Get respective sub orders for a specified algo ID | https://binance-docs.github.io/apidocs/spot/en/#query-sub-orders-user_data |
The transaction details will not be displayed until all TWAP orders are filled. Only partially completed orders will be displayed, showing the transaction quantity, average transaction price, and trading fee.
You may receive the following error responses following an inadequate query.
External code | External msg |
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 it 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 | Reach the max open orders allowed. |
TWAP orders do not guarantee execution. Orders will be filled with best effort, subject to market liquidity and volatility.
If the market price moves considerably or liquidity is insufficient during the execution of an order, the algorithm may not achieve full completion.
Thus, execution is and will always be liquidity-dependent with no guarantee for best price execution. For example, if the market becomes distressed, the algorithm may fail to complete the order before the specified end time.
Binance employs multiple risk mitigation strategies, including manual and automated circuit breakers, as well as kill-switch controls. These features can activate in the event of market disruption and/or systems failure, canceling any TWAP order early in a non-fully filled state.
To check the status of a TWAP order, you can use the query order endpoints (GET sapi/v1/algo/futures/openOrders or GET sapi/v1/algo/futures/historicalOrders).
Please note that no websocket notification will be available for orders filling updates. Besides, receiving "success": true does not mean that your order will be executed.
For instance, should your futures balance be insufficient, or your account be in Reduce Only status, you will receive "success": true, but the order will fail to execute.