Explorations#
A collection of mathematical notes exploring questions that naturally arise when using hestonpy.
Each post mixes theory, intuition, and concrete code to dig into one specific question.
The hedge ratio between two cointegrated assets is rarely constant. We derive the
Kalman filter state-space model used by spreadpy — both the 2-state random-walk
and the 3-state locally-linear trend variants — and show how each avoids lookahead
bias. Applied to GLD/GDX with a full stationarity diagnostic.
From Markowitz target-volatility to the Kelly criterion. We derive the truncated
normal models behind spreadpy’s three Kelly sizers, show how the optimal fraction
$f^*$ depends on the entry threshold, and compare all four sizers on a concrete
GLD/GDX backtest.
A backtest is an optimistic experiment by construction. We identify the four failure
modes of naive backtesting — single split, multiple testing, autocorrelation bias,
period overfitting — and design a StrategyValidator class with walk-forward
engine, Deflated Sharpe Ratio, PBO, and parameter sensitivity analysis.