ml-strategy
Installation
SKILL.md
Machine-Learning Predictive Strategy
Purpose
Use sklearn machine-learning models (RandomForest / GradientBoosting / Ridge) to predict the direction of future returns and generate trading signals. Walk-forward training is used to avoid future data leakage, and feature engineering extracts useful factors from OHLCV data.
Signal Logic
- Validate input: check OHLCV columns, minimum row count, NaN ratio — skip symbols that fail
- Feature engineering: build multi-dimensional factors from raw OHLCV data (momentum, volatility, RSI, moving-average ratios, volume ratio, and more). All features are sanitized (inf removed, division-by-zero guarded)
- Label construction: future N-day return > 0 is the positive class (
1), < 0 is the negative class (0) - Walk-forward training: use an expanding or sliding window, train on historical data only, and roll forward day by day for prediction
- Signal generation: map
predict_proba[:, 1]to[-1.0, 1.0], or use discrete signals frompredictin{-1, 0, 1}. Output is guaranteed clean (no NaN, clipped to range)
Complete SignalEngine Example
This is the recommended full pipeline. Copy and customise — safety is built in.