Self-learning quant trading system - CFA-level market research, prediction tracking, paper trading
  • Python 93.6%
  • Shell 6%
  • HTML 0.3%
Find a file
pookNast 01c107db07 fix(snapshot): keep-last-good chain on sparse pre-market fetches
06:25 ET pre-market Yahoo returns mostly zero-bid strikes (23 usable quotes
on 2026-10-14 vs 3,034 during RTH), silently degrading the whole book to
BS marks. Sparse fetches (<200 two-sided quotes) now reuse the previous
chain block, marked stale=true; spy/vix always refresh.
2026-10-14 11:17:06 -04:00
.claude/data/sessions feat: initial PRD, audits, and swarm launcher infrastructure 2026-05-23 10:51:29 -04:00
agent ti: T1+T3+T5 paper-fidelity wave — real chain quotes, equity observability, calibration 2026-10-13 13:39:24 -04:00
alembic fix(agent+data): W1-00 partial_fill clobber + missing-symbol files; W1-01/03 ingest+schema 2026-06-18 07:22:28 -04:00
audits feat(GAP-fix): LIVE_CONFIRM gate + hmmlearn dep; SHIP verdict 25/25 2026-06-19 14:15:37 -04:00
backtest feat(portfolio): VIX-weighted multi-strategy ensemble — PMCC + long-vol + cash 2026-06-19 20:19:48 -04:00
briefs Initial commit: Trading Intelligence System 2026-01-30 19:52:15 -05:00
broker fix(gap-09): cold-audit iter-1 — token alignment, gate polarity, broker defense-in-depth 2026-06-19 17:21:00 -04:00
config fix(gap-09): cold-audit iter-1 — token alignment, gate polarity, broker defense-in-depth 2026-06-19 17:21:00 -04:00
dashboard feat(cron): weekly calibration report (Friday 06:45 ET) 2026-10-13 17:41:51 -04:00
data fix(quotes): ChainQuoteBook refuses dte extrapolation beyond 45d 2026-10-13 17:40:32 -04:00
deploy feat(W5): broker + observability + deploy + RUNBOOK; mark W5 passes:true 2026-06-19 13:23:29 -04:00
desks Initial commit: Trading Intelligence System 2026-01-30 19:52:15 -05:00
docs feat(W5): broker + observability + deploy + RUNBOOK; mark W5 passes:true 2026-06-19 13:23:29 -04:00
journal feat: SPX Rolling Call Options Trading Intelligence — full codebase 2026-05-23 10:51:55 -04:00
launchers fix(rlm): canonical PRD + scaffolding passes mega-chief preflight 2026-06-10 11:29:25 -04:00
logs feat(backtest): remediate stress-regime robustness — long-leg regime flatten 2026-06-19 18:20:14 -04:00
monitoring feat: SPX Rolling Call Options Trading Intelligence — full codebase 2026-05-23 10:51:55 -04:00
observability feat(W5): broker + observability + deploy + RUNBOOK; mark W5 passes:true 2026-06-19 13:23:29 -04:00
options ti: T1+T3+T5 paper-fidelity wave — real chain quotes, equity observability, calibration 2026-10-13 13:39:24 -04:00
prd feat: initial PRD, audits, and swarm launcher infrastructure 2026-05-23 10:51:29 -04:00
prompts fix(rlm): canonical PRD + scaffolding passes mega-chief preflight 2026-06-10 11:29:25 -04:00
prompts-money-path feat(structure): add test package __init__.py files 2026-06-09 22:15:00 -04:00
regime feat(W3): regime + risk modules; mark W3 passes:true (hand-verified) 2026-06-19 10:15:17 -04:00
research feat: SPX Rolling Call Options Trading Intelligence — full codebase 2026-05-23 10:51:55 -04:00
risk chore(lint+state): finish ruff fixes (conftest, risk_manager) + record W4-01 pass 2026-06-19 12:59:38 -04:00
scripts fix(snapshot): keep-last-good chain on sparse pre-market fetches 2026-10-14 11:17:06 -04:00
ship/sp-call-options feat(backtest): remediate stress-regime robustness — long-leg regime flatten 2026-06-19 18:20:14 -04:00
strategies ti: T1+T3+T5 paper-fidelity wave — real chain quotes, equity observability, calibration 2026-10-13 13:39:24 -04:00
swarm feat: Olympus cherry-pick complete — 14 features ported, 183 tests, remediated 2026-05-24 14:51:57 -04:00
tests fix(quotes): ChainQuoteBook refuses dte extrapolation beyond 45d 2026-10-13 17:40:32 -04:00
.env.sample fix(gap-09): cold-audit iter-1 — token alignment, gate polarity, broker defense-in-depth 2026-06-19 17:21:00 -04:00
.gitignore feat(execution): ship broker path + faithful tuned PMCC config 2026-06-20 07:39:26 -04:00
alembic.ini feat: SPX Rolling Call Options Trading Intelligence — full codebase 2026-05-23 10:51:55 -04:00
ARCHITECTURE.md Initial commit: Trading Intelligence System 2026-01-30 19:52:15 -05:00
BRIEF_TEMPLATE.md Final brief template - comprehensive data + tin foil analysis 2026-01-30 20:07:15 -05:00
conftest.py chore(lint+state): finish ruff fixes (conftest, risk_manager) + record W4-01 pass 2026-06-19 12:59:38 -04:00
DATA_SOURCES.md Initial commit: Trading Intelligence System 2026-01-30 19:52:15 -05:00
docker-compose.trading.yml feat(dashboard): trading monitor (FastAPI+Jinja) + dockerized VPS deploy 2026-06-30 21:40:10 -04:00
docker-compose.yml feat(W5): broker + observability + deploy + RUNBOOK; mark W5 passes:true 2026-06-19 13:23:29 -04:00
Dockerfile fix(gap-09): cold-audit iter-1 — token alignment, gate polarity, broker defense-in-depth 2026-06-19 17:21:00 -04:00
PAPER-FIDELITY-FIXES-2026-10-13.md ti: T1+T3+T5 paper-fidelity wave — real chain quotes, equity observability, calibration 2026-10-13 13:39:24 -04:00
prd-money-path.json fix(rlm): canonical PRD + scaffolding passes mega-chief preflight 2026-06-10 11:29:25 -04:00
prd.json feat: initial PRD, audits, and swarm launcher infrastructure 2026-05-23 10:51:29 -04:00
pyproject.toml fix(dashboard): add pydantic-settings dep + copy requirements.txt before pip install 2026-06-30 21:56:32 -04:00
README.md ti: T1+T3+T5 paper-fidelity wave — real chain quotes, equity observability, calibration 2026-10-13 13:39:24 -04:00
trading.db.bak fix(W3): ruff build-gate + vix_ensemble API contract 2026-06-19 11:00:48 -04:00
trading.db.test_backup fix(W3): ruff build-gate + vix_ensemble API contract 2026-06-19 11:00:48 -04:00
TRADING_SYSTEM.md Add canonical brief template - comprehensive data + CFA synthesis 2026-01-30 19:59:22 -05:00
uv.lock chore: refresh uv.lock for hmmlearn dep; drop spent watchdog.alert 2026-06-19 15:11:51 -04:00
WORKFLOW.md Initial commit: Trading Intelligence System 2026-01-30 19:52:15 -05:00

Trading Intelligence (trading-intelligence)

Self-learning quant trading system with CFA-level research.

Overview

Quantitative trading system that combines CFA-level fundamental analysis with technical indicators. Features prediction tracking, paper trading, performance scoring, and adaptive learning from historical outcomes.

Stack

  • Python

Quick Start

# Clone
git clone ssh://git@192.168.183.110:2222/pook/trading-intelligence.git
cd trading-intelligence

Backtesting

Install dependencies

cd trading-intelligence
uv venv .venv
uv pip install --python .venv/bin/python yfinance

Load historical data

.venv/bin/python scripts/backtest_data.py

Downloads 5 years of daily OHLCV for 27 tickers (equities, crypto, metals, indices) into trading_intelligence.db.

Run backtests

# Single strategy
.venv/bin/python scripts/backtest_engine.py --strategy momentum --start 2023-01-01 --end 2025-12-31
.venv/bin/python scripts/backtest_engine.py --strategy mean_reversion --start 2023-01-01 --end 2025-12-31
.venv/bin/python scripts/backtest_engine.py --strategy macd --start 2023-01-01 --end 2025-12-31
.venv/bin/python scripts/backtest_engine.py --strategy random --start 2023-01-01 --end 2025-12-31

# Compare all strategies
.venv/bin/python scripts/backtest_engine.py --compare all --start 2023-01-01

# Options: --tickers SPY BTC-USD --commission 0.001 --capital 100000 --max-positions 10 --json --no-store

Available strategies

Strategy Description
momentum Top-N momentum with lookback window
mean_reversion RSI-based mean reversion (oversold/overbought)
macd MACD histogram crossover
random Random baseline (statistical control)

Status

In Development

License

Private — All rights reserved

Dry Run Usage

# Quick 2-year run (downloads data from yfinance):
python dry_run.py --start 2024-07-01

# 5-year backtest:
python dry_run.py --start 2021-06-01 --end 2026-06-30

# Today's signals only:
python dry_run.py --today

# Use existing database instead of download:
python dry_run.py --start 2024-01-01 --use-db

# Custom capital:
python dry_run.py --start 2024-01-01 --capital 50000

Output goes to dry_run_output/:

  • trades.csv — every fill with strategy, side, strike, DTE, price, P&L
  • equity_curve.csv — daily mark-to-market equity, cash, position value, and portfolio Greeks (net_delta, net_gamma, net_theta, net_vega)
  • state.json — resumption state

Key Metrics (5-year backtest, 2021-06 to 2026-06, hardened config)

Metric Strategy SPY Buy&Hold
Total Return +67.6% +84.8%
Max Drawdown -11.3% -22.1%
Alpha vs SPY -17.2% —

After the risk-hardening milestones (M1–M5) the strategy runs roughly flat to SPY on absolute return while cutting peak drawdown ~49% (11.3% vs 22.1%). Raw return trails buy-and-hold in this bull sample; the edge is risk-adjusted, not absolute. (The original pre-hardening baseline was -13.5% MaxDD.)

Risk Controls (hardening milestones)

  • M1 — IV-rank entry gate: sell-premium entries require IV percentile ≥ 0.40 (LEAPS buys ≤ 0.60); data/iv_rank.py.
  • M2 — P&L roll triggers: take profit / cut the short leg by premium P&L, not just DTE; checked before the DTE roll gate.
  • M3 — Portfolio drawdown kill switch: flatten all + cooldown at 10% drawdown; risk/portfolio_guard.py.
  • M4 — Greeks + delta-aware allocation: per-position/portfolio delta/gamma/theta/vega (risk/greeks.py); new entries blocked when net portfolio delta exceeds max_net_delta (default 2.0 = 200 shares); strategies/allocation.py.
  • M5 — Fast regime override: VIX-spike / SPY-gap floors the regime ahead of the slow classifier (regime/fast_override.py).

Not live-tradeable. Fills use Black-Scholes pricing with a VIX-derived IV proxy — real bid/ask spread, vol skew and liquidity are absent. A real options data feed (IBKR / Polygon / Tradier) is required before deploying capital.

Adding a New Strategy

  1. Create strategies/my_strategy.py inheriting from Strategy base class
  2. Implement generate_signal(ctx: MarketContext) -> Signal
  3. Register in dry_run.py → self.strategies list
  4. Defined-risk validation enforced automatically via _validate_risk()