SPB Git forge
1commits 1branches 0releases
189.0 KBsize
maindefault branch
3 h agolast push
Python 54.7% TypeScript 42.5% SQL 1.9%
2.2 KB

# Kraken Spot API — facts this code relies on (verified 2026-10-21 on docs.kraken.com)

  • Base https://api.kraken.com/0; public GET /public/{Time,SystemStatus,Assets,AssetPairs,Ticker,OHLC,Depth,Trades}; private POST /private/{Balance,TradeBalance,OpenOrders,ClosedOrders,QueryOrders,TradesHistory,TradeVolume, GetWebSocketsToken,AddOrder,CancelOrder,CancelAll}.
  • Signature: API-Sign = b64(HMAC-SHA512(path + SHA256(nonce + postdata), b64decode(secret))), headers API-Key, API-Sign; nonce strictly increasing uint64 (ms). Test vector reproduced in tests.
  • Rate limits: private counter 15/20/20 (starter/intermediate/pro) decaying 0.33/0.5/1 per s; ledger/trade-history cost 2. Trading engine limiter is separate (add +1, cancel +8…+1 by order age; thresholds 60/125/180).
  • AssetPairs: ordermin, costmin, tick_size, pair_decimals, lot_decimals, cost_decimals, status (online|cancel_only|post_only|limit_only|reduce_only), wsname (v1 names, e.g. XBT/USD), leverage lists. fees/fees_maker are deprecated since 2026-09-08 (always []) → use TradeVolume.
  • OHLC: interval ∈ {1,5,15,30,60,240,1440,10080,21600}; rows [time, open, high, low, close, vwap, volume, count]; last = cursor for since; ≤ 720 most recent entries, older data not retrievable; last row is the forming bar.
  • Depth: count 1–500. Trades: count ≤ 1000, last is a ns cursor.
  • AddOrder: ordertype ∈ market/limit/iceberg/stop-loss/take-profit/…; timeinforce GTC/IOC/GTD/FOK; oflags post for post-only; cl_ord_id (UUID or ≤18 ascii) XOR userref; validate=true validates without trading.
  • WebSocket v2 wss://ws.kraken.com/v2: {"method":"subscribe","params":{"channel":"ticker|book|trade|ohlc", "symbol":["BTC/USD"],…}}; book depth ∈ {10,25,100,500,1000}, checksum = CRC32 over top-10 asks (asc) then bids (desc) with price/qty strings stripped of . and leading zeros; heartbeat ~1/s when idle; one ohlc interval per symbol per connection (observed Already subscribed to one ohlc interval on this symbol).
  • No Spot sandbox exists. Private WS (wss://ws-auth.kraken.com/v2, token from GetWebSocketsToken, ~15 min to first use) is not used yet (Phase 4/5).