Skip to content

quantsingularity/Meridian-Quantitative-Research-Atlas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Meridian

Quantitative Strategy Research Atlas

Meridian is an end-to-end quantitative equity research notebook covering the full systematic investment pipeline, from raw signal construction through to portfolio optimisation and risk management. All analysis is performed on live market data downloaded via yfinance across a universe of 70+ S&P 500 stocks.


Contents

Chapter Title Key Methods
I Alpha Decay Analysis IC/ICIR, exponential decay fitting, half-life estimation, cost-adjusted IC, ensemble construction
II Alternative-Style Signal Research Volume anomaly, volatility dispersion, RSI sentiment, orthogonality testing
III Execution and Transaction Cost Analysis Intraday microstructure, market impact models, TWAP/VWAP, IS decomposition, Almgren-Chriss
IV Factor Model Analysis Fama-MacBeth regression, Newey-West standard errors, PCA, Barra-style risk model, factor zoo
V Model Validation and Backtesting Purged K-Fold CV, walk-forward, Combinatorial Purged CV, Diebold-Mariano test, overfitting diagnostics
VI Portfolio Construction Mean-variance optimisation, risk parity, Black-Litterman, constraint-aware optimisation, rolling backtest
VII Market Regime Detection Gaussian HMM on SPY/VIX, CUSUM change-point detection, transition matrix, regime-adaptive strategy
VIII Risk Management Historical/Gaussian/Student-t/EWMA VaR, CVaR, GEV extreme value theory, drawdown analysis, stress testing, Kelly criterion

Data

All data is sourced live from yfinance at runtime. No static data files are bundled with the repository. A working internet connection is required.

  • Equity universe: 70+ S&P 500 large-cap stocks across 11 sectors
  • Market benchmark: SPY (SPDR S&P 500 ETF)
  • Volatility proxy: VIX (CBOE Volatility Index)
  • Intraday data: SPY 1-minute OHLCV for execution analysis
  • Date range: January 2019 to December 2024 (approximately 5 years)

Signals

Five cross-sectional equity signals are constructed from price and volume data:

Signal Construction Expected Decay
momentum_12_1 252-day return minus 21-day return Medium
reversal_5d Negative of 5-day return Fast
low_volatility Negative of 63-day annualised volatility Slow
value_52w Negative of price divided by 52-week high Slow
volume_anom 5-day average volume divided by 63-day baseline Very fast

All signals are cross-sectionally z-scored and winsorised at +/- 3 standard deviations before use.


Requirements

python >= 3.9
yfinance >= 0.2
numpy
pandas
scipy
scikit-learn
matplotlib
seaborn

Install all dependencies with:

pip install yfinance numpy pandas scipy scikit-learn matplotlib seaborn

Optional, for HMM regime detection:

pip install hmmlearn

If hmmlearn is not installed, Chapter VII falls back to sklearn.mixture.GaussianMixture automatically.


Usage

Open the notebook and run all cells from top to bottom. The global setup cell downloads all market data and constructs signals. Subsequent chapter cells build on these shared variables.

If the kernel is restarted mid-session, individual chapter cells that are marked as self-contained can be run independently. They re-download data and recompute signals internally.

jupyter notebook Meridian_Quantitative_Research_Atlas.ipynb

Design Conventions

  • Figure size: all plots use a uniform width of 16 inches and height of 6 inches (FIG_W=16, FIG_H=6) at 120 DPI to ensure visual consistency
  • Colour palette: a single eight-colour palette (PALETTE) is applied throughout all chapters
  • No synthetic data: every number in every chart comes from live market data
  • No long dashes: all text uses standard hyphens to ensure plain-text compatibility across editors and operating systems
  • Style: seaborn-v0_8-darkgrid base with top and right spines removed

Project Structure

Meridian/
    Meridian_Quantitative_Research_Atlas.ipynb       # main notebook
    README.md                                        # this file

Key Results and Takeaways

Alpha Decay (Chapter I) Cross-sectional IC peaks at short horizons for reversal and volume signals (half-life under 5 days) and decays slowly for momentum and low-volatility (half-life exceeding 30 days). After adjusting for a 5 bps transaction cost, reversal and volume signals lose a material fraction of their raw IC at daily rebalancing frequencies.

Execution Costs (Chapter III) Using real SPY 1-minute data, VWAP execution consistently outperforms TWAP on low- volume days. The square-root market impact model calibrated to SPY implies roughly 8 to 12 bps of impact for a 5% of ADV order under normal conditions.

Factor Model (Chapter IV) Fama-MacBeth regression with Newey-West standard errors identifies momentum and low-volatility as consistently significant factors across the 2019 to 2024 period. The first three principal components explain over 75% of cross-sectional return variance. The Barra risk model shows that low-volatility dominates factor risk contribution in an equal-weight composite.

Model Validation (Chapter V) Combinatorial Purged CV across 15 paths shows positive out-of-sample IC for momentum and low-volatility, with meaningful degradation for reversal at longer horizons. The Diebold-Mariano test confirms that momentum IC is statistically distinguishable from the volume anomaly signal at the 5% level.

Portfolio Construction (Chapter VI) The risk parity portfolio delivers the best Sharpe ratio over the backtest period, with the constrained Max Sharpe portfolio (TE <= 5%, max 10% per stock) offering the best drawdown control. Black-Litterman tilts toward the top momentum stock produce a modest improvement in forward return without materially increasing tracking error.

Regime Detection (Chapter VII) The Gaussian HMM fitted to joint SPY returns and VIX identifies three stable regimes consistent with bull, neutral, and bear classifications. The CUSUM procedure detects major regime transitions including the COVID crash (February to March 2020) and the 2022 rate-hike drawdown. A regime-adaptive momentum strategy that goes defensive in bear regimes improves the Sharpe ratio relative to a static buy-and-hold position.

Risk Management (Chapter VIII) Historical VaR at 99% confidence is approximately 2.5% daily for the equal-weight portfolio. The GEV extreme value fit to monthly block minima reveals a positive shape parameter, confirming heavy tails consistent with equity return distributions. Portfolio correlations increase materially during the bottom 5% of return days, with average pairwise correlation rising from 0.45 in normal conditions to above 0.70 under stress.


Notes

  • Forward returns are constructed with a one-period shift to prevent look-ahead bias at all stages of the analysis
  • Purged K-Fold and CPCV splits include a 10-day embargo on either side of each test fold to prevent information leakage through serial correlation
  • All rolling windows use a minimum of half the window length as the minimum observation count before producing a valid estimate
  • The Kelly criterion outputs shown in Chapter VIII are for illustrative purposes and should not be used as direct position sizing guidance without further adjustments for estimation error and parameter uncertainty

License

Licensed under the MIT License. See LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors