Skip to main content

Installation

Requires Python 3.10+.
1

Install the package

2

Set your API key

Get your key at api.mathematicalcompany.com, then:
Add this to your shell profile (~/.zshrc or ~/.bashrc) so it persists.
3

Verify installation

Your First Strategy

Create a file my_strategy.py:
Run it:
You should see output like:
Press Ctrl+C to stop. All open orders are canceled automatically on shutdown.

What Just Happened?

  1. hz.run() created a paper exchange engine with risk limits
  2. A SQLite database was opened at ./my_strategy.db for persistence
  3. The main loop started, running your pipeline every 1 second:
  • fair_value returned 0.50
  • quoter received 0.50 and generated quotes at bid=0.47 / ask=0.53
  • The engine canceled stale orders, submitted new quotes, and ticked the paper exchange
  1. On Ctrl+C, positions were snapshotted and all orders canceled

Next Steps

Core Concepts

Understand hz.run(), pipelines, and the context object.

Exchanges

Connect to Polymarket, Kalshi, Alpaca, IBKR, Coinbase, Robinhood, or trade on paper.

Examples

See full strategy examples with live feeds.

Multi-Exchange

Trade on multiple exchanges simultaneously.