Strategies are built by chaining pipeline functions. Each function receives theDocumentation Index
Fetch the complete documentation index at: https://mathematicalcompany.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Context plus the outputs of previous functions. The final function must return list[Quote].
Basic Example
How It Works
Horizon inspects each function’s signature to determine how many arguments it expects. Previous outputs are passed in order:| Parameters | What’s passed |
|---|---|
(ctx) | Just the context |
(ctx, prev) | Context + last output |
(ctx, a, b) | Context + last two outputs |
(ctx, a, b, c) | Context + last three outputs |
Signature Introspection
The pipeline runner usesinspect.signature() to count parameters:
Pipeline Rules
- At least one function is required in the pipeline
- The final function must return
list[Quote](or a singleQuote) - Each function runs once per market per cycle
- If a function raises an exception, the error is logged and that market is skipped for the cycle
- The pipeline runs for every market in the
marketslist
Result Processing
After the pipeline runs,_process_result() handles the output:
- Cancel existing orders for the market (
cancel_market()) - Tick the paper exchange with the feed mid price (or quote mid as fallback)
- Update mark prices for unrealized P&L tracking
- Submit new quotes, routed to the correct exchange based on
market.exchange
Risk rejections during quote submission are logged at
debug level (not warning), since they’re expected during normal operation (e.g., position limits hit).Composability Examples
Adding a stage
You can add an intermediate stage without modifying existing functions:Multiple data sources
The hz.quotes() Helper
A convenience function to create quotes from a fair value and spread:
Built-in Pipeline Functions
Horizon provides several ready-to-use pipeline functions that can be composed together:| Factory | Returns | Description |
|---|---|---|
hz.market_maker(...) | list[Quote] | Avellaneda-Stoikov market making with multi-level quoting |
hz.signal_combiner(...) | float | Combine multiple alpha signals into a composite score |
hz.kelly_sizer(...) | float | Kelly criterion position sizing |
hz.arb_scanner(...) | list[Quote] or None | Continuous cross-exchange arbitrage scanning |
hz.hawkes_intensity(feed_name, mu, alpha, beta) | float | Hawkes self-exciting process intensity |
hz.correlation_estimator(feed_names, window) | list[list[float]] | Ledoit-Wolf shrinkage correlation |
hz.hot_reload(source) | dict | Runtime parameter hot-reload |