spb/crypto-trade-bot
Public
Python 54.7%
TypeScript 42.5%
SQL 1.9%
1# Operator runbook23## Daily checks4- `GET /api/health` → `db: ok`, `redis: ok`, `stream.connected: true`, `stream.last_msg_age < 10`.5- `/settings` → Kraken status `online`, clock drift < 2 s; `/market` → data-quality badges green (lag_bars 0–1).6- `pm2 ls` on the node: `crypto-trade-bot-api|web|worker` online, restarts not climbing.78## Common operations9| Task | Command |10|---|---|11| Apply migrations | `ktrade migrate` |12| One-shot OHLC pull | `ktrade backfill` |13| Probe key permissions (never trades) | `ktrade preflight` or Settings → Preflight |14| Change owner password | `ktrade set-owner-password` → put hash in env → restart api |15| Verify audit chain | `ktrade audit-verify` |16| Kill switch | Risk Center → toggle (audited) — blocks all new orders; cancels eligible open orders in Phase 4/5 |17| Add a pair to the universe | edit `KTRADE_UNIVERSE`, restart worker (pairs refresh immediately) |1819## Failure modes20- **WS disconnected / checksum mismatches climbing**: worker reconnects with backoff; if persistent, restart the21 worker; check Kraken status page. Backtests are unaffected (REST data).22- **Stale candles (lag_bars > 2)**: REST backfill failing → see worker logs `ingest.backfill.error`; rate-limit waits23 are logged as `kraken.ratelimit.wait`.24- **Postgres down**: API health reports `db: error`; gateway defaults to deny; restart `postgresql@17`.25- **Exchange outage**: kill switch still blocks new orders locally; *cancellation of resting exchange orders cannot be26 guaranteed while the exchange is unreachable* (Phase 5 note).2728## Backups & retention29- Postgres: nightly `pg_dump ktrade` (add to PM2 cron on the node); candles are re-accumulable only forward in time —30 **back up `candles` to keep history**.31- Retention: trades 30 d, book samples 14 d (worker `retention_loop`).3233## Deployment (MacLustr)34Manifest `M1M32:~/dispatch/apps/crypto-trade-bot.json`; `mld deploy crypto-trade-bot` (post_sync builds venv + web);35route `https://crypto-trade-bot.app → <node>:8471` on BHS64. Remote-first: edit on the node, `git push` to spbgit.36