Risk Pipeline
The checks run in order. If any check fails, the order is rejected immediately:Configuration
Risk Builder
TheRisk class provides a clean builder API:
hz.Risk() does not support max_position_per_event. For event-level position limits, use RiskConfig directly (see below).Equity Risk Preset
For equity strategies, useRisk.equity() which sets appropriate defaults:
Risk.equity() sets price_min=0.01 and price_max=100000 (vs 0.01-0.99 for prediction markets).
Use default
hz.Risk() for prediction markets (price: 0.01-0.99). Use Risk.equity() for equities/options (price: 0.01-100,000). For crypto, customize price_min/price_max to match the asset’s range.RiskConfig (Direct)
For full control, use the RustRiskConfig directly:
Kill Switch
The kill switch is a global emergency stop:- Daily drawdown exceeds
max_drawdown_pct - You can also trigger it manually or from a pipeline function
Drawdown Tracking
The strategy loop automatically tracks drawdown:- On startup, the daily baseline is set to the current total P&L
- Each cycle,
update_daily_pnl()is called with the latest total P&L - If P&L drops below
baseline * (1 - max_drawdown_pct / 100), the kill switch triggers
Rate Limiting
The rate limiter uses a token bucket algorithm:- Sustained rate: refill rate in orders per second
- Burst capacity: maximum tokens available for bursts
Dedup Window
The dedup check prevents submitting identical orders within a configurable time window. Two orders are considered duplicates if they have the same:- Market ID
- Side (Yes/No/Long)
- Order side (Buy/Sell)
- Size
- Price
Event Risk Limits
When trading multi-outcome events, you can setmax_position_per_event to cap total exposure across all outcomes in an event:
engine.register_event() (or via hz.run(events=...)). Markets not in any event are unaffected.
When max_position_per_event is None (the default), event-level risk checks are skipped entirely.