|
Download README.md from AcyLa/forex-predictive-model: direct link, hf CLI and curl.
- Browser
- Download file 6.27 kB
-
https://huggingface.co/AcyLa/forex-predictive-model/resolve/main/README.md
- Command line
-
hf download hf://AcyLa/forex-predictive-model/README.md
-
curl -L -o README.md https://huggingface.co/AcyLa/forex-predictive-model/resolve/main/README.md
6.27 kB
| tags: | |
| - ml-intern | |
| # π¦ Forex Predictive Model β ML Ensemble with Nadaraya-Watson + Bollinger | |
| A production-grade machine learning pipeline for **intraday forex price prediction** using Nadaraya-Watson envelope estimation, multi-window Bollinger Bands, and 180+ technical indicators. Outputs **BUY / SELL / NEUTRAL** signals with pip-based price targets. | |
| ## π Quick Start | |
| ```bash | |
| pip install yfinance pandas numpy scikit-learn lightgbm ta torch pyarrow joblib scipy | |
| git clone https://huggingface.co/AcyLa/forex-predictive-model | |
| cd forex-predictive-model | |
| # Get predictions immediately (pre-trained models included) | |
| python predict.py --ticker EURUSD=X | |
| # Fast mode (LightGBM only, sub-ms) | |
| python predict.py --ticker EURUSD=X --no-lstm | |
| # Single horizon | |
| python predict.py --ticker EURUSD=X --horizon 8 --features | |
| ``` | |
| ## π Architecture | |
| ``` | |
| Yahoo Finance FX Data β 180+ Features β Multi-Horizon Labels β LightGBM + LSTM Ensemble β BUY/SELL/NEUTRAL | |
| β β β | |
| 730 days 1h bars Nadaraya-Watson Pip-based targets | |
| Bollinger (3 windows) Consensus voting | |
| RSI, MACD, ADX, Ichimoku | |
| Stochastic, ATR, Donchian | |
| Session timing (London/NY/Tokyo) | |
| ``` | |
| ## π Key Components | |
| ### Nadaraya-Watson Envelope (12 features) | |
| Non-parametric kernel regression that smooths price to identify trend + overbought/oversold zones. Vectorized implementation computes 17k bars in 0.3s. | |
| ### Bollinger Bands System (45 features) | |
| - 3 windows (20, 50, 100) Γ 3 std devs (2.0, 2.5, 3.0) | |
| - Bandwidth, %B position, squeeze detection, band-walk signals | |
| ### All Best Indicators (180+ total) | |
| | Category | Indicators | | |
| |----------|-----------| | |
| | **Trend** | EMA stack (9/21/50/100/200), SMA, MACD, ADX, Ichimoku Cloud, CCI | | |
| | **Momentum** | RSI (7/14/21), Stochastic, Williams %R, ROC, Awesome Oscillator | | |
| | **Volatility** | ATR (14/21/50), Bollinger, Keltner, Donchian, Historical Vol | | |
| | **Volume** | OBV, MFI, VWAP, CMF, Volume ratios | | |
| | **Price** | Multi-horizon returns, candlestick, support/resistance, drawdown | | |
| | **Session** | Tokyo/London/NY sessions, overlaps, opens/closes, day-of-week | | |
| | **NW** | Smooth, envelopes, slope, crossovers, trend regime, breakout signals | | |
| ### Trading Session Awareness | |
| The model knows when London opens (08:00 UTC), NY opens (13:00 UTC), and the high-activity London-NY overlap (13:00-17:00 UTC). This is critical for FX β most price action happens during session overlaps. | |
| ## π Prediction Output | |
| ``` | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| EURUSD=X | Multi-Horizon FX Predictions | |
| Latest Bar: 2026-09-11 22:00 | |
| Current Price: 1.16023 | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| 1h: π‘ NEUTRAL | -0.0 pips | target=1.16023 | |
| 4h: π‘ NEUTRAL | +0.2 pips | target=1.16025 | |
| 8h: π‘ NEUTRAL | +0.8 pips | target=1.16030 | |
| 24h: π‘ NEUTRAL | +3.9 pips | target=1.16062 | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| CONSENSUS: π‘ NEUTRAL (confidence: 50%) | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| ``` | |
| ## π§ Python API | |
| ```python | |
| from predict import ForexPredictor | |
| predictor = ForexPredictor(ticker="EURUSD=X") | |
| # Multi-horizon with consensus | |
| result = predictor.get_multi_horizon() | |
| print(f"Consensus: {result['consensus']}") | |
| # Single horizon | |
| signal = predictor.get_signal(horizon=8) | |
| # signal = { | |
| # 'pair': 'EURUSD=X', 'signal': 'BUY', 'confidence': 0.65, | |
| # 'predicted_pips': 12.3, 'current_price': 1.16023, | |
| # 'target_price': 1.16146, 'horizon_hours': 8 | |
| # } | |
| # Fast HFT mode (LightGBM only) | |
| fast = predictor.get_signal(horizon=1, use_lstm=False) | |
| # Batch prediction on your own data | |
| preds = predictor.predict_batch(your_ohlcv_df, horizon=4) | |
| ``` | |
| ## π Training Other Pairs | |
| ```bash | |
| # Train on GBP/USD | |
| python train.py --ticker GBPUSD=X --no-backtest | |
| # Train on USD/JPY (pip size auto-detected as 0.01) | |
| python train.py --ticker USDJPY=X --no-backtest | |
| # Full walk-forward backtest (slower) | |
| python train.py --ticker EURUSD=X | |
| ``` | |
| Supported pairs: EURUSD, GBPUSD, USDJPY, USDCHF, AUDUSD, USDCAD, NZDUSD | |
| ## π Files | |
| ``` | |
| forex-predictive-model/ | |
| βββ config.py # All hyperparameters | |
| βββ data_loader.py # Yahoo Finance FX download | |
| βββ nadaraya_watson.py # NW envelope estimator (vectorized) | |
| βββ features.py # 180+ indicators (Bollinger, RSI, MACD, etc.) | |
| βββ labels.py # Pip-based labels + triple-barrier | |
| βββ models.py # LightGBM + LSTM ensemble | |
| βββ backtest.py # Walk-forward backtester (pip P&L) | |
| βββ train.py # Training pipeline CLI | |
| βββ predict.py # Prediction API + CLI | |
| βββ fx_models/EURUSD_X/ # Pre-trained models (4 horizons) | |
| ``` | |
| ## β οΈ Disclaimer | |
| Research tool, not financial advice. FX trading carries high risk. Always use stop-losses and proper position sizing. | |
| <!-- ml-intern-provenance --> | |
| ## Generated by ML Intern | |
| This model repository was generated by [ML Intern](https://github.com/huggingface/ml-intern), an agent for machine learning research and development on the Hugging Face Hub. | |
| - Try ML Intern: https://smolagents-ml-intern.hf.space | |
| - Source code: https://github.com/huggingface/ml-intern | |
| ## Usage | |
| ```python | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| model_id = 'AcyLa/forex-predictive-model' | |
| tokenizer = AutoTokenizer.from_pretrained(model_id) | |
| model = AutoModelForCausalLM.from_pretrained(model_id) | |
| ``` | |
| For non-causal architectures, replace `AutoModelForCausalLM` with the appropriate `AutoModel` class. | |