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