What you will learn
- Estimate annual cost drag from turnover and per-trade costs.
- Design an out-of-sample and walk-forward test and count its windows.
Modeling realistic costs
Costs include commissions, the bid-ask spread, slippage from price movement or market impact, financing, and taxes or levies where applicable. A round trip pays roughly half the spread at entry and half at exit.
Annual cost drag equals turnover multiplied by the one-way cost. High-turnover rules are the most sensitive, so test with costs at least double your estimate. If the edge disappears, it was fragile.
In-sample and out-of-sample data
In-sample data is used to design and tune the rule. Out-of-sample data stays untouched until the rule is final, giving an unbiased check. Each peek at it, and each later revision, turns it into in-sample data.
Overfitting is fitting noise: with enough parameters and trials, some rule will fit any history. Fewer parameters, simpler logic and a record of every trial reduce the problem but do not eliminate it.
Walk-forward analysis
Walk-forward analysis repeats design and test through time. Optimize on a training window, apply the chosen settings to the next test window, slide both windows forward, and join the test segments into one out-of-sample record.
It mimics how a rule would have been re-tuned in practice. Fix window lengths and the selection rule beforehand, and compare in-sample with out-of-sample performance: a large drop signals overfitting.
Worked example: A cost stress test
A fictional strategy earns 6.0% a year gross and turns over 1,200% of the portfolio annually, so traded value is 12 times the portfolio. At 0.25% one-way cost, drag is 12 × 0.25 = 3.0% and net return is 3.0%. Doubling cost to 0.50% gives drag of 6.0% and net return of 0.0%: the edge is gone.
Check your understanding
Data covers 2010 to 2021, twelve calendar years. A walk-forward test trains on four years, tests on the next year and rolls forward one year each time. How many test windows result, and which years are out-of-sample?
Show answer and explanation
The first training window is 2010-2013 and it tests 2014. The last tests 2021 after training on 2017-2020. That gives 12 - 4 = 8 windows, with out-of-sample years 2014 through 2021. The first four years are only ever training data.