Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Risk Manager

RiskManager enforces pre-trade risk controls. Every order passes through it before reaching the gateway.

Checks

CheckDescription
Position limitRejects orders that would exceed the configured max position size
Daily loss guardHalts trading when realized + unrealized loss exceeds the daily limit
Rate limitEnforces a maximum number of orders per second
Kill switchImmediately blocks all new orders; drains open orders via cancel

Configuration

#![allow(unused)]
fn main() {
RiskConfig {
    max_position:    dec!(1.0),      // max open qty per symbol
    daily_loss_limit: dec!(500.0),   // USD
    max_orders_per_sec: 10,
}
}

Kill switch

Activate programmatically:

#![allow(unused)]
fn main() {
risk_manager.kill();
}

Or via the TUI with the K keybinding. Once triggered, the engine stops submitting new orders and attempts to cancel all open positions.