Câu hỏi thường gặp | Binance FAQ
Bài viết này không hỗ trợ ngôn ngữ của bạn. Bạn nên dùng bộ dịch tự động sang tiếng Anh.
Trang chủ
Trung tâm trợ giúp
Câu hỏi thường gặp | Binance FAQ
Bot giao dịch
Lệnh Algo Hợp đồng Tương lai
How to Use TWAP Algorithm on Binance Futures

How to Use TWAP Algorithm on Binance Futures

2022-04-28 03:48
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.

What Is a TWAP Algorithm?

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.

When to Use a TWAP Algorithm?

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:
  • Order size larger than available liquidity on the order book.
  • Anticipation of high price volatility period with no clear up or downward trend.
Illustration of TWAP Algorithm Execution Patterns
How to Set Up a TWAP strategy?
  • Determine the trade size, which is the total size of the contract you choose to buy or sell. The minimum allowed TWAP strategy trade size is equivalent to 1,000 USDT. When a TWAP strategy completes all orders, the TWAP order will stop.
  • Select the duration, which is the targeted TWAP execution period. The minimum duration is 5 minutes, and the maximum is 24 hours.
For more information about TWAP strategy, please refer to the dedicated FAQ

TWAP Algorithm API Details

New TWAP Order Endpoint:

Customizable Execution Parameters

ParametersDescription
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

Other Supplementary Endpoints

EndpointDescriptionLink
DELETE sapi/v1/algo/futures/orderCancel an active orderhttps://binance-docs.github.io/apidocs/spot/en/#cancel-algo-order-trade
GET sapi/v1/algo/futures/openOrdersGet all running ordershttps://binance-docs.github.io/apidocs/spot/en/#query-current-algo-open-orders-user_data
GET sapi/v1/algo/futures/historicalOrdersGet historical ordershttps://binance-docs.github.io/apidocs/spot/en/#query-historical-algo-orders-user_data
GET sapi/v1/algo/futures/subOrdersGet respective sub orders for a specified algo IDhttps://binance-docs.github.io/apidocs/spot/en/#query-sub-orders-user_data

Additional Notes on TWAP Algorithm

1. What Are the Order Limitations When Using the TWAP Algorithm?

  • Open Order Limit - TWAP supports up to 10 simultaneously running orders per account. You can place multiple TWAP orders for the same symbol
  • Notional Limit - The notional (Order Quantity * `Mark Price (base asset)`) must be higher than the equivalent of 1,000 USDT and lower than the equivalent of 1,000,000 USDT.
  • Duration - Duration cannot be less than 5 min (300sec) or more than 24 hours (86,400 sec)
  • End Time (Delivery) - For quarterly contracts, TWAP orders must end one hour before the contract’s settlement time. For example, if you create a TWAP order at 7:00 AM with a 4-hour duration, the TWAP order will end at 11:00 AM.
  • Eligible Contract Type - TWAP supports USDⓈ-M contracts and can be used with Multi-Assets Mode.
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.

2. What Are the Expected Error Responses From the TWAP Order Endpoint?

You may receive the following error responses following an inadequate query.
External codeExternal msg
0OK
-1000An unknown error occurred while processing the request.
-1102A mandatory parameter was not sent, empty/null, or malformed.
-20121Invalid symbol.
-20130Invalid data sent for a parameter.
-2013Order does not exist.
-5007Quantity must be greater than zero.
-20124Invalid algo id or it has been completed.
-20132The client algo id is duplicated.
-20194Duration is too short to execute all required quantity.
-20195The total size is too small.
-20196The total size is too large.
-20198Reach the max open orders allowed.

3. Is TWAP a Guaranteed Execution Algorithm?

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.

4. How Do I Check the Status of My TWAP Order?

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.