04 · Quant

Quantitative finance, on the side.

Markets are the other place where the tools I use for astrophysics are useful. Probability, Bayesian inference, and time series analysis all port across. What started as curiosity has turned into a serious side interest.

The overlap

Why physics and markets read well together.

A transit light curve is a noisy time series with a hidden, structured signal. A stock price is a noisy time series with a hidden, structured signal. The math is more similar than the words suggest. The same sampler I use to fit a planet's radius can, with different priors and a different likelihood, fit the mean reversion rate of a stock pair.

I've spent the last year reading through standard material on systematic trading, reproducing the simpler results in Python, and completing Wharton Online's Fundamentals of Quantitative Modeling. The bigger project below is where I'm applying it.

Net Sharpe sensitivity surface over tunable parameters
A Sharpe sensitivity surface across two tunables. The sharp peaks are usually where a strategy has started fitting noise instead of signal. The quiet plateaus are where real edge tends to live.
Self‑directed · ongoing

Reading, building, backtesting.

The loop I run is simple. Read a paper or a chapter. Implement the simplest version in Python. Backtest it. Break it on purpose by removing a safety assumption, and see what happens. Most of what I learn comes from the broken runs, not the clean ones.

The project

MCMC pairs trading on US equities.

A statistical arbitrage strategy that borrows the sampler from my thesis. Instead of fitting the light curve of a transiting planet, I fit a time varying spread between two cointegrated stocks, then trade the reversions back to the mean.

Project in progress. The numbers reported below will be replaced with real backtest results once the pipeline is end‑to‑end complete.

The idea, in one paragraph

Some pairs of stocks move together because their businesses are tied to the same underlying factor. Coke and Pepsi. Visa and Mastercard. Two oil majors. When the price ratio of such a pair drifts temporarily out of line, there is often a small statistical edge in betting it comes back. The mean reversion edge is tiny per trade, so the strategy has to be applied across many pairs, carefully, and with honest accounting for costs.

How the pipeline works

Universe. Liquid US large caps, filtered to within the same sub industry. Candidate pairs are tested for cointegration on a rolling 252 day window.

Spread model. Each pair's log price ratio is modelled as an Ornstein‑Uhlenbeck process, fit by MCMC. The fit returns posterior distributions on the mean reversion rate, the long term mean, and the spread volatility.

Signal. The current spread is scored against its posterior predictive. Enter when the z‑score exceeds a threshold, exit either on reversion to the mean or on a volatility based stop loss.

Sizing. Dollar neutral per pair. Risk parity across pairs with a fixed annualised volatility target, so the portfolio shouldn't be dominated by any single pair.

Costs. Realistic per‑leg commissions and a borrow cost for the short leg. This is where most naive backtests silently cheat.

Things to be careful about

It is very easy to build a version of this that shows a beautiful in‑sample Sharpe by (a) peeking at the future when choosing pairs, (b) ignoring survivorship bias in the universe, (c) using an unrealistic flat transaction cost. All three have to be handled honestly for the final number to mean anything at all.

The mean reversion rate is where most of the supposed edge lives, but it is also the least stable parameter across time. A pair can look beautifully mean reverting for a year and then regime shift. The posterior spread on the reversion rate ends up being a better signal for when to stop trading a pair than any single point estimate.

Why Bayesian, and not just least squares

A maximum likelihood fit gives you a best guess. MCMC gives you a distribution of plausible values. For a strategy whose performance depends on one or two fragile parameters, the distribution matters more than the point estimate. It tells you when the fit is confident and when it is not, and you can size positions accordingly, or sit out entirely when the posterior is too wide to trust.

Toolbox

What I'm using.

Languages
  • Python
  • C++
  • NumPy, SciPy, pandas
Methods
  • MCMC, Bayesian inference
  • Time series modelling
  • Backtesting workflows
Coursework
  • Wharton Online · Quantitative Modeling
  • IBM · Generative AI: Introduction & Applications
  • Reading list of papers, self directed
← Back Research Next → CV