Python Reference¶
Python components for backtesting, ML training, and strategy validation.
Components¶
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 |