Personal project · February 2025 – present
Quantitative momentum trading strategy
- Python
- Back-testing
- Quantitative finance
- Challenge
- Test whether a momentum factor combining long-term trend, short-term reversal and volatility normalization can be traded systematically on the S&P 500.
- Solution
- A Python back-testing engine with configurable rebalancing frequency, position sizing and transaction costs.
- Result
- Risk-adjusted performance metrics (Sharpe ratio, drawdown, win rate) across 25 years of data, with weekly rebalancing performing best.

Data preparation
- Load the S&P 500 constituent list from CSV and normalize symbols (for example BRK.B to BRK-B).
- Download price history through the Yahoo Finance API.
- Drop symbols with fewer than 504 data points.
Momentum factor
For each stock, the 252-day return is combined with the 21-day return as a mean-reversion term and normalized by the 126-day standard deviation of daily returns, giving a single momentum score.
Rebalancing
A range of rebalancing frequencies was tested and ranked; weekly performed best on the S&P 500 universe. On each rebalance date the top N stocks by score are selected, weighted by score, and held until the next rebalance.
Portfolio tracking
- Daily portfolio value from weighted returns.
- Optional transaction costs.
- Stored history of returns, portfolio value and positions.
Performance analysis
Total and annualized return, annualized volatility, Sharpe ratio, maximum drawdown and win rate, with charts of portfolio value on a log scale, drawdown and annual returns.