Market Exposure Timing Research
Status: Finished •
License: MIT
"Can a machine learning model beat random market entries using just price and volume data?"
METR is a personal experiment I built to see if I could use machine learning to filter out bad trades from a basic momentum strategy. I wanted to test this rigorously, so I compared my model's performance against 10,000 random Monte Carlo simulations to make sure any success wasn't just luck.
- The Core Idea: I start with a basic momentum signal (e.g., buy if the price has been going up). Then, I use an XGBoost classifier to look at other indicators and decide whether to actually take the trade or pass on it.
- Labeling: I used a "Triple Barrier" method to label my data. It sets a profit target, a stop loss, and a time limit (like 5 days) for each trade.
- Features: I used Polars to build technical indicators, including some fractional differentiation to make the data stationary while keeping its history.
- Validation: I checked the results using standard metrics like Sharpe ratio and ran Monte Carlo simulations to verify the stats.
The most interesting result came from the Gold ETF (GoldBees). The model was actually able to turn a losing basic momentum signal into a profitable one on unseen data from 2024–2025.
| Metric | Result |
|---|---|
| Return | +17.92% |
| Sharpe Ratio | 1.48 |
| Max Drawdown | 7.99% |
| Win Rate | 66.1% |
I ran a few statistical tests (like a Monte Carlo simulation with 10k runs), and the results for Gold were statistically significant (p-value ~0.01). However, the model didn't find any real edge for Nifty 50 or USD/INR, which makes sense given how efficient and managed those markets are.
Click to view
METR/
├── data/ # Raw and processed data
├── docs/ # My notes and methodology
├── src/
│ ├── fetch_data.py # Fetches data from yfinance
│ ├── feature_eng.py # Indicator logic using Polars
│ ├── triple_barrier.py # Trade labeling logic
│ ├── train_trade_filter.py # The XGBoost model
│ ├── backtest_engine.py # Code to calculate returns
│ └── monte_carlo_audit.py # Random simulations for testing
├── config.yaml # Project settings
└── README.md
If you want to read more about what I learned and how I built it:
- Documentation & Methodology: The main write-up of my findings.
- Observations: My daily logs while working on the project.
- Triple Barrier Labelling Algorithm by William Santos – Implementation guidance for volatility-adaptive labeling.
- Fractional Differencing Financial Data by The Quant Trading Room – Theoretical foundation for memory preservation.
