ctxx (py) - for crypto, haven’t tried, but heard good things.
VectorBT - for vectorized backtesting.
Build yours - not in the beggining.
Backtesting pitfalls
Overfitting - tuning the strategy to the data, p-hacking.
Look ahead bias - we mention here again.
Only insample - training data, out of sample - testing data.
Walk forward optimization
Cross-validation
Montecarlo simulation
Backtesting tips
Backtesting is not a research tool; it should be used at the end of the process:
Final Verification - don’t optimize parameters.
Sensitivity - to transaction costs and fill ratios.
Code bugs
Non-Performance Stats: turnover, max net/gross exposure, and other stats.
Avoid Full Backtests for Signal Evaluation: Use alternative methods like event studies or regression for signal/alpha evaluation without running full backtests.
Costs - Reality modeling
Brokerage costs - easily estimated, commissions and fees.
Trading costs - slippage (delay), bid-ask spread and market impact.
Opportunity costs - order fillings.
Short sale constraints - cost of borrowing.
CFD costs - if you trade CFD’s
Example
Example: Momentum strategy for stocks equity
Difference between momentum (relative or cross sectional momentum) and trend following (absolute ot time series momentum):
Trend - moving in the same direction. If it has gone up rcently it will continue to go up.
Momentum - if it has gone up relative to other assets, it will continue to go up.
Behavioral - Overreact/underreact to new information, anchor to old prices, herding.
Structural - Investors are slow - need to call investment committee etc.
Information-based: Information diffusion, information asymmetry.
Trend effects are are stronger in small caps, in countries with less developed financial markets, after important information is released or fair value is less clear in general.
Crypto - fragmented, hard to value, strong retail engagement.