- 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 toAddStrategy.
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.
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
pricefor a buy or below it for a sell.
closed: the fullvolumewas 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 calledCancelStrategy.
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_feereports 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, andvalidate: truedoes 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
openwithreason: insufficientFundsand continues once funds are available. Volume that is still unfilled when the window ends isn’t executed, and the strategy endsexpired.
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 thenonce 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
Will my average price equal the market's TWAP exactly?
Will my average price equal the market's TWAP exactly?
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.
Is my full volume guaranteed to execute?
Is my full volume guaranteed to execute?
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.Do I need to stay connected?
Do I need to stay connected?
No. The strategy runs on Kraken’s side. Disconnecting, or losing your session, doesn’t affect it.
Can I run several TWAPs at once?
Can I run several TWAPs at once?
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.
Can I change a TWAP after creating it?
Can I change a TWAP after creating it?
Not yet. Cancel it with
CancelStrategy and create a new one. Fills from the cancelled strategy are kept.How do I find the trades a TWAP made?
How do I find the trades a TWAP made?
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