Skip to content

Python Reference

Python components for backtesting, ML training, and strategy validation.

Components

  • Backtesting


    Event-driven backtest engine with anti-bias validation

    Guide

  • ML Training


    Train models to predict setup quality

    Guide

  • API Reference


    Module documentation and examples

    API

Project Structure

src/
├── core/                 # Pattern detection
│   ├── data_loader.py   # Data ingestion
│   ├── swing_detector.py # Pivot detection
│   └── pattern_detector.py # QM patterns
├── edge/                 # Edge evaluation
│   ├── quality_scorer.py # Confluence scoring
│   ├── time_filter.py    # Session filtering
│   └── edge_stack.py     # Multi-edge weighting
├── backtest/             # Simulation
│   ├── engine.py        # Main loop
│   ├── position.py      # Trade tracking
│   └── metrics.py       # Performance calc
└── ml/                   # Machine learning
    ├── features.py      # Feature engineering
    ├── model.py         # Model wrapper
    └── trainer.py       # Training pipeline

Quick Start

# Run backtest
python scripts/run_backtest.py --symbol MNQ --timeframe 4h

# Train model
python scripts/train_edge_model.py --symbol MNQ --timeframe 4h

Skills

Skill Purpose
/backtest Run backtest with validation
/train-model Train ML models
/pine-to-python Convert Pine for parity testing