Binance Algo Orders API: Complete Trader's Guide
Master Binance algo order API endpoints to automate TWAP, VP, and VWAP strategies. Real code examples, auth setup, and error handling included.
Master Binance algo order API endpoints to automate TWAP, VP, and VWAP strategies. Real code examples, auth setup, and error handling included.
Executing large crypto orders manually is a fast way to move the market against yourself. Drop a 50 BTC market buy on Binance without any execution logic and you'll eat slippage that wipes out any edge you had. Algorithmic order types solve this — and Binance exposes them directly through their API. Whether you're running a prop desk, a hedge fund script, or a personal bot, the Binance algo order API gives you TWAP, VP (Volume Participation), and VWAP execution natively, without needing a third-party OMS.
Algo orders are execution algorithms that break a large parent order into smaller child orders over time or volume, reducing market impact. Binance currently supports three algo types via their API: TWAP (Time-Weighted Average Price), VP (Volume Participation), and VWAP (Volume-Weighted Average Price). These are available on Binance Spot, USD-M Futures, and COIN-M Futures markets.
Compared to platforms like Bybit and OKX, which also offer algo execution but through different API schemas, Binance's implementation is more granular — you get direct control over duration, urgency ratio, and limit price offsets. OKX calls their equivalent 'iceberg' and 'time-division' orders, while Bybit bundles similar logic under their TWAP order type. Binance's binance algo order api is arguably the most flexible of the three for futures trading.
Algo order endpoints require a signed request with your API key and secret. This means every request needs an HMAC SHA256 signature. Here's the minimal Python setup you need before touching any algo endpoint:
import hmac
import hashlib
import time
import requests
from urllib.parse import urlencode
API_KEY = 'your_api_key_here'
API_SECRET = 'your_api_secret_here'
BASE_URL = 'https://api.binance.com'
def sign_params(params: dict) -> str:
query_string = urlencode(params)
signature = hmac.new(
API_SECRET.encode('utf-8'),
query_string.encode('utf-8'),
hashlib.sha256
).hexdigest()
return signature
def get_headers() -> dict:
return {
'X-MBX-APIKEY': API_KEY,
'Content-Type': 'application/x-www-form-urlencoded'
}
def get_timestamp() -> int:
return int(time.time() * 1000)
Always use IP whitelisting on your Binance API keys for algo trading. If your key leaks, an attacker can't use it from an unauthorized IP. Also set 'Spot & Margin Trading' or 'Futures' permissions only — never enable withdrawals on a trading key.
The binance algo order api endpoints are split by market type. Spot algo orders live under /sapi/v1/algo/spot/, while USD-M futures algo orders use /sapi/v1/algo/futures/. Here's a breakdown of the key endpoints you'll use daily:
| Endpoint | Method | Description |
|---|---|---|
| /sapi/v1/algo/spot/newOrderTwap | POST | Place spot TWAP order |
| /sapi/v1/algo/futures/newOrderTwap | POST | Place futures TWAP order |
| /sapi/v1/algo/futures/newOrderVp | POST | Place futures VP order |
| /sapi/v1/algo/spot/openOrders | GET | List open algo orders (spot) |
| /sapi/v1/algo/futures/openOrders | GET | List open algo orders (futures) |
| /sapi/v1/algo/spot/order | DELETE | Cancel spot algo order |
| /sapi/v1/algo/futures/order | DELETE | Cancel futures algo order |
| /sapi/v1/algo/spot/historicalOrders | GET | Historical algo orders (spot) |
| /sapi/v1/algo/futures/subOrders | GET | List child orders for a parent |
Note that all algo endpoints require 'Enable Spot & Margin Trading' or 'Enable Futures' permissions respectively, and every request must be signed. The recvWindow parameter (default 5000ms) controls how long your timestamp stays valid — for algo orders, 5000ms is usually fine since you're not doing microsecond HFT here.
Let's walk through placing a futures TWAP order. The required parameters are symbol, side, quantity, duration (in seconds), and clientAlgoId (your own reference ID). Optional params include limitPrice to cap your execution price and positionSide for hedge mode.
import uuid
def place_futures_twap(
symbol: str,
side: str, # 'BUY' or 'SELL'
quantity: float,
duration: int, # seconds, min 300 (5 min), max 86400 (24h)
limit_price: float = None
) -> dict:
"""
Place a TWAP order on Binance USD-M Futures.
duration: how long to spread the order (300-86400 seconds)
"""
endpoint = '/sapi/v1/algo/futures/newOrderTwap'
params = {
'symbol': symbol,
'side': side,
'quantity': str(quantity),
'duration': duration,
'clientAlgoId': str(uuid.uuid4()).replace('-', '')[:32],
'timestamp': get_timestamp(),
'recvWindow': 5000
}
if limit_price:
params['limitPrice'] = str(limit_price)
params['signature'] = sign_params(params)
response = requests.post(
BASE_URL + endpoint,
headers=get_headers(),
data=params # POST body, not query string
)
data = response.json()
if response.status_code != 200:
raise Exception(f"Binance API error {data.get('code')}: {data.get('msg')}")
return data
# Example: buy 1.5 ETH over 30 minutes
result = place_futures_twap(
symbol='ETHUSDT',
side='BUY',
quantity=1.5,
duration=1800 # 30 minutes
)
print(f"Algo order placed. algoId: {result['algoId']}")
print(f"Client ID: {result['clientAlgoId']}")
The response gives you an algoId — store this. You'll need it to query child orders, check status, or cancel. Binance will start firing child orders immediately, and you can monitor them via the /sapi/v1/algo/futures/subOrders endpoint using that algoId.
Once your algo order is live, you need to track its execution. The subOrders endpoint gives you every child order that has been sent, including their fill status. Here's a complete monitoring and cancel workflow:
def get_algo_sub_orders(algo_id: int, page: int = 1, page_size: int = 20) -> dict:
"""Fetch child orders for a parent algo order."""
endpoint = '/sapi/v1/algo/futures/subOrders'
params = {
'algoId': algo_id,
'page': page,
'pageSize': page_size,
'timestamp': get_timestamp()
}
params['signature'] = sign_params(params)
response = requests.get(
BASE_URL + endpoint,
headers=get_headers(),
params=params
)
return response.json()
def cancel_algo_order(algo_id: int) -> dict:
"""Cancel an active algo order by its algoId."""
endpoint = '/sapi/v1/algo/futures/order'
params = {
'algoId': algo_id,
'timestamp': get_timestamp()
}
params['signature'] = sign_params(params)
response = requests.delete(
BASE_URL + endpoint,
headers=get_headers(),
params=params
)
data = response.json()
if data.get('success'):
print(f"Algo {algo_id} cancelled. {data.get('msg')}")
return data
def monitor_algo_execution(algo_id: int):
"""Print a summary of algo order execution progress."""
sub_orders = get_algo_sub_orders(algo_id)
total = sub_orders.get('total', 0)
orders = sub_orders.get('subOrders', [])
filled = sum(1 for o in orders if o['status'] == 'FILLED')
total_qty_filled = sum(float(o['executedQty']) for o in orders)
print(f"Child orders: {filled}/{total} filled")
print(f"Total qty executed: {total_qty_filled}")
for order in orders[-3:]: # show last 3
print(f" orderId={order['orderId']} "
f"status={order['status']} "
f"price={order['price']} "
f"qty={order['executedQty']}")
# Usage
monitor_algo_execution(algo_id=12345678)
If your algo order gets stuck (e.g., limitPrice is too far from market), Binance will pause child order submission but keep the parent active. Always monitor fill rate in the first 5 minutes. If less than 10% is filled after 10% of your duration has elapsed, your limitPrice is probably too restrictive.
Platforms like Bybit handle stuck algo orders differently — they'll auto-cancel after a timeout. Binance keeps them open until duration expires or you explicitly cancel. Build a monitoring loop into your bot that checks fill rate and auto-cancels if execution pace is far below expected. VoiceOfChain's signal layer can feed entry/exit triggers into this loop — when a signal fires, your TWAP bot activates; when the signal expires, the monitor cancels any remaining algo order.
The Binance algo order API removes the hardest part of large-order execution from your plate. Instead of hand-rolling TWAP slicing logic, managing child order queues, and watching for partial fills, you submit one parent order and let Binance handle the mechanics. Your job becomes higher-level: decide when to enter, what size, and over what window.
Pair these binance algo order api endpoints with a signal source and you have a complete execution pipeline. VoiceOfChain provides real-time on-chain and technical signals that can trigger your TWAP bot — when a whale accumulation signal fires on ETH, your bot places a 30-minute TWAP buy; when momentum reverses, it cancels any remaining algo order and sits flat. Exchanges like Binance, Bybit, and OKX all offer programmatic algo execution, but the key is tying that execution to a reliable signal layer rather than running blindly on schedule.
Start with small quantities to verify your signing logic, confirm child orders are appearing correctly in the subOrders endpoint, then scale up. Algorithmic execution isn't about being smarter than the market — it's about not being your own worst enemy when size starts to matter.