Risk Management
Every trade signal must pass through a deterministic risk management gate before an order is placed. The risk manager runs all checks on every signal without short-circuiting, so all violations are logged simultaneously. If any single check fails, the trade is rejected.
14-Check Risk Gate
Before any order is submitted, the signal must pass all 14 checks. Checks 1-5 apply to all signals. Checks 6-14 apply only to BUY signals.
- Symbol blacklist -- the symbol must not be on the configured blacklist
- Circuit breaker status -- the system-wide circuit breaker must not be active
- Signal expiry -- the signal must not have expired (default max age: 300 seconds)
- Signal confidence-- the signal's confidence score must meet the minimum threshold (default: 0.70)
- Max daily trades -- the number of trades placed today must be below the limit (default: 50)
- Max open positions -- total number of concurrent positions must be below the limit (default: 15)
- Volume filter-- the stock's daily volume must meet the minimum threshold (default: 100,000 shares)
- Spread check -- the bid-ask spread must be within acceptable bounds (default: 2%)
- Position size limit -- the total position value (existing + proposed) cannot exceed the max single position percentage (default: 10% of equity)
- Sector allocation -- adding this position must not push any sector above the max sector exposure limit (default: 30%)
- Correlated exposure -- the total value of correlated positions must stay below the limit (default: 40% of equity)
- Cash reserve -- sufficient cash must remain after the trade to meet the minimum reserve (default: 10% of equity)
- Daily loss limit -- cumulative daily P&L must not have breached the max daily loss (default: 3%)
- Max drawdown -- current portfolio drawdown must be below the configured limit (default: 15%)
Circuit Breaker
The circuit breaker is an automatic safety mechanism that halts all trading when dangerous conditions are detected. When triggered, no new orders are placed and the dashboard displays a warning. Trading resumes automatically after the halt duration expires (default: 60 minutes), or you can manually resume from the dashboard.
The circuit breaker activates when any of these seven conditions occur:
- Consecutive losing trades -- 5 or more consecutive trades result in a loss
- Daily loss limit breached -- cumulative losses for the day exceed the max daily loss threshold
- Weekly loss limit breached -- cumulative losses for the week exceed the max weekly loss threshold (default: 7%)
- Max drawdown breached -- portfolio drawdown exceeds the configured maximum (default: 15%)
- VIX threshold -- VIX exceeds the configured threshold (default: 35)
- System errors -- 3 or more errors within a 5-minute window
- Manual kill switch -- the operator presses the kill switch on the dashboard
Position Sizing
KlawTrade uses a fixed fractional approach by default to calculate position sizes. The position sizer takes the minimum of several constraints: the signal's suggested quantity, the max single position size (default: 10% of equity), available cash after reserve, and risk-per-trade sizing based on stop-loss distance.
A Kelly criterion implementation is also available. The Kelly formula determines how much capital to allocate based on historical win rate and win-to-loss ratio:
Kelly % = W - (1 - W) / RWhere W is the win probability and R is the ratio of average win size to average loss size. Half-Kelly (50% of the full allocation) is recommended to reduce volatility.
Regardless of the sizing method, every position is capped by the max_single_position_pct setting (default: 10%) and the max_single_trade_loss_pct setting (default: 2%) to ensure no single trade risks more than the configured percentage of total portfolio value.