01 — PIPELINE STAGE MAP
Nine stages, one pass per session
Stage 1 market_fetch.py → raw OHLCV per symbol (external)
Stage 2 london_premarket.py → sqrt_impact · OFI · VWAP · basis · FVG
Stage 3 qc_analyze.py → vol_acf · Markov · Wonham · Hurst · ADF
Stage 4 alpha_agent.py → FAN · OU · zscore · EMA/TSMOM · HJB
Stage 5 portfolio_optimizer.py → cvar_lp_solve_robust (Student's t)
Stage 6 risk_manager.py → kelly · ev_gate · gamma_scalp · parity
Stage 7 rithmic_execute.py → bracket orders via AMP/Rithmic (external)
Stage 8 pipeline_runner.py → orchestration
Stage 9 firebase_auth_state.py → sharpe · sortino · capm · VaR (NCC)
02 — DATA FLOW THROUGH THE CLUSTERS
From raw tape to the NCC report line
Raw market data
↓
microstructure ─┐
├─→ statistics.beta_update_bernoulli (π update)
mean_reversion ─┤ ↓
├─→ risk_sizing.ev_gate_check (Gate 5)
trend_following ┤ ↓
└─→ risk_sizing.kelly_uncertain (sizing)
↓
risk_sizing.cvar_lp_solve_robust (portfolio)
↓
foundations.parametric_var_normal (report)
↓
foundations.sharpe_ratio / capm_regression (NCC)
03 — THE 6-GATE EXECUTION SEQUENCE
Short-circuit order, every candidate entry
| Gate | Formula | Check |
| 1 | (time-based) | Wall clock in 07:00–08:30 PDT window |
| 2 | hill_estimator → calibrate_nu_from_hill | PBO ≥ 0.5 → 50% haircut |
| 3 | (composite scorer) | Confluence adjusted ≥ 6 |
| 4 | quality_estimator | QE minimum ≥ 0.50 |
| 5 | ev_gate_check | EV = π·R:R − (1−π) ≥ 0.25R |
| 6 | (age-based) | Position age 60/90 min cap |
04 — WONHAM + HJB SAR (DUAL WITH PARABOLIC SAR)
An earlier-firing exit trigger
Wonham + HJB is an earlier-firing SAR trigger that complements — does not replace — the incumbent Parabolic SAR. Both run in parallel; Wonham fires when P(bull) drops through π** even while price is still near the high, whereas Parabolic SAR fires only after price starts to retrace.
┌── Parabolic SAR flip → EXIT
Live tape ─→ qc_analyze ┤
└── wonham_step → π_t → sar_signal → EXIT
(fires earlier)
Promotion policy. Run Wonham in shadow mode for 10+ sessions, compare exit timing against Parabolic SAR, promote only if the early-exit hypothesis is confirmed empirically.
05 — THE 15-FACTOR CONFLUENCE MATRIX (F01–F15)
Every factor mapped to its implementation
| Factor | Package + function |
| F01 market state | qualitative |
| F02 CVD level | microstructure.order_flow_imbalance |
| F03 ORB breakout | mean_reversion.zscore |
| F04 AR(1) φ | trend_following.ts_momentum_regression |
| F05 Hurst H | trend_following.hurst_exponent |
| F06 playbook momentum | qualitative |
| F07 macro regime | qualitative |
| F08 TimesFM | external forecast |
| F09 pre-session action | microstructure.price_impact |
| F10 overnight gap | qualitative |
| F11 Claude confidence | external agent |
| F12 CVD slope | microstructure.order_flow_imbalance (Δ) |
| F13 drawdown guardrail | risk_sizing.cvar_lp_solve_robust |
| F14 Wyckoff AMD phase | trend_following.fit_transition_matrix |
| F15 iFVG CE precision | microstructure.detect_bull_fvg + consequent_encroachment |
06 — ACE POST-CLOSE LOOP (STAGE 9+)
The playbook updates itself overnight
16:00 PDT angelic_audit.py → 7-lens forensic review
ace_reflector.py → InsightBundle
ace_curator.py → delta_context_items.json
(updates playbook_current.json overnight)
Beta-Bernoulli π update:
prior = playbook.pi_beta_params
obs = today.wins, today.trades
posterior = beta_update_bernoulli(*prior, obs.wins, obs.trades)
playbook.pi_beta_params = posterior (auditable, single-line)
07 — EXTENSION POINTS
Where new formulas plug in cleanly
| Extension | Where to add | Notes |
| New confluence factor | microstructure/ or trend_following/ | Register with the composite scorer |
| Alternative scenario generator | risk_sizing/robust_cvar.py | Follow the generate_students_t_scenarios signature |
| Additional Greek | foundations/ | Analytical form preferred over numerical |
| New session regime | trend_following/markov.py | 3-state chain in production; can extend to 4-state |
| Chandelier stop | risk_sizing/ (new module) | Currently in commodity_orb.py — should be scaffolded |
| Parabolic SAR | trend_following/ (new module) | Currently referenced but not implemented |
08 — NON-GOALS
What this library does not do
- Connect to any broker or exchange — order routing (AMP/Rithmic bracket orders) lives entirely in the caller
- Store any market data
- Persist any state across function calls
- Depend on any live external services
All functions are pure. All state that matters lives in the caller. A math library, not a trading system.