Skip to main content
TWAP (time-weighted average price) works a large buy or sell across a time window you choose. A single large order can move the price against you. TWAP instead spreads the execution across the window in many smaller child orders. The aim is an average fill price close to the market’s average price over that window, with less market impact. Typical uses:
  • Building or reducing a position gradually, without signalling the full size to the market
  • Executing size on pairs where the order book is thin
  • Running a scheduled buy or sell without keeping a client connected

At a glance

Parameters

Send these fields to AddStrategy. volume and price follow the same precision and minimum rules as a regular order on the pair. See AssetPairs for lot_decimals, pair_decimals, ordermin and costmin.

How Kraken executes a TWAP

This section describes current behaviour. How child orders are sized, timed and placed is managed by Kraken and may change as execution improves. Your parameters, and the limit price of a limit TWAP, are always respected.
A TWAP runs in Kraken’s algorithmic execution engine, a service that sits alongside the matching engine. The execution engine holds your strategy, follows market data and your fills, and sends child orders to the matching engine through the same path as any other order. Because the logic runs on Kraken’s side, a strategy keeps executing whether or not your client is connected. 1. A schedule across the window. Kraken spreads volume across the time between starttm and expiretm. At any moment the strategy has a target: the share of the volume that should be filled by now. Halfway through the window, about half the volume should be filled. 2. Child orders when the strategy is behind. Kraken checks the strategy regularly against that target and sends a child order whenever the filled volume falls behind it. Child order sizes and timing vary. A TWAP therefore doesn’t leave a fixed, predictable pattern on the book that other participants could trade against. 3. Each child order takes the available price. Every child order is an immediate-or-cancel limit order:
  • Market TWAP: priced to trade at the best available price, within Kraken’s market price protection.
  • Limit TWAP: priced to trade at the best available price, but never above your price for a buy or below it for a sell.
4. Unfilled quantity is caught up later. If a child order doesn’t fill completely, the unfilled part is cancelled straight away, so child orders never rest on the book. The shortfall stays on the schedule and is picked up by later child orders. 5. The window closes out. Kraken completes the remaining volume towards the end of the window, so the last child orders can be larger than earlier ones. If a remainder is smaller than the pair’s minimum order size, it is folded into an earlier child order, so the strategy isn’t left with an amount it can’t trade. 6. The strategy ends.
  • closed: the full volume was executed.
  • expired: the window ended first, for example because a limit TWAP’s price was never reached or the account ran out of funds. The filled part stays filled and nothing more is executed.
  • cancelled: you called CancelStrategy.

Market and limit TWAP

Funds and fees

  • Fees: each fill is charged the standard trading fee for your account’s fee tier. Child orders are currently immediate-or-cancel, so they take liquidity and are charged the taker fee. TWAP adds no fee of its own. A strategy’s total_fee reports the fees paid so far.
  • Balance check at creation: the execution engine performs a best-effort balance check for the full volume. Sells require base currency. Market buys are valued at the current ask; limit buys use the lower of the ask and the limit price, or the limit if no ask is available. Insufficient balance can reject creation with EOrder:Insufficient funds. Funds are not reserved, and validate: true does not run this check.
  • Balance check per child order: every child order is checked against your available balance when it’s placed, exactly like an order you place yourself. Other orders, withdrawals or other strategies can use the same funds in the meantime.
  • Running short: if a child order can’t be funded, the strategy stays open with reason: insufficientFunds and continues once funds are available. Volume that is still unfilled when the window ends isn’t executed, and the strategy ends expired.
Each child order also goes through the same checks as a regular order, such as order minimums and account limits.

Tracking progress

GetOpenStrategies, QueryStrategies and GetClosedStrategies return a details object with the strategy’s running totals: Child orders appear in ClosedOrders and trade history as limit orders, including for a market TWAP, because that is how they’re sent to the book. They do not rest on the book, so use the strategy endpoints to monitor progress. They can’t yet be linked back to their strategy_id from those endpoints, so use the strategy totals above for your execution reporting.

Cancelling

CancelStrategy stops further child-order scheduling. An already-submitted child order may still fill while cancellation completes, and those fills are kept. The strategy normally finishes as cancelled with reason: userRequested; if the in-flight order completes the requested volume, it can finish as closed. Poll QueryStrategies for the terminal status and final execution totals. To change a running TWAP’s volume, price or window, cancel it and create a new one. Amending a strategy isn’t supported yet.

Examples

Create a limit TWAP

Buy 0.5 BTC over the next hour, never paying more than 60,000 USD.
Request: POST /0/private/AddStrategy
Response

End-to-end in Python

The example validates the request, creates the strategy, checks its progress and cancels it. The request signing is the standard REST authentication: for a JSON body, the signature covers the nonce followed by the exact JSON string you send.
twap_example.py

Read a strategy’s progress

Response: POST /0/private/QueryStrategies

Validation

AddStrategy rejects the request, and creates nothing, when: Send validate: true to check a request without creating it. Validation doesn’t run the creation-time balance check, so a request that passes can still fail with EOrder:Insufficient funds when you submit it without validate. See the error reference for how errors are returned.

FAQ

No. TWAP aims for an average price close to the market’s time-weighted average price over the window, but it’s not guaranteed. The result depends on liquidity, volatility and, for a limit TWAP, your limit price.
No. A market TWAP normally completes within the window on liquid pairs. A limit TWAP only trades at or better than your price, so it can end expired with part of the volume unfilled. Insufficient funds can also leave volume unfilled.
No. The strategy runs on Kraken’s side. Disconnecting, or losing your session, doesn’t affect it.
Yes. Each one is checked against your available balance independently, and funds aren’t reserved, so make sure your balance covers all of them. The number of open strategies per account is limited.
Not yet. Cancel it with CancelStrategy and create a new one. Fills from the cancelled strategy are kept.
They appear in ClosedOrders and trade history like any other orders, but they can’t yet be linked to their strategy_id there. The strategy’s details (filled_volume, avg_price, total_cost, total_fee) give you the totals.

Algo Trading overview

Strategies, lifecycle and endpoints

Add Strategy

API reference for creating a TWAP

Get Closed Strategies

Review finished strategies