Series · Complete
Seasonality in Python
Intraday patterns in futures. Preprocessing, backtesting, trade statistics and optimization.
04/04 parts
- Part 1: Seasonality in Python. Searching for Intraday PatternsPublished
- Part 2: Seasonality in Python II - BacktestingPublished
- Part 3: Seasonality in Python III - Statistics on TradingPublished
- Part 4: Intraday Seasonality IV - Field SearchPublished
The series builds, step by step in Python, a system to search for intraday seasonal patterns in futures: from 1-minute data to a search that tests every entry combination. Some Python and pandas is enough; the backtester is written from scratch with pandas masks.
Part 1 defines intraday seasonality and its causes, builds a 6E continuous future with a calendar roll and resamples 1-minute bars to 15 minutes. Part 2 writes the IntradaySeasonalBacktester class: it enters by weekday, hour and minute, exits after N bars and returns the trade history in points. Part 3 computes SQN, VaR and CVaR, alpha, beta, maximum drawdown and the Sharpe ratio on that history. Part 4 sweeps every weekday, hour, minute and bar combination with itertools and saves the metrics to a CSV.
The result is a custom backtester and a table of metrics per parameter combination: the starting point for finding seasonal edges.