Use this file to discover all available pages before exploring further.
Horizon uses SQLite with WAL mode for crash recovery and an audit trail. All fills, order events, position snapshots, and risk events are persisted automatically.
Source of truth for position reconstruction. Uses INSERT OR IGNORE on fill_id for idempotent dedup.
CREATE TABLE fills ( fill_id TEXT PRIMARY KEY, order_id TEXT NOT NULL, market_id TEXT NOT NULL, side TEXT NOT NULL, order_side TEXT NOT NULL, price REAL NOT NULL, size REAL NOT NULL, fee REAL NOT NULL DEFAULT 0.0, timestamp REAL NOT NULL, token_id TEXT, exchange TEXT NOT NULL DEFAULT '', inserted_at REAL NOT NULL);
order_events - Order lifecycle log
One row per status change (append-only).
CREATE TABLE order_events ( id INTEGER PRIMARY KEY AUTOINCREMENT, order_id TEXT NOT NULL, market_id TEXT NOT NULL, side TEXT NOT NULL, order_side TEXT NOT NULL, price REAL NOT NULL, size REAL NOT NULL, filled_size REAL NOT NULL DEFAULT 0.0, remaining_size REAL NOT NULL, order_type TEXT NOT NULL, time_in_force TEXT NOT NULL, status TEXT NOT NULL, status_reason TEXT, exchange TEXT NOT NULL DEFAULT '', created_at REAL NOT NULL, recorded_at REAL NOT NULL);
position_snapshots - Periodic snapshots
Periodic snapshots for fast recovery. Each snapshot is a batch of positions with a shared timestamp.
CREATE TABLE position_snapshots ( id INTEGER PRIMARY KEY AUTOINCREMENT, snapshot_batch REAL NOT NULL, market_id TEXT NOT NULL, side TEXT NOT NULL, size REAL NOT NULL, avg_entry_price REAL NOT NULL, realized_pnl REAL NOT NULL, unrealized_pnl REAL NOT NULL, token_id TEXT, exchange TEXT NOT NULL DEFAULT '');
risk_events - Risk event log
Kill switch activations, deactivations, and violations.
CREATE TABLE risk_events ( id INTEGER PRIMARY KEY AUTOINCREMENT, event_type TEXT NOT NULL, details TEXT, timestamp REAL NOT NULL);
strategy_runs - Run audit trail
Records strategy run start/end with exchange info.
CREATE TABLE strategy_runs ( run_id TEXT PRIMARY KEY, strategy_name TEXT NOT NULL, exchange TEXT NOT NULL, started_at REAL NOT NULL, ended_at REAL, config TEXT);
# Snapshot positions to DBcount = engine.snapshot_positions()# Recover state from DBcount = engine.recover_state()# Record strategy run start/endengine.start_run("my_strategy")engine.end_run()# Check persistence statusengine.has_persistence() # True/False# Get current run IDengine.db_run_id() # UUID string# Get orphaned order IDsengine.db_open_order_ids() # list[str]
# Show recent fillspython -m horizon fills --db ./my_strategy.db --limit 50# Show fills for a specific marketpython -m horizon fills --db ./my_strategy.db --market will-btc-hit-100k# Show latest position snapshotpython -m horizon positions --db ./my_strategy.db# Show orders (open only by default)python -m horizon orders --db ./my_strategy.dbpython -m horizon orders --db ./my_strategy.db --all