Skip to content

Uses z-score to generate an equally weighted long/short portfolio of the S&P 500 constituents and backtests using Backtrader.

Notifications You must be signed in to change notification settings

sapk806/alpha_factor_research

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

S&P 500 Mean-Reversion (Backtrader)

Mean-reversion strategy using dynamic S&P 500 membership.
Pipeline covers: data preparation (historical index membership + Yahoo Finance OHLCV), rolling z-scores, and an equally-weighted long/short Backtrader strategy with basic performance metrics.


Features

  • Handles changing S&P 500 constituents over time
  • Downloads OHLCV via yfinance
  • Computes rolling z-scores (lookback + 1-bar shift to avoid lookahead)
  • Rebalances on a fixed frequency; equal-weight long/short
  • Reports Sharpe, total return, start value, end value, max drawdown
  • Saves CSVs and an equity curve plot

Install

Using pip

python -m venv .venv && source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -r requirements.txt
pip install -e .   # so `alpha_factor_research` is importable

About

Uses z-score to generate an equally weighted long/short portfolio of the S&P 500 constituents and backtests using Backtrader.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages