Horizon SDK
Horizon is a trading SDK. Rust core, Python interface. Build, backtest, and deploy strategies across prediction markets (Polymarket, Kalshi), equities and options (Alpaca, IBKR), crypto (Coinbase, Robinhood), and paper — all from a singlehz.run() call.
Rust Core
Risk pipeline, order management, position tracking, and exchange clients compiled to a native Python extension via PyO3.
Multi-Asset
Prediction markets, equities, options, crypto. Trade across exchanges with cross-exchange netting and unified position tracking.
Pipeline Composition
Chain functions with automatic signature introspection. Insert or remove stages without changing downstream code.
Key Features
- Single entry point:
hz.run()handles engine creation, feed management, position sync, and the main loop - 8-point risk pipeline: kill switch, price/size validation, position limits, notional limits, drawdown checks, rate limiting, and dedup
- Advanced orders: stop-loss, take-profit, bracket orders with OCO linking, and order amendment
- Execution algorithms: TWAP, VWAP, and Iceberg for large order execution
- Backtesting:
hz.backtest()replays historical data through the same pipeline as live trading, with full analytics - Kelly criterion: Rust-native Kelly sizing functions for optimal position sizing
- Automated market making: Avellaneda-Stoikov model with inventory skew, competitive spread blending, and multi-level quoting
- Signal combiner: Weighted average, rank, and z-score combination of alpha signals with built-in extractors
- Monte Carlo simulation: Portfolio stress testing with correlated binary outcomes, VaR, CVaR, and full scenario distributions
- Arbitrage executor: Atomic cross-exchange arb execution with auto-rollback, pipeline scanner, and one-shot sweep
- Equity/options discovery: search stocks, pull options chains, compute Greeks, IV surfaces, and screen by fundamentals via the
equityCLI group Side.Long: first-class side for equities and crypto alongsideSide.Yes/Side.Nofor prediction marketsRisk.equity(): classmethod with equity-appropriate defaults (no 0-1 price clamping, sensible position/notional limits)- Live feed system: Binance WebSocket, Polymarket orderbook, Kalshi orderbook, Alpaca, IBKR, Chainlink on-chain oracles, and generic REST feeds
- Multi-exchange support: trade on multiple exchanges simultaneously with
exchanges=[...] - Netting pairs: offset correlated positions across exchanges for reduced notional exposure
- Monitoring: Prometheus metrics server, multi-channel alerts (Discord, Telegram, webhooks), and calibration tracking
- SQLite persistence: crash recovery via position snapshots and fill replay
- TUI dashboard: real-time monitoring with Textual (P&L, positions, orders, risk, fills, feeds)
- CLI: run strategies with option overrides from the command line
- Paper trading: local simulated exchange with tick-based matching for strategy development
How It Works
Backtest First, Deploy Live
Run the same pipeline on historical data before going live:Protect Positions
Add stop-loss and take-profit with a single call:Technology
| Layer | Technology | Purpose |
|---|---|---|
| Core | Rust + PyO3 | Risk, orders, positions, exchanges, feeds, asset types |
| SDK | Python 3.10+ | Strategy composition, configuration, dashboard |
| Build | maturin | Rust to Python native extension |
| Async | tokio | WebSocket feeds, HTTP exchange clients |
| Storage | SQLite (WAL) | Persistence, crash recovery, audit trail |