Run a portfolio of independent strategies, each with its own risk budget and Engine instance. The StrategyBook provides aggregate analytics, pairwise correlation tracking, rebalancing recommendations, and intervention alerts. The reconciliation module detects discrepancies between engine state and exchange positions.
Strategy Book
Manage multiple engines with isolated risk budgets, rolling Sharpe, and drawdown tracking.
Correlation Monitoring
Pairwise Pearson correlation of PnL changes across strategies.
Capital Rebalancing
Equal, risk-parity, and performance-based budget allocation.
Position Reconciliation
Compare engine vs exchange positions and flag breaks by severity.
The StrategyBook holds references to multiple Engine instances and provides oversight, analytics, and rebalancing. It does not own engines. Each strategy is responsible for its own execution.
book.add_strategy( name="momentum", engine=engine_a, risk_budget=0.4, # 40% of total capital)
Parameter
Type
Default
Description
name
str
required
Unique strategy name.
engine
Engine
required
Reference to the strategy’s Engine instance.
risk_budget
float or None
None
Fraction of total capital to allocate (0.0 to 1.0). If None, budgets are redistributed equally across all strategies.
If risk_budget is None, all existing strategies’ budgets are redistributed equally (including the new one). If a specific budget is provided, the total across all strategies must not exceed 1.0.
Record PnL snapshots for each active strategy. Call this once per cycle to build up the equity curves used for correlation and Sharpe computation.
Copy
book.update()
Queries each strategy’s engine via engine.status() to read current total_pnl. Updates rolling Sharpe, drawdown, and the combined portfolio equity curve.
Return names of strategies that breach risk thresholds.
Copy
troubled = book.needs_intervention( max_drawdown=0.10, # Flag if drawdown > 10% min_sharpe=0.0, # Flag if Sharpe < 0 (with enough history))for name in troubled: print(f"Strategy '{name}' needs attention")
Parameter
Type
Default
Description
max_drawdown
float
0.1
Maximum allowed drawdown (e.g., 0.1 = 10%).
min_sharpe
float
0.0
Minimum acceptable Sharpe ratio. Only checked when 10+ PnL observations exist.
A strategy is flagged if its drawdown exceeds max_drawdown OR its Sharpe falls below min_sharpe (once enough history has accumulated). Both conditions are checked independently.
Detect discrepancies between the engine’s internal position tracking and the exchange’s reported positions. Flags missing positions, size mismatches, and side mismatches with severity levels.
Copy
from horizon.reconciliation import reconcile, auto_reconcile, PositionBreak, ReconciliationReport
Side mismatches are always critical. A side mismatch means your engine thinks you are long but the exchange shows short (or vice versa). This requires immediate attention.
True if no breaks were found in the last reconciliation run.
"recon_breaks"
int
Number of breaks found in the last reconciliation run.
Between reconciliation runs, the pipeline injects the results from the most recent run. The first run happens on the first cycle; subsequent runs occur every interval seconds. Critical breaks are logged at WARNING level; info-level breaks are logged at INFO.