Horizon SDK

A trading SDK whose backtest runs the live code

Quant Finance · Rust + Python · SDK

Moving a strategy from a notebook to a real venue usually takes weeks. Each broker has its own quirks and each asset class its own conventions, the live system ends up as different code from the backtest, and the number you measured stops being the number you get.

Horizon is the SDK I built so a strategy is written once. You write it as a few plain Python functions, and a Rust engine runs them through the same pipeline whether the data is historical or live. The same strategy can trade prediction markets on Polymarket, Kalshi or Limitless, equities and options through Alpaca or Interactive Brokers, and crypto on Coinbase, Robinhood or Hyperliquid. It was the engine behind MC².

How it works

  1. 01

    A strategy is a list of functions

    Each function receives the context and the previous function's output, and the last one returns orders or quotes. A call to hz.run() starts the feeds, attaches the risk checks and starts the event loop. Seventeen kinds of feed arrive through the same stream, from venue order books and a Binance trade stream to a Chainlink price oracle read on-chain.

  2. 02

    Every order passes eight checks

    Between the strategy and the exchange, each order goes through a kill switch, price and size sanity checks, a position limit, a portfolio notional limit, a daily drawdown stop, duplicate detection and a rate limit. Any of them can reject it. A strategy can override the checks, add its own, and test them next to its own code.

  3. 03

    The backtest replays history through the same pipeline

    The backtester feeds historical ticks through the same functions hz.run() uses, against a paper exchange that matches orders tick by tick. Fees, the fill model, market impact and latency are parameters of the run. Walk-forward optimization leaves a purge gap between training and test windows, so no future data leaks into the fit. Going live changes the exchange and nothing in the strategy.

  4. 04

    A live strategy runs unattended

    A terminal dashboard shows positions, fills and PnL as they happen. State persists to SQLite, so after a crash the strategy resumes from its last known position, and a command line handles deploy, pause, resume and rollback. A fund layer can run many strategies side by side under one shared risk budget.

Inside

Avellaneda-Stoikov market making with inventory skew, Almgren-Chriss execution, Kelly sizing and hierarchical risk parity are written from scratch in Rust.

TWAP, VWAP and iceberg execution come with it, along with cross-venue arbitrage that rolls back if any leg fails.

Each venue keeps its own authentication behind one interface, from Polymarket's contract wallets to Hyperliquid's EIP-712 signatures.

All projects