Quant trading backtests

Two trading strategies backtested from 2021 to 2026, through the 2022 bear market, for the Harvard Venture Tech Summer Program.

When
Jun – Jul 2026
Role
Solo
Built with
Python, pandas, matplotlib
Code
Public code
Links
By the numbers
18 commits of mine over 11 working days, Jun 17, 2026 to Jul 14, 2026
Same signal, two portfolio designs. v1 (dashed) sat in cash; v2 put idle capital in SPY and sized live trades properly.
Line chart from 2021 to 2026: earnings strategy v2 ends at +137.9%, SPY at +119%, v1 at +14.3%.

What I built

A momentum strategy that only holds when four conditions agree (market regime, trend, rate of change, and volatility), and an earnings strategy that goes long on beats and short on misses after the announcement.

I kept both purely numeric on purpose: no model calls, fully reproducible from cached data. I wanted the backtest engine and look-ahead safety right before adding AI on top.

Momentum trails SPY on raw return but its worst drawdown was -10.7% against SPY's -24.5%.
Momentum strategy versus SPY, 2021 to 2026, with the best run-up shaded green and the worst drawdown of -10.7% shaded red.

What was hard

Look-ahead bias. It's easy to accidentally trade on information you wouldn't have had yet, and it makes every result look better than it is.

Extending the window from 2023 back to 2021 changed both stories, which was a lesson in how much the test period decides the conclusion.

What I learned

The earnings strategy went from +14% to +138% between versions, and almost none of that came from a better signal. It came from portfolio construction: concentrating capital in live trades and parking idle cash in SPY.

Results

Momentum: +52.4%, Sharpe 1.02 versus SPY's 0.94, max drawdown -10.7% versus SPY's -24.5%.

Earnings (v2): +137.9%, beating SPY's roughly +120% on return, Sharpe, and drawdown.