Skip to content

Quantitative trading research framework for ES-SPY basis strategies. End-to-end backtester with persistent caching, market-neutral signal generation, and production-ready test suite (49+ tests, zero live dependencies).

Notifications You must be signed in to change notification settings

jgoyk/QuantTraderProject

Repository files navigation

QuantTraderProject β€” Documentation Index

Current Status: Phase 2 Complete βœ… | Phase 3 Planning πŸ“‹


Quick Navigation

πŸ“Š Latest Results

  • DEMO_EXECUTION_SUMMARY.md ← START HERE (visual summary)
  • DEMO_RESULTS_ANALYSIS.md (detailed results analysis)
  • analyze_demo.py (script to analyze results)

πŸ“– Project Documentation

  • AI_CONTEXT.md (technical specifications)
  • PROJECT_STATUS.md (current state + roadmap)
  • PHASE2_COMPLETION.md (Phase 2 detailed summary)

πŸ§ͺ Testing & Quality

  • tests/test_signal.py (14 signal tests)
  • tests/test_backtest.py (12 backtest tests)
  • tests/test_yahoo.py (8 new data pipeline tests)
  • All 34 tests passing βœ…

πŸ”§ Source Code

  • src/signal.py (V1 & V2 signal implementations)
  • src/backtest.py (deterministic backtest engine)
  • src/data.py (data loading & alignment)
  • src/main.py (walk-forward evaluation)
  • src/yahoo.py (NEW: Yahoo Finance fetching + caching)
  • src/plotting.py (equity curve visualization)

πŸ“œ Scripts

  • scripts/fetch_yahoo_data.py (NEW: fetch data from Yahoo Finance)
  • scripts/demo_latest.py (NEW: end-to-end demo)
  • analyze_demo.py (NEW: results analyzer)

πŸ“ Data & Results

  • data/es_prices.csv (ES daily prices)
  • data/spy_prices.csv (SPY daily prices)
  • data/cache/ (cached Yahoo Finance data)
  • results/best_params_v2.csv (V2 best parameters)
  • results/test_equity_curve_v2.csv (V2 test equity)
  • results/test_summary_v2.csv (V2 test metrics)
  • Plus V1 equivalents

Phase Summary

Phase 1: Backtest Engine βœ…

What: Deterministic backtesting with proper accounting
Files: src/signal.py, src/backtest.py, src/main.py
Tests: 26 passing
Status: Production ready

Phase 2: Data Pipeline βœ…

What: Yahoo Finance integration + demo script
Files: src/yahoo.py, scripts/fetch_yahoo_data.py, scripts/demo_latest.py
Tests: 8 new tests, all passing
Status: Production ready

Phase 3: Extended History πŸ“‹

What: Multi-year regime analysis
Command: python scripts/demo_latest.py --lookback 1095 --signal v2
Status: Ready to execute


Key Results

V2 Signal Beats V1

Metric V1 V2 Winner
Test Sharpe 0.402 0.558 V2 +38.9%
Test Return 0.37% 0.49% V2 +33.9%

Backtesting Details

  • Data: 253 trading days (Jan 1 – Dec 31, 2024)
  • Train/Test: 60% / 40% split
  • Parameters tested: 125 combinations
  • Best V2 params: Window=30, Entry=1.0, Exit=1.0

How to Use This Project

Run Demo Analysis (No Internet Required)

python analyze_demo.py

Fetch Fresh Data (Requires Internet)

python scripts/fetch_yahoo_data.py --lookback 365

Run End-to-End Demo

python scripts/demo_latest.py --lookback 365 --signal v2

Run All Tests

pytest tests/ -v

Extended History Analysis

python scripts/demo_latest.py --lookback 1095 --signal v2 --no-plot

Repository Structure

QuantTraderProject/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ signal.py              (V1 & V2 signals)
β”‚   β”œβ”€β”€ backtest.py            (deterministic backtest)
β”‚   β”œβ”€β”€ data.py                (load & align data)
β”‚   β”œβ”€β”€ main.py                (walk-forward evaluation)
β”‚   β”œβ”€β”€ yahoo.py               (NEW: Yahoo Finance API)
β”‚   └── plotting.py            (equity visualization)
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ fetch_yahoo_data.py    (NEW: fetch tool)
β”‚   └── demo_latest.py         (NEW: demo script)
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ test_signal.py         (14 tests)
β”‚   β”œβ”€β”€ test_backtest.py       (12 tests)
β”‚   β”œβ”€β”€ test_yahoo.py          (NEW: 8 tests)
β”‚   └── fixtures/
β”‚       └── yahoo_sample.json  (NEW: test data)
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ es_prices.csv          (ES prices)
β”‚   β”œβ”€β”€ spy_prices.csv         (SPY prices)
β”‚   └── cache/                 (Yahoo Finance cache)
β”œβ”€β”€ results/
β”‚   β”œβ”€β”€ best_params_v2.csv     (V2 best params)
β”‚   β”œβ”€β”€ test_summary_v2.csv    (V2 test metrics)
β”‚   β”œβ”€β”€ test_equity_curve_v2.csv (V2 equity)
β”‚   └── ... (V1 equivalents)
β”œβ”€β”€ AI_CONTEXT.md              (tech specs)
β”œβ”€β”€ PROJECT_STATUS.md          (status + roadmap)
β”œβ”€β”€ PHASE2_COMPLETION.md       (detailed summary)
β”œβ”€β”€ DEMO_RESULTS_ANALYSIS.md   (results analysis)
β”œβ”€β”€ DEMO_EXECUTION_SUMMARY.md  (execution report)
└── analyze_demo.py            (results analyzer)

Implementation Checklist

Core Systems

  • Signal generation (V1 & V2)
  • Deterministic backtest engine
  • Walk-forward evaluation
  • Parameter sweep (125 combinations)
  • Yahoo Finance integration
  • Deterministic caching
  • Data alignment

Quality Assurance

  • 34 unit tests (100% passing)
  • No lookahead bias
  • No hardcoded paths
  • No breaking changes
  • Offline test coverage

Documentation

  • Technical specifications (AI_CONTEXT.md)
  • Project status (PROJECT_STATUS.md)
  • Phase 2 summary (PHASE2_COMPLETION.md)
  • Results analysis (DEMO_RESULTS_ANALYSIS.md)
  • Execution report (DEMO_EXECUTION_SUMMARY.md)

Deliverables

  • Phase 1 backtest engine
  • Phase 2 data pipeline
  • Production-ready code
  • Full test coverage
  • Reproducible results

Next Actions

Immediate (Execute Now)

  1. Review DEMO_EXECUTION_SUMMARY.md
  2. Run python analyze_demo.py to verify results
  3. Read DEMO_RESULTS_ANALYSIS.md for deep insights

Short Term (Next Sprint)

  1. Execute Phase 3: python scripts/demo_latest.py --lookback 1095
  2. Analyze performance across market regimes
  3. Document any regime-dependent behavior

Medium Term

  1. Intraday extension (hourly bars)
  2. Advanced risk management (dynamic stops)
  3. Parameter sensitivity analysis

Long Term

  1. Live trading integration
  2. Real-time monitoring
  3. Portfolio optimization

Support & Questions

All information is contained in:

  1. DEMO_EXECUTION_SUMMARY.md β€” Start here for overview
  2. AI_CONTEXT.md β€” Technical details
  3. PROJECT_STATUS.md β€” Current state + roadmap
  4. Code comments β€” Minimal but present

To Run Any Analysis:

# View results
python analyze_demo.py

# Run tests
pytest tests/ -v

# View status
cat PROJECT_STATUS.md | head -100

Version Info

  • Phase: 2 Complete βœ…
  • Last Updated: January 10, 2026
  • Python: 3.13+
  • Key Libraries: pandas, numpy, pytest, matplotlib

Status: 🟒 PRODUCTION READY

See DEMO_EXECUTION_SUMMARY.md for the latest results!

About

Quantitative trading research framework for ES-SPY basis strategies. End-to-end backtester with persistent caching, market-neutral signal generation, and production-ready test suite (49+ tests, zero live dependencies).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages