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.

  1. Symbol blacklist -- the symbol must not be on the configured blacklist
  2. Circuit breaker status -- the system-wide circuit breaker must not be active
  3. Signal expiry -- the signal must not have expired (default max age: 300 seconds)
  4. Signal confidence-- the signal's confidence score must meet the minimum threshold (default: 0.70)
  5. Max daily trades -- the number of trades placed today must be below the limit (default: 50)
  6. Max open positions -- total number of concurrent positions must be below the limit (default: 15)
  7. Volume filter-- the stock's daily volume must meet the minimum threshold (default: 100,000 shares)
  8. Spread check -- the bid-ask spread must be within acceptable bounds (default: 2%)
  9. Position size limit -- the total position value (existing + proposed) cannot exceed the max single position percentage (default: 10% of equity)
  10. Sector allocation -- adding this position must not push any sector above the max sector exposure limit (default: 30%)
  11. Correlated exposure -- the total value of correlated positions must stay below the limit (default: 40% of equity)
  12. Cash reserve -- sufficient cash must remain after the trade to meet the minimum reserve (default: 10% of equity)
  13. Daily loss limit -- cumulative daily P&L must not have breached the max daily loss (default: 3%)
  14. 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:

  1. Consecutive losing trades -- 5 or more consecutive trades result in a loss
  2. Daily loss limit breached -- cumulative losses for the day exceed the max daily loss threshold
  3. Weekly loss limit breached -- cumulative losses for the week exceed the max weekly loss threshold (default: 7%)
  4. Max drawdown breached -- portfolio drawdown exceeds the configured maximum (default: 15%)
  5. VIX threshold -- VIX exceeds the configured threshold (default: 35)
  6. System errors -- 3 or more errors within a 5-minute window
  7. 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) / R

Where 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.