Algorithms API
The Algorithms API provides execution algorithms that break large orders into smaller slices to minimize market impact and achieve better average prices.Key Features
- Time-sliced execution: TWAP and TimePace spread orders evenly over time
- Multi-level orders: Ladder places limit orders at multiple price levels
- Aggressive fills: Sweep uses IOC orders for immediate execution
- Spread trading: Two-leg execution for basis/arb trades with risk management
- Anti-gaming: Randomization of size and timing to avoid detection
- Limit price guardrails: Won’t execute beyond your price limit
- TCA metrics: Arrival price, VWAP, slippage tracking
- Full lifecycle: Start, pause, resume, cancel algorithms
Algorithm Types
POST /order-execution/algorithms/start
Start a new execution algorithm.Request Body (JSON)
TWAP Parameters
Request Example
total_intervals = duration_seconds / interval_seconds
slices and works one interval at a time:
- Interval start, compute the interval’s target size
(
base = total_quantity / total_intervals, jittered ±20% whenrandomize_sizeis on) and post a passive limit at the chosen aggression level. - Mid-interval reprice, if the passive order is still unfilled about halfway through the interval, it is cancelled and reposted as an aggressive IOC so the slice doesn’t sit idle on a thin book. The original passive is always cancelled first, so an interval is never bought twice.
- Catch-up (when
catch_up_enabled), if the algo has fallen behind the schedule, it sends an extra IOC of up tomax_catch_up_pct%of the interval size to close the gap. - Fill crediting, every child-order fill (passive or IOC) is credited to
progress.filled_quantityandchild_orders_filled. The reported fill percentage always reflects quantity actually filled on the exchange.
Final interval mops up the remainder. Because
randomize_size perturbs
each interval independently it does not conserve the order total, so the
randomized targets can sum to slightly less than quantity. To guarantee the
order attempts 100%, the last interval ignores randomization and targets the
entire remaining quantity. Per-order exchange lot-size rounding may still
leave a tiny remainder; if that remainder is below the venue’s minimum order
size/notional it is unfillable and the algorithm completes at 100%
(dust snapped). A larger genuine shortfall is reported honestly (e.g. 94%),
not masked.Completion. After the last interval the algo waits briefly for any
in-flight child orders to settle, then transitions to
COMPLETED. It does not
hang waiting on reserved-but-unfilled rounding dust.- Use
passiveaggression for large orders to minimize market impact - Keep
catch_up_enabledon (default) so the order fills its full quantity - Set
limit_priceas a safety guardrail - Longer durations reduce market impact but increase timing risk
- Expect the final slice to be larger than the others when earlier randomized slices came in light, this is the mop-up that drives the order to ~100%
Ladder Parameters
Size Distributions
Request Example
- Use
lineardistribution to concentrate size near market price - Set
cancel_on_fill_pctto 70-80% to capture most fills without overfilling - Use
reprice_on_move_bpsfor volatile markets to keep levels relevant - Keep
num_levelsat 3-10 for most use cases
Sweep Parameters
Request Example
- Sweep is the simplest algorithm - use it when you need immediate fills
- All slices are IOC (Immediate-or-Cancel) - unfilled portions cancel immediately
- Set
max_slippage_bpsto protect against adverse price movement - Use
max_retries> 0 for illiquid markets where one pass may not fill
TimePace Parameters
Key Difference from TWAP: TimePace has no catch-up logic. If an interval is skipped (due to limit price breach), that quantity is lost. TWAP catches up on missed quantity.
Request Example
- Use TimePace when you want predictable, fixed-size executions
- Set
limit_priceto skip intervals during adverse price moves - Unlike TWAP, skipped intervals do NOT accumulate - choose TimePace for strict pacing
- Runs until total_quantity is filled or the algorithm is cancelled
Spread Parameters
The anchor leg tradesanchor_symbol on the order’s side; the contra leg
trades contra_symbol on the OPPOSITE side (it is a hedge). The contra
symbol may be a derivative (e.g. BTC/USDT:USDT); each leg’s orders route
to the market type implied by its own symbol.
Sweep Trigger Modes
Request Example (BTC spot vs perp basis trade)
- Set
risk_quantityconservatively - it limits max unhedged exposure - Use
immediatesweep trigger for tight risk management - Set
pause_offset_pctto stop trading when the spread widens beyond tolerance - The algorithm completes when BOTH legs are fully filled
- Use different exchange accounts for each leg for cross-venue basis trades
FundingArb Parameters
Delta-neutral funding-rate carry: go long spot and short the perpetual on the same underlying, collect the funding that longs pay shorts while the carry is favourable, and unwind when it no longer is. The two legs cancel each other’s price exposure (delta-neutral by construction), so the P&L is the funding collected minus fees and basis drift, not a directional bet. v1 supports positive funding only (long spot + short perp). This is a long-running position algorithm, not a fill-and-finish execution algo. One algorithm represents one position: it waits for an entry signal, opens both legs, holds across funding windows, then unwinds and completes.How the entry and exit signal works
Funding rates, especially on hourly-funding venues, oscillate around zero and flip sign constantly. Acting on a single funding print would open and close the position several times a day and bleed round-trip fees that dwarf the carry. The strategy is built to avoid that:- Smoothed signal. Every entry and exit decision uses an exponentially-weighted moving average (EWMA) of the predicted funding APR, never the latest raw print.
funding_smoothing_hoursis the EWMA time-constant: larger values give a smoother, slower signal (less churn, more lag). - Asymmetric hysteresis band. You enter when the smoothed APR is at or above
entry_apr_threshold, and only exit (funding decay) when it falls below the lowerexit_apr_threshold. The gap between the two is a deadband that stops the position flip-flopping when funding hovers near the entry level. - Fee-aware entry gate. Before opening, the strategy estimates how long the current carry would take to cover the round-trip cost (
round_trip_cost_bps). If that break-even time exceedsmax_breakeven_hours, it refuses to open. On near-zero-funding markets this gate simply never fires, which is the correct behavior: the carry cannot beat the fees. - Minimum hold. Once open, the funding-decay exit cannot fire until the position has been held for
min_hold_hours, preventing a same-day round trip if funding dips right after entry. The hard exits below bypass it.
Parameters
Legs and size
Entry / exit signal
Fees and hold
Perp leg risk
Execution
Lifecycle phases (in
state.phase): waiting_entry then opening then holding then unwinding then done. The spot leg posts as a maker; each spot fill is hedged with a taker order on the perp leg. The algorithm unwinds (taker on both legs) on any exit trigger, or immediately if you cancel it.
Exit triggers (any one unwinds the position):
- Funding decay when the smoothed APR falls below
exit_apr_thresholdandmin_hold_hourshas elapsed (the main hysteresis exit). - Funding flip when the smoothed APR is strongly adverse (below the negative of
entry_apr_threshold). Instant, bypasses the minimum hold. - Basis blow-out when the basis exceeds
stop_loss_basis_bps. Instant, bypasses the minimum hold. - Kill switch when you cancel the algorithm; both legs are flattened.
side is always buy for v1 (long spot, short perp); it is fixed regardless of what you send.
State (the position view)
The state block on GET /oems/algorithms/{order_id} is the live position:
state.legs. Each leg’s child orders are the algorithm’s slices grouped by symbol - fetch them from GET /oems/algorithms/{order_id}/slices (spot leg vs perp leg, with opposite sides). Profitability is the state.pnl block: funding collected, fees paid, mark-to-market basis drift, and the net. This strategy P&L is distinct from the execution tca block (which measures slippage and fee savings, not carry).
Funding accounting depends on the venue.
funding_collected only counts realized funding payments the venue reports per fee event; it is never estimated. Kraken Futures has no per-payment funding endpoint, so on Kraken funding_collected stays 0 and the net is carried by unrealized_basis_pnl. Binance, Bybit, and OKX report per-payment funding and populate it.- Pre-fund both wallets (spot cash for the long, perp margin for the short). v1 does not auto-transfer between wallets; it does pre-check balances and refuses to start if either leg is underfunded.
- Keep
leveragelow (2 to 3x). It sets the perp liquidation distance and does not change the spot cash you need. - Leave a healthy gap between
entry_apr_thresholdandexit_apr_threshold. A narrow band re-introduces churn; a wide band holds through normal funding dips. - Pick markets by their realized funding history, not the instantaneous prediction. On majors whose funding sits near zero, the fee gate will (correctly) refuse to open, so a one-off high print will not trigger a trade.
- Cancel the algorithm to flatten the position immediately (the kill switch).
Aggression Levels
Applies to TWAP, Ladder, TimePace, and Spread algorithms.GET /order-execution/algorithms/
Get the status and progress of an algorithm.Path Parameters
Request Example
Response Example
TCA Summary (tca)
Post-trade Transaction Cost Analysis, computed from the order’s fills. It is
null until the order has at least one fill.
vs_market_order breakdown
vs_market_order is an estimate (estimated: true). The price-improvement
leg assumes a market order crosses half the arrival spread and ignores
market impact, so for large orders the real saving is larger than shown.
It needs the venue’s maker/taker fee rates; if those aren’t available it falls
back to the observed taker rate of the order’s own market fills.POST /order-execution/algorithms//pause
Pause a running algorithm. Stops generating new slices but keeps open orders.Request Example
Response Example
POST /order-execution/algorithms//resume
Resume a paused algorithm.Request Example
Response Example
POST /order-execution/algorithms//cancel
Cancel an algorithm. Cancels all open child orders.Request Example
Response Example
GET /order-execution/algorithms//slices
Get all child orders (slices) for an algorithm.Request Example
Response Example
symbol and side. For single-symbol
algorithms these match the parent order (or are null on older records).
Multi-leg algorithms (Spread) emit slices on different symbols and
opposite sides: the anchor leg trades anchor_symbol on the parent side,
the contra leg trades contra_symbol on the opposite side as a hedge.
arrival_price always refers to the slice’s own market and may be null
when no snapshot for that market was available at submission.
GET /order-execution/algorithms
List all algorithms.Query Parameters
Request Example
GET /order-execution/algorithms/by-status/
List algorithms by status.Request Example
GET /order-execution/algorithms/by-account/
List algorithms for a specific exchange account.Request Example
Algorithm Status Lifecycle
TCA Metrics (Transaction Cost Analysis)
Each algorithm tracks execution quality metrics:Calculating Implementation Shortfall
Error Handling
Daily Limit Behavior
When an algorithm hits the daily trading limit:- Remaining slices are rejected
- Algorithm is paused automatically
- Check
/order-execution/execution/daily-limitfor current limit status

