An institutional-grade, educational application that applies XGBoost machine learning to historical market data for multi-class trading signal generation. The system computes 33+ technical indicators, auto-selects the best labelling strategy, evaluates model performance, explains predictions with SHAP, and backtests the resulting signals.
Link to live terminal - https://tradewithmachine.streamlit.app/
⚠️ Disclaimer: This project is for educational and informational purposes only. It is not financial advice. Always do your own research before making investment decisions.
- Data Acquisition – Pulls OHLCV data from Yahoo Finance for Indian indices, futures, and crypto assets.
- Feature Engineering – Builds 33+ technical indicators across momentum, oscillators, trend, volatility, and volume categories.
- Automated Labelling – Generates bullish / bearish / neutral labels across multiple lookahead windows and thresholds.
- Baseline Scan – Trains a quick XGBoost model for every label strategy and ranks them by macro-F1.
- Hyper-Parameter Optimization – Optional
GridSearchCVwith time-series cross-validation. - Walk-Forward Validation – Optional out-of-sample validation across multiple time folds.
- Classification Reports – Accuracy, balanced accuracy, macro-F1, precision, recall, MCC.
- Confusion Matrix – Normalised heatmap of predicted vs actual classes.
- ROC Curves – One-vs-rest ROC/AUC for each class.
- SHAP Summary – Global feature importance to understand what drives predictions.
- Probability Thresholding – User-defined bullish / bearish thresholds to reduce false signals.
- Live Trading Signal – Latest prediction with confidence breakdown.
- Signal Timeline Chart – Candlestick chart overlaid with BUY / SELL markers.
- Strategy Backtest – Compares cumulative strategy return vs buy-and-hold market return.
- Risk Metrics – Win rate, alpha, total signals, and market return.
- Modern dark-themed interface using custom design tokens (
theme.py). - Reusable chart components (
components.py) and styled cards (ui_styles.py). - Landing page with feature overview and clear call-to-action.
| Layer | Libraries |
|---|---|
| App Framework | Streamlit |
| Data | yfinance, pandas, numpy |
| Technical Indicators | pandas-ta |
| Machine Learning | XGBoost, scikit-learn |
| Explainability | SHAP |
| Visualisation | Plotly, Matplotlib, Altair |
-
Clone or navigate to the project folder:
cd "XGboost ML"
-
Create a virtual environment (recommended):
python -m venv venv # Windows venv\Scripts\activate # macOS / Linux source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
Run the Streamlit application from the project root:
streamlit run p1.pyThen open your browser at http://localhost:8501.
- Select an asset symbol in the sidebar (e.g.
^NSEI,^BSESN,BTC-USD). - Set the start date and lookback window.
- Choose a labelling strategy or leave it on auto.
- Adjust bullish / bearish probability thresholds.
- Optionally enable Hyper-Parameter Search or Walk-Forward Validation.
- Click Execute Strategy to train the model and view results.
- Algorithm:
XGBClassifierwithmulti:softprobobjective for 3-class classification. - Classes:
0– Neutral1– Bearish2– Bullish
- Default Hyperparameters:
n_estimators=600max_depth=4learning_rate=0.01subsample=1.0colsample_bytree=0.6tree_method='hist'
- Data Split: 60% train / 20% validation / 20% test (chronological).
| Category | Indicators |
|---|---|
| Momentum | RSI(5, 10, 15), ROC(10), MOM(10) |
| Oscillators | Stochastic RSI, CCI(20), Williams %R(14), KST, MACD |
| Trend | SMA(5, 10, 20), EMA(5, 10, 20), VWMA(20) |
| Volatility | Bollinger Bands, ATR(14), Keltner Channel |
| Volume | OBV, A/D Line, EFI, NVI, PVI |
Engineer
📧 contact: ggengineerco@gmail.com
This project is released for educational purposes. Use at your own risk.