Phase 0 — State of the System
Audit date: 2026-05-17
Repo: QGTMAI/trading @ main (857f05ef as of audit run)
Operators: user + Naz
Mandate: Code-verified ground truth — README claims are not evidence.
Executive summary
The platform is a mature paper-trading stack (Alpaca paper, DigitalOcean droplet, self-hosted CI/deploy) with 52 PM strategies registered in the live daemon, 3–4 intraday sleeves, and ~4,044 automated tests. Institutional validation infrastructure exists in qgtm_backtest (PBO, DSR, walk-forward) but checked-in backtest artifacts cover only mvg_v1 — GAP-002 remains open in practice.
Production vs main: Prior session noted API deploy pinned/rolled back to 9d9fa79d. Commits after that on main include drawdown peak-reset (1f0964b8), deploy health probes, and CI fast path — verify droplet git rev-parse HEAD before trusting runtime behavior.
Default capital mode: qgtm_live_trading_enabled=False, alpaca_base_url=https://paper-api.alpaca.markets → PAPER, not live.
A. Repository inventory
Packages (production-reachable)
| Package | .py files |
Role | Production entry |
|---|---|---|---|
qgtm_live |
7 | Daemon, scheduler, reconciliation, watchdog | systemd qgtm-daemon, TradingDaemon |
qgtm_api |
19 | FastAPI, metrics, operator UI backend | systemd qgtm-api, uvicorn :8000 |
qgtm_execution |
9 | OMS, Alpaca broker, TCA, VWAP/TWAP | Daemon → OMS |
qgtm_risk |
11 | Kill-switch, compliance, VaR/EVT (mostly telemetry) | Daemon pre-trade |
qgtm_portfolio |
8 | Signal aggregation, drawdown, IC tracker | Daemon rebalance |
qgtm_strategies |
69 | Signal generators | Daemon registry |
qgtm_data |
28 | Alpaca, FRED, COT, ETF flows, AISC | Daemon feature build |
qgtm_features |
3 | Feature store | Daemon |
qgtm_core |
18 | Config, types, audit log, calendar | All |
qgtm_backtest |
6 | Validation harness | scripts/backtest_*.py, CI workflow |
qgtm_bot |
5 | Telegram, gold brief | Cron + daemon callbacks |
qgtm_web |
2 (+ Next app) | Operator dashboard | Cloudflare Pages qgtm-trading |
qgtm_altdata |
6 | News/sentiment (thin usage) | Partial daemon enrich |
qgtm_integrations |
6 | Notion, etc. | Side workflows |
qgtm_signals |
2 | Legacy/small | Low |
scripts/dead_ml_loop/ |
moved | Self-learning not imported by daemon | DEAD |
Scale: ~1,561 Python files tracked (excl. .venv); ~576k LOC total per wc (includes tests, scripts, dead_ml_loop).
Test coverage (honest)
| Metric | Value | Source |
|---|---|---|
| Tests collected | 4,044 | pytest --collect-only |
| Test modules | 150 | tests/test_*.py |
| Claimed coverage (gap ledger) | ~90% (Apr 2026) | verification/gap_ledger.md — re-run make coverage to refresh |
| Strategy backtest golden dir | 1 strategy (mvg_v1/) |
backtest_results/ |
Coverage is strong on plumbing (risk drills, reconciliation, compliance wiring) and weak on economic proof (most strategies lack checked-in OOS artifacts).
90-day git heatmap (approximate)
Heavy activity 2026-04-12 → 2026-05-17: deploy hardening, site operator pages, quarantine/compliance, TCA wiring, Redis persistence, dead workflow deletion, Tier-0 audit fixes (#82), dead ML relocation (#81).
Top themes (30 commits sampled): site truthfulness, risk/compliance, deploy/CI, gold strategy expansion, observability.
Production-reachable entry points
| Entry | Path | Notes |
|---|---|---|
| Trading loop | qgtm_live/daemon.py → main() |
SIGTERM handler present (L4183+) |
| API | qgtm_api/main.py |
Health /health, telemetry /api/v1/daemon/telemetry |
| Deploy | .github/workflows/deploy-api-self-hosted.yml |
workflow_run CI gate on success |
| Watchdog | qgtm_live/watchdog.py |
Same host; DMS 300s default |
| Backtest batch | scripts/backtest_all.py |
Registry still lists 29 names — stale vs 52 PM |
B. Strategy ledger (76 strategy_id values in code)
Status key: LIVE = wired in daemon and not quarantined; PAPER = same (platform default is paper); RESEARCH = implemented but not in daemon registry; DEAD = quarantined, moved to dead_ml_loop, or explicit stub.
B1. PM daemon registry (PM_STRATEGY_CATEGORIES) — 52 strategies
| strategy_id | Category | Status | Last code touch | Claimed Sharpe | OOS / artifact | Capacity | Kill? |
|---|---|---|---|---|---|---|---|
| real_rate_gold | macro | PAPER | active | — | No artifact | High (GLD) | No |
| gold_real_rate_residual | macro | PAPER | active | — | No | High | No |
| gold_druckenmiller_delta | macro | PAPER | active | — | No | High | No |
| gold_yield_curve_steepener | macro | PAPER | active | — | No | Med | No |
| gold_geopolitical_risk | macro | PAPER | active | — | No | Med | No |
| dxy_gold | macro | PAPER | active | — | No | High | No |
| breakeven_inflation_gold | macro | PAPER | active | — | No | High | No |
| central_bank_gold | macro | PAPER | active | — | No | Low (slow data) | No |
| vix_haven | macro | PAPER | active | — | No | Med | Merge w/ gold_vix? |
| gold_vix_haven | macro | PAPER | active | — | No | Med | Overlap vix_haven |
| gold_bitcoin_regime | macro | PAPER | active | — | No | Med | No |
| tsmom | momentum | PAPER | active | — | No | High | No |
| xsmom | momentum | PAPER | active | — | No | High | No |
| overnight_gold | momentum | DEAD (quarantine) | quarantine | neg OOS | constants | Med | Yes |
| carver_trend | momentum | PAPER | active | — | No | High | No |
| carver_carry | momentum | PAPER | active | — | No | Low (needs curve) | Data-blocked often |
| gold_tsmom | momentum | PAPER | active | — | No | High | Corr w/ tsmom |
| gold_day_of_week | momentum | PAPER | active | — | No | High | No |
| gold_multi_ma_trend | momentum | PAPER | active | — | No | High | Corr cluster |
| gold_silver_ratio | MR | DEAD (quarantine) | quarantine | Sharpe -0.46 | PBO 0.88 in constants | Med | Revive or delete |
| miners_vs_metal | MR | DEAD (quarantine) | quarantine | neg | PBO 0.63 | Med | Freeze |
| kalman_pairs | MR | PAPER | active | — | No | High | No |
| gold_platinum | MR | DEAD (quarantine) | quarantine | Sharpe -1.57 | PBO 1.0 | Med | Delete |
| pairs_mr | MR | PAPER | active | — | No | High | No |
| gold_royalty_divergence | MR | PAPER | active | — | No | Med | No |
| gold_miner_aisc_margin | MR | PAPER | active | — | No | Med | AISC stale risk |
| gold_phys_premium | MR | PAPER | active | — | No | Med | No |
| etf_flow_pm | flow | PAPER | active | — | No | Med | Data quality |
| cot_precious | flow | PAPER | active | — | No | Med | Overlap hedging_pressure |
| sge_withdrawals | flow | PAPER | active | — | No | Low | Data-blocked often |
| hedging_pressure | flow | PAPER | active | — | No | Med | Inverse cot? |
| gold_etf_flow | flow | DEAD (quarantine) | broken feed | — | Tier 0.6 | Med | Yes |
| gold_mint_sales | flow | PAPER | active | — | No | Low | No |
| gold_sge_premium | flow | PAPER | active | — | No | Low | No |
| gold_comex_squeeze | flow | PAPER | active | — | No | Med | No |
| silver_comex_squeeze | flow | PAPER | active | — | No | Med | No |
| gold_lbma_fix_anomaly | flow | PAPER | active | — | No | Med | No |
| vol_risk_parity | vol | PAPER | active | — | No | High | No |
| vol_risk_premium_pm | vol | PAPER | active | — | No | Med | IV data gaps |
| vol_term_structure_pm | vol | PAPER | active | — | No | Med | Proxy not options |
| gamma_scalp_pm | vol | PAPER | active | — | No | Med | ETF proxy |
| skew_trades | vol | PAPER | active | — | No | Med | Proxy |
| tail_hedge_pm | vol | PAPER | active | — | No | Med | Carry cost |
| gold_options_skew | vol | PAPER | active | — | No | Med | Proxy |
| gold_vol_term_structure | vol | PAPER | active | — | No | Med | No |
| seasonality_pm | seasonal | DEAD (quarantine) | quarantine | Sharpe -1.74 | PBO 1.0 | Med | Delete |
| levered_etf_decay | seasonal | PAPER | active | — | No | Med | No |
| event_drift_pm | seasonal | PAPER | active | — | No | Low | Calendar data |
| gold_seasonal_demand | seasonal | PAPER | active | — | No | Med | CNY table maintenance |
| gc_term_structure | carry | PAPER | active | — | No | Low | Futures feed |
| cross_carry | carry | PAPER | active | — | No | Low | Futures feed |
| backwardation_stress | carry | PAPER | active | — | No | Low | Futures feed |
Active PM (non-quarantined): 46 strategies.
B2. Intraday daemon list (_intraday_strategies) — not in PM registry
| strategy_id | Status | Notes |
|---|---|---|
| gold_silver_ratio_intraday | PAPER | 15m pairs; compliance wired (2026-05) |
| vwap_reversion_intraday | PAPER | 5m VWAP fade |
| gold_gamma_scalp | PAPER | Reuses GoldGammaScalpStrategy (also in PM vol bucket) |
| mvg_v1 | DEAD default | QUARANTINED + QGTM_ENABLE_MVG=false; artifact Sharpe -1.34 |
B3. Implemented but not in daemon PM registry (RESEARCH / DEAD)
| strategy_id | Status | Rationale |
|---|---|---|
| comex_warehouse | RESEARCH | Not in PM_STRATEGY_CATEGORIES |
| cot_positioning | RESEARCH | Superseded by cot_precious? |
| inventory_surprise | RESEARCH | EIA — unwired |
| regime_classifier_pm | RESEARCH | Critical: regime detector used, classifier sleeve unwired |
| ml_ensemble | RESEARCH | Not in daemon |
| meta_labeller_pm | RESEARCH | Not in daemon |
| si_term_structure | RESEARCH | Silver curve — unwired |
| fix_dislocation | RESEARCH | Unwired |
| precious_metals / gold_macro_regime | RESEARCH | Legacy composite in precious_metals.py |
| gold_seasonality, gold_momentum_mr, silver_industrial, miners_leverage | RESEARCH | Legacy classes |
| covered_call_writer, cash_secured_put, vrp_harvester, gold_collar, silver_ratio_spread, event_straddle | RESEARCH | options_strategies.py — not routed to OMS |
| ml_ensemble | RESEARCH | — |
B4. scripts/dead_ml_loop/ — DEAD (production)
Modules: auto_retrain, model_registry, self_learning — 34+ tests, zero daemon imports (relocated #81).
C. Data dependencies
| Vendor / source | Used for | License / cost | Cadence | Latency | Gaps / PIT |
|---|---|---|---|---|---|
| Alpaca | Bars, orders, positions | Broker ToS | 1m–1d | Low | Paper vs live URL |
| FRED | Rates, breakevens, DXY proxies | Free API key | Daily | 1d | Revision risk |
| CFTC COT | Positioning | Public | Weekly | 3d lag per constants | PIT: report lag modeled |
| Yahoo (yfinance) | ETF vol proxy, some flows | ToS gray | Daily | Variable | gold_etf_flow used volume not SO (quarantined) |
| AISC JSON | Miner margins | Internal file | Quarterly | ~80d stale risk (Feb 2026 file) | Manual update |
| Redis | IC, perf, dedup | Self-hosted | Real-time | ms | AOF enabled (#78) |
| DO Spaces | Audit backup | Paid | On write | — | Optional |
| Databento / Polygon | Keys in config | Paid | — | — | Not verified wired in hot path |
| LBMA / COMEX / SGE | Various gold sleeves | Mixed | — | — | Several strategies data-blocked (Apr 2026 report) |
PIT correctness: Backtest harness supports embargo (WALK_FORWARD_DEFAULT_EMBARGO=21); live feature merge must respect COT lag — verify per-strategy in qgtm_strategies/* (not globally enforced in one module).
D. Infrastructure
| Component | Implementation |
|---|---|
| Broker | Alpaca (paper default) |
| Cloud | DigitalOcean droplet 142.93.1.195, /opt/trading |
| Edge | Cloudflare Pages (web), API proxied |
| Secrets | .env on droplet (600), GitHub Actions secrets injection |
| CI/CD | Self-hosted runner label qgtm-do; deploy-api-self-hosted.yml + deploy.yml (web) |
| DR | Merkle audit chain + DO Spaces; no warm standby; K8s scripts exist but not prod |
| M5 Max / ThinkPad | Dev machines — not in trading path |
| Laptop closed 9:31 ET | Daemon on droplet — local laptop irrelevant for loop; risk: no operator UI if only local |
Rollback: Deploy captures PREV_COMMIT; health/deep-health extended in recent commits. Confirm daemon restarted on same SHA as API.
E. Honest scoreboard
| Metric | Status |
|---|---|
| Live P&L | N/A — qgtm_live_trading_enabled=False, paper URL |
| Paper P&L | Available via Alpaca + site /pnl (wired #75) — not fetched in this audit |
| Realization ratio | Unknown without broker export |
| Paper readiness gap | Validation gap >> engineering gap — need full backtest_all.py artifacts + promotion policy |
| Signals firing (historical) | Apr 2026: 5/26 active in one rebalance (data wiring) — improved since but not re-measured here |
| GAP-002 backtests | IN PROGRESS / stale — only mvg_v1 in repo |