joshriang
← Back to portfolio

Quant research & trading·Python·Published

Factor Research

This is the library I use to answer whether a factor actually sorts returns or just looks plausible in a chart. It pulls EOD prices and fundamentals from yfinance for a curated 50-ticker US universe, or the full S&P 500 scraped from Wikipedia with a fallback to the 50 if that fails, computes five factors, forms decile portfolios at each month-end, and measures the information coefficient as the Spearman rank correlation between the factor and the next period's return. The five factors are 12-1 momentum, earnings yield as 1 / trailing P/E, a quality composite z-score of ROE and gross margin, negative 252-day realized volatility, and negative log market cap. The CLI runs a full decile backtest plus IC summary and writes CSV and JSON alongside matplotlib charts of cumulative decile returns, the IC time series and the top-minus-bottom spread. ic_summary breaks the IC out per year as well as overall, which is the part that tells me whether a factor worked once in 2020 or has been consistently weak. Each factor is computed at the rebalance date from data available at that date, so the ordering being measured is the ordering a portfolio could actually have held.

Date
2026
Main stack
Python
Code
github ↗
01
02
  • A decile spread and an IC measure different things: the spread tells you the payoff if you could trade the extremes, the IC tells you whether the ordering is monotone, and a factor can have a positive spread with a near-zero IC if only the top decile carries the signal.
  • Skipping the most recent month in 12-1 momentum is not cosmetic; including it loads the factor with short-term reversal, which is a different and usually opposite effect.
  • Per-year IC breakdowns catch regime dependence that a single overall IC averages away, and a factor with a good overall IC built from two good years and eight flat ones is not a factor I would size.
03

Scale 0–100: how much this project relied on each skill.