Skip to main content

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
Response Example
How TWAP executes TWAP splits the order into total_intervals = duration_seconds / interval_seconds slices and works one interval at a time:
  1. Interval start, compute the interval’s target size (base = total_quantity / total_intervals, jittered ±20% when randomize_size is on) and post a passive limit at the chosen aggression level.
  2. 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.
  3. Catch-up (when catch_up_enabled), if the algo has fallen behind the schedule, it sends an extra IOC of up to max_catch_up_pct% of the interval size to close the gap.
  4. Fill crediting, every child-order fill (passive or IOC) is credited to progress.filled_quantity and child_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.
Best Practices
  • Use passive aggression for large orders to minimize market impact
  • Keep catch_up_enabled on (default) so the order fills its full quantity
  • Set limit_price as 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
Response Example
Best Practices
  • Use linear distribution to concentrate size near market price
  • Set cancel_on_fill_pct to 70-80% to capture most fills without overfilling
  • Use reprice_on_move_bps for volatile markets to keep levels relevant
  • Keep num_levels at 3-10 for most use cases

Sweep Parameters

Request Example
Response Example
Best Practices
  • 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_bps to 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
Response Example
Best Practices
  • Use TimePace when you want predictable, fixed-size executions
  • Set limit_price to 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 trades anchor_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)
Response Example
Best Practices
  • Set risk_quantity conservatively - it limits max unhedged exposure
  • Use immediate sweep trigger for tight risk management
  • Set pause_offset_pct to 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_hours is 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 lower exit_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 exceeds max_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_threshold and min_hold_hours has 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.
Request Example (Kraken BTC carry)
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:
The two open legs and their entry prices live under 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.
Best Practices
  • 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 leverage low (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_threshold and exit_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.
Reading the sign: because implementation_shortfall_bps isn’t flipped by side, a value near zero means the algo tracked the arrival price almost exactly (excellent execution). For a buy, negative is favourable; for a sell, positive is favourable.

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

Each slice carries its own 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

Positive = paid more than arrival (for buys), negative = got better price.

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-limit for current limit status

Choosing an Algorithm

TWAP vs TimePace