Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,40 +1,156 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
| 6 |
-
- `trading_model_romeo_daily.pkl` — joblib artifact with tree models, weights, and canonical `features` list (artifact['features']).
|
| 7 |
-
- `romeo_keras_daily.keras` — optional Keras model (if included during training).
|
| 8 |
-
- `MODEL_CARD.md` — human-readable model card (detailed evaluation and transparency notes).
|
| 9 |
-
- `metadata.json` — machine-readable metadata for the artifact (owner, tags, metrics, usage).
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
2. Load the artifact:
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
```python
|
| 16 |
import joblib
|
| 17 |
artifact = joblib.load('trading_model_romeo_daily.pkl')
|
| 18 |
-
features = artifact['features']
|
| 19 |
-
|
|
|
|
| 20 |
```
|
| 21 |
|
| 22 |
-
|
| 23 |
```python
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
| 26 |
```
|
| 27 |
|
| 28 |
-
|
| 29 |
-
```
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
|
| 35 |
-
|
| 36 |
-
-
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
- The backtester that produced the evaluation uses per-bar M2M equity; position sizing is currently simple and may not reflect margin rules — exercise caution.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: mit
|
| 4 |
+
library_name: sklearn
|
| 5 |
+
tags:
|
| 6 |
+
- trading
|
| 7 |
+
- finance
|
| 8 |
+
- gold
|
| 9 |
+
- xauusd
|
| 10 |
+
- forex
|
| 11 |
+
- algorithmic-trading
|
| 12 |
+
- smart-money-concepts
|
| 13 |
+
- smc
|
| 14 |
+
- xgboost
|
| 15 |
+
- lightgbm
|
| 16 |
+
- machine-learning
|
| 17 |
+
- backtesting
|
| 18 |
+
- technical-analysis
|
| 19 |
+
- multi-timeframe
|
| 20 |
+
- intraday-trading
|
| 21 |
+
- high-frequency-trading
|
| 22 |
+
- ensemble-model
|
| 23 |
+
- keras
|
| 24 |
+
- tensorflow
|
| 25 |
+
datasets:
|
| 26 |
+
- yahoo-finance-gc-f
|
| 27 |
+
metrics:
|
| 28 |
+
- accuracy
|
| 29 |
+
- precision
|
| 30 |
+
- recall
|
| 31 |
+
- f1
|
| 32 |
+
- sharpe
|
| 33 |
+
- max_drawdown
|
| 34 |
+
- cagr
|
| 35 |
+
- win_rate
|
| 36 |
+
model-index:
|
| 37 |
+
- name: romeo-v5-daily
|
| 38 |
+
results:
|
| 39 |
+
- task:
|
| 40 |
+
type: binary-classification
|
| 41 |
+
name: Daily Price Direction Prediction
|
| 42 |
+
dataset:
|
| 43 |
+
type: yahoo-finance-gc-f
|
| 44 |
+
name: Gold Futures (GC=F)
|
| 45 |
+
metrics:
|
| 46 |
+
- type: accuracy
|
| 47 |
+
value: 49.47
|
| 48 |
+
name: Win Rate
|
| 49 |
+
- type: sharpe
|
| 50 |
+
value: 0.3119
|
| 51 |
+
name: Sharpe Ratio
|
| 52 |
+
- type: max_drawdown
|
| 53 |
+
value: -47.66
|
| 54 |
+
name: Max Drawdown (%)
|
| 55 |
+
- type: cagr
|
| 56 |
+
value: 0.0444
|
| 57 |
+
name: CAGR
|
| 58 |
+
---
|
| 59 |
|
| 60 |
+
# Romeo V5 — Ensemble Trading Model for XAUUSD
|
| 61 |
|
| 62 |
+
## Model Details
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
+
### Model Description
|
| 65 |
+
Romeo V5 is an ensemble machine learning model designed for predicting price movements in XAUUSD (Gold vs US Dollar) futures. It combines tree-based models (XGBoost and LightGBM) with an optional Keras neural network head to generate trading signals. The model outputs a probability score for long (up) trades, and the backtester handles entry/exit logic, position sizing, and risk management.
|
|
|
|
| 66 |
|
| 67 |
+
- **Model Type**: Ensemble Classifier (XGBoost + LightGBM + optional Keras NN)
|
| 68 |
+
- **Asset**: XAUUSD (Gold Futures)
|
| 69 |
+
- **Strategy**: Smart Money Concepts (SMC) with technical indicators
|
| 70 |
+
- **Prediction Horizon**: Daily timeframe (5-day ahead direction)
|
| 71 |
+
- **Framework**: Scikit-learn, XGBoost, LightGBM, TensorFlow/Keras
|
| 72 |
+
|
| 73 |
+
### Model Architecture
|
| 74 |
+
- **Ensemble Components**:
|
| 75 |
+
- XGBoost Classifier: Gradient boosting on decision trees.
|
| 76 |
+
- LightGBM Classifier: Efficient gradient boosting with leaf-wise growth.
|
| 77 |
+
- Optional Keras Neural Network: Dense layers with custom `SumAxis1Layer` to replace anonymous Lambda for serialization.
|
| 78 |
+
- **Features**: 31 canonical features including technical indicators (SMA, EMA, RSI, Bollinger Bands) and SMC elements (order blocks, volume profiles).
|
| 79 |
+
- **Serialization**: Tree models saved in joblib `.pkl` format; Keras model in native `.keras` format.
|
| 80 |
+
- **Weights**: Ensemble weights stored in artifact for weighted probability averaging.
|
| 81 |
+
|
| 82 |
+
### Intended Use
|
| 83 |
+
- **Primary Use**: Research, backtesting, and evaluation on historical XAUUSD data.
|
| 84 |
+
- **Secondary Use**: Educational purposes for understanding ensemble trading models.
|
| 85 |
+
- **Out-of-Scope**: Not financial advice. Do not use for live trading without proper validation, risk controls, and regulatory compliance.
|
| 86 |
+
|
| 87 |
+
### Factors
|
| 88 |
+
- **Relevant Factors**: Market volatility, economic indicators affecting gold prices (e.g., USD strength, inflation data).
|
| 89 |
+
- **Evaluation Factors**: Tested on unseen data; robustness scanned across slippage, commission, and threshold parameters.
|
| 90 |
+
|
| 91 |
+
### Metrics
|
| 92 |
+
- **Evaluation Data**: Unseen daily data (out-of-sample).
|
| 93 |
+
- **Metrics**:
|
| 94 |
+
- Initial Capital: 100
|
| 95 |
+
- Final Capital: 484.82
|
| 96 |
+
- CAGR: 0.0444
|
| 97 |
+
- Annual Volatility: 0.4118
|
| 98 |
+
- Sharpe Ratio: 0.3119
|
| 99 |
+
- Max Drawdown: -47.66%
|
| 100 |
+
- Total Trades: 3610
|
| 101 |
+
- Win Rate: 49.47%
|
| 102 |
+
- Avg PnL per Trade: 0.1066
|
| 103 |
+
|
| 104 |
+
### Training Data
|
| 105 |
+
- **Source**: Yahoo Finance (GC=F) historical data.
|
| 106 |
+
- **Preprocessing**: Feature engineering with technical indicators and SMC concepts.
|
| 107 |
+
- **Split**: Trained on historical data; evaluated on unseen fresh dataset.
|
| 108 |
+
|
| 109 |
+
### Quantitative Analyses
|
| 110 |
+
- **Robustness Scan**: Coarse grid sweep (slippage: 0-1 pips, commission: 0-0.0005, threshold: 0.5-0.6). Best scenarios: low friction, threshold ~0.5. Worst: high commission/threshold.
|
| 111 |
+
- **M2M Equity**: Per-bar mark-to-market equity calculation for accurate risk metrics.
|
| 112 |
+
|
| 113 |
+
### Ethical Considerations
|
| 114 |
+
- **Bias**: Model trained on historical data; may not account for future market changes or black swan events.
|
| 115 |
+
- **Risk**: High volatility in forex; potential for significant losses.
|
| 116 |
+
- **Transparency**: Full disclosure of assumptions, limitations, and evaluation.
|
| 117 |
+
|
| 118 |
+
### Caveats and Recommendations
|
| 119 |
+
- **Limitations**: Simplified position sizing; small-account behavior may differ with margin rules. Historical backtests not indicative of future results.
|
| 120 |
+
- **Recommendations**: Use with stop-loss, diversify, and consult financial advisors. Validate on your own data before use.
|
| 121 |
+
|
| 122 |
+
## Usage
|
| 123 |
+
|
| 124 |
+
### Loading the Model
|
| 125 |
```python
|
| 126 |
import joblib
|
| 127 |
artifact = joblib.load('trading_model_romeo_daily.pkl')
|
| 128 |
+
features = artifact['features'] # Canonical feature list
|
| 129 |
+
models = artifact['models'] # Dict of XGBoost/LightGBM models
|
| 130 |
+
weights = artifact['weights'] # Ensemble weights
|
| 131 |
```
|
| 132 |
|
| 133 |
+
### Making Predictions
|
| 134 |
```python
|
| 135 |
+
import pandas as pd
|
| 136 |
+
# Prepare df with features matching artifact['features']
|
| 137 |
+
X = df[features].fillna(0) # Fill missing features with 0
|
| 138 |
+
probabilities = sum(weight * model.predict_proba(X)[:, 1] for model, weight in zip(models.values(), weights.values())) / sum(weights.values())
|
| 139 |
+
signals = (probabilities > threshold).astype(int) # threshold e.g. 0.5
|
| 140 |
```
|
| 141 |
|
| 142 |
+
### Backtesting
|
| 143 |
+
Use `v5/backtest_v5.py` with `--data <path>` to run on custom data. It aligns features automatically.
|
| 144 |
+
|
| 145 |
+
### Requirements
|
| 146 |
+
- Python 3.8+
|
| 147 |
+
- scikit-learn, xgboost, lightgbm, tensorflow, joblib
|
| 148 |
|
| 149 |
+
## Files
|
| 150 |
+
- `trading_model_romeo_daily.pkl`: Main artifact.
|
| 151 |
+
- `romeo_keras_daily.keras`: Optional Keras model.
|
| 152 |
+
- `README.md`: This model card.
|
| 153 |
+
- `metadata.json`: Structured metadata.
|
| 154 |
|
| 155 |
+
## Contact
|
| 156 |
+
For issues or contributions: https://github.com/JonusNattapong/AITradings-samsam
|
|
|