Skip to main content
Ultra Feature. Requires an Ultra subscription. Get started at api.mathematicalcompany.com

Multi-Leg Execution

Spread trades, hedged positions, and arbitrage strategies require multiple orders that must succeed or fail together. Horizon’s multi-leg module provides atomic execution with three fill policies, aggregate risk checks, and cross-exchange leg support. Type validation is in Rust; execution orchestration is in Python.

Overview

Fill Policies

All-or-none, best-effort, and delta-neutral execution modes.

Aggregate Risk

hz.aggregate_leg_risk() sums notional across all legs before submission.

Validation

hz.validate_legs() checks legs for completeness before execution.

Cross-Exchange

Each leg can target a different exchange.

Core Types

FillPolicy

Leg


Core Functions

hz.validate_legs

Check legs for completeness (non-empty market_id, positive size).

hz.aggregate_leg_risk

Sum risk metrics across all legs.

hz.build_mock_result

Build a mock execution result for backtesting.

Pipeline Function

hz.multi_leg

Execute multiple legs atomically each cycle.
Returns each cycle:

Examples

Hedged Entry

Dynamic Legs from Pipeline