8 Independent StagesAny Stage Can VetoNo Global State

Risk Management Systems

8-stage sequential risk chain — each stage is independently veto-capable. A stage failure logs the kill_reason and stops propagation to execution. No stage has visibility into whether others have already vetoed.

Risk Chain — Sequential Pipeline

Post-signal risk pipeline — each node is an independent gate

SuperIntel risk chain pipeline

The 8 Risk Stages

0
MicrostructureAgentmicrostructure_agent.pyVETO-CAPABLE

Level 2 order book analysis via Databento. Computes Order Book Imbalance (OBI) and detects sell / buy walls. Applied before any ML or LLM processing — the cheapest possible early exit.

OBI = (Bid Vol − Ask Vol) / (Bid Vol + Ask Vol). Veto triggers when OBI > 0.7 in the wrong direction for the trade. Wall detected when a single level holds ≥ 5× average volume across top-10 levels.
1
CVaR Risk Calculatorrisk_calculator.pyVETO-CAPABLE

Conditional Value at Risk (Expected Shortfall) via historical simulation. Confidence level: 95%. Lookback: rolling window from TimescaleDB. Max per-asset position: 5% of total portfolio NAV.

CVaR₀.₉₅ = E[L | L > VaR₀.₉₅]. If the proposed position would breach the 5% per-asset ceiling, RiskCalculator returns a fail signal that blocks the allocation stage entirely.
2
Portfolio Optimizerportfolio_optimizer.pyVETO-CAPABLE

Kelly Criterion allocator with half-Kelly conservative production setting. Enforces 4 sequential constraints: correlation, volatility targeting, sector limits, ATR-based stops.

f* = (p·b − q) / b. Production uses f = f*/2 (half-Kelly). Correlation check: reject if proposed trade > 0.75 correlation with any open position. ATR-based stops size the position so stop-loss ≈ risk budget.
3
ChaosEnginechaos_simulator.pyADVISORY

Monte Carlo jump-diffusion simulation. Generates Normal, Flash Crash, and Gap-Down path types. Output (ChaosReport) is embedded in AgentState and attached to every deal memo. Does not independently veto — an elevated ruined_rate can trigger red_team veto.

dS = μS dt + σS dW + J·S dN — Geometric Brownian Motion + Poisson jump process. μ, σ estimated from YFinance history. Flash Crash: large downward jump mid-path. Gap Down: large gap at open.
4
StressTesterstress_test.pyADVISORY

Replays four historical crisis paths against the proposed position. Output is advisory — informs the deal memo and chaos_report. Does not independently veto.

Scenarios: 2008 Financial Crisis (Sep–Nov 2008), COVID-19 Crash (Feb–Mar 2020), Black Monday 1987 (Oct 19, 22% single-day drop), Flash Crash 2010 (May 6, intraday liquidity collapse). Each returns survival score + projected P&L.
5
TailHedgingServicetail_hedge.pyADVISORY

Black-Scholes option pricing for 3 hedging strategies. Recommendations are advisory — reviewed by CIO or risk manager before any hedge order is placed. Does not directly veto or execute.

Strategies: Protective Put (long put at current strike), Put Spread (long ATM + short OTM put, lower cost), Collar (long put + short call, zero-cost, caps both downside and upside). Inputs: spot, IV from GARCH, risk-free rate from FMP API, DTE.
6
RedTeamAgentred_team.pyVETO-CAPABLE

Adversarial GPT-3.5-turbo call. Receives full AgentState and is explicitly instructed to find every reason the trade should NOT be taken. Returns veto=bool, kill_reason, risk_flags[].

System prompt: "You are a risk-averse adversarial analyst. Find all reasons this trade should NOT be taken. Be critical, skeptical, and thorough." If veto=True, red_team_veto flag is set in AgentState and graph routes to no_trade.
7
SanityGuardsanity_guard.pyVETO-CAPABLE

Hallucination detection and hard price reality check. If |LLM-referenced price − live price| / live price > 5%, immediate veto='price_hallucination'. Also validates order size vs. current market liquidity.

Checks: price deviation > 5% → unconditional veto. Order size > X% of average daily volume → illiquid veto. Structural hallucination check: non-existent tickers, contradictions with TimescaleDB records, extreme confidence claims inconsistent with signal uncertainty.

Kelly Criterion — Position Sizing

Formula

f* = (p·b − q) / b
p = estimated win probability
q = 1 − p
b = estimated win/loss ratio
production: f = f* / 2 (half-Kelly)

AllocationResult

approved: bool
position_size_pct: float
stop_loss: float # ATR-based
take_profit: float
kelly_fraction: float # raw
veto_reason: str # if rejected

Portfolio Optimizer — 4 Constraints

ConstraintLogic
Correlation checkReject if proposed trade correlation with any open position > 0.75 (avoids concentration)
Volatility targetingInverse volatility sizing — higher volatility means smaller position size
Sector limitsSectorValidatorOrchestrator enforces sector concentration limits
ATR-based stopsPosition sized so stop-loss distance ≈ risk budget. Stop price = ATR-derived.

StressTester — Historical Crisis Replays

ScenarioPeriodNature
2008 Financial CrisisSep–Nov 2008Calibrated equity crash path
COVID-19 CrashFeb–Mar 2020Sharp V-shape drawdown
Black Monday 198719 Oct 1987Single-day 22% crash
Flash Crash 20106 May 2010Intraday liquidity-driven spike/recovery
StressTester is advisory — output feeds the deal memo. It does not veto independently. A high ruined_rate from ChaosEngine can cause RedTeamAgent to veto.

Portfolio-Level Circuit Breakers

TriggerActionReset
Daily PnL drawdown > 5%Halt all new signal processingManual only — CIO/Risk Manager via API
3+ execution failures in 5 minutesHalt all new signal processingAuto-reset after cool-down period
Latency threshold exceededHalt all new signal processingAuto-reset
Manual commandHalt all new signal processingManual release only
When any breaker trips: open orders continue (fills proceed). New signal processing halts. Telegram alert fires immediately to Risk Manager. Open positions are NOT force-closed — only new entries are blocked.