# Trading Risk Management

> Risk management patterns, circuit breakers, and compliance controls for the trading ecosystem.

- Skill: `knuckles-team/trading-risk-management` (Agent Skill)
- Install (CLI): `npx skillmds@latest add knuckles-team/trading-risk-management`
- Raw SKILL.md: https://api.skillmd.com/api/skills/knuckles-team/trading-risk-management/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: Knuckles-Team (https://skillmd.com/u/knuckles-team)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/knuckles-team/trading-risk-management

---


# Risk Management Skill-Graph — CONCEPT:AU-AHE.assimilation.skill-workflow-ingest / AU-OS.safety.prompt-injection-scanner

Comprehensive risk management patterns enforced by the Emerald Exchange RiskGuard engine.

## P0 Risk Controls

### Circuit Breakers
| Control | Threshold | Action | Recovery |
|---------|-----------|--------|----------|
| Portfolio Drawdown | > 10% from peak | HALT all trading | Manual resume only |
| Daily Loss Limit | > 3% of equity | HALT new orders | Next trading day |
| Regime Shift | KS-test p < 0.05 | HALT + alert | Manual review |
| Kill Switch | Manual trigger | HALT immediately | `emerald_orders(action='resume')` |

### Position Sizing — Kelly Criterion
```
Kelly fraction = W - (1-W)/R
Where:
  W = historical win rate
  R = win/loss ratio (avg win / avg loss)

Capped at: min(kelly, max_position_pct=2%)
```

### Pre-Trade Validation
Every order passes through `RiskGuard.pre_trade_check()`:
1. **Halt check**: Is trading halted?
2. **Position size**: Does this exceed 2% equity limit?
3. **Concentration**: Portfolio exposure to single asset?
4. **Cash availability**: Sufficient buying power?
5. **Live gate**: If live mode, require human approval (OS-5.1)

## Regime Detection — CONCEPT:EX-AHE.harness.ee-11

### Hidden Markov Model (HMM)
- 3-state model: Bull, Bear, Neutral
- Trained on rolling 252-day windows
- State transitions trigger portfolio adjustments

### KS-Test Regime Shift
- Kolmogorov-Smirnov test on recent vs historical prediction distributions
- Detects distribution drift before traditional drawdown signals
- p-value < 0.05 triggers circuit breaker

## Monitoring Schedule
| Check | Interval | MCP Tool |
|-------|----------|----------|
| Drawdown | 5 minutes | `emerald_risk(action='drawdown_check')` |
| Daily P&L | 5 minutes | `emerald_risk(action='daily_loss_check')` |
| Regime | 15 minutes | `emerald_signals(action='regime')` |
| Portfolio snapshot | 15 minutes | `emerald_portfolio(action='positions')` |

## Human-in-the-Loop — OS-5.1
- **Paper → Live promotion**: Requires explicit human approval via `graph_orchestrate.request_approval`
- **Kill switch**: Any agent can halt; only human can resume live trading
- **Audit trail**: All risk events persisted as `RiskSnapshot` nodes in KG

## Integration Points
- **Risk MCP**: `emerald_risk` — status, drawdown, daily loss, Kelly, limits
- **Orders MCP**: `emerald_orders` — halt/resume kill switch
- **KG Ontology**: `RiskSnapshot`, `regimeState`, `isHalted` OWL classes
- **Workflow**: `risk-monitoring` cron (every 5 min)

