Data & analysis / Research prototype
Stat-Arb Engine
A Python research prototype for tracing a pairs-trading backtest from CSV inputs through signals, costs, and a report.
View source code- Python
- Pandas
- NumPy
- Statsmodels
01 / The problem
The problem
A backtest needs enough detail to explain how it reached a result. This project keeps the input data, signals, position sizes, and costs available for inspection.
02 / What was built
What was built
CSV loaders align two price series by date. Separate modules calculate the hedge ratio, spread, z-score, position weights, and turnover costs. The report summarizes returns and drawdown.
03 / Engineering decisions
Engineering decisions
Match the dates
The loader sorts records, drops missing and duplicate rows, and keeps dates shared by both price series.
Return the working values
Backtest output includes prices, hedge ratio, spread, z-score, signals, weights, costs, returns, and equity in one table.
Keep costs adjustable
The cost module multiplies turnover by a configurable basis-point rate. A separate report calculates return, volatility, Sharpe ratio, drawdown, and total costs.
04 / Scope
Scope
05 / Read the code
Source code
Reviewed September 10, 2026.