Backtesting Frameworks
Subject: Stock-Market · Chapter: 6.2 Backtesting Frameworks Level: 2 (Recall / Standard Problems) Time Limit: 30 minutes Total Marks: 50
Section A — Definitions & Short Answers (24 marks)
Q1. Define backtesting in one sentence, and state the single most important assumption that makes a backtest predictive of live performance. (3 marks)
Q2. Explain survivorship bias in the context of a backtest that only uses currently-listed stocks. State one way to eliminate it. (3 marks)
Q3. Define look-ahead bias and give one concrete coding example of how it can accidentally occur. (3 marks)
Q4. Distinguish between slippage and transaction costs (commissions). Give one sentence each. (3 marks)
Q5. Explain the difference between in-sample and out-of-sample testing, and state why reporting only in-sample results is misleading. (3 marks)
Q6. Name three Python tools used in backtesting and give the primary role of each. (3 marks)
Q7. Define maximum drawdown (max DD) and state whether a smaller or larger value is preferable. (3 marks)
Q8. What is paper trading, and why is it recommended before deploying a strategy with real capital? (3 marks)
Section B — Standard Problems (26 marks)
Q9. A strategy grows an initial capital of $10,000 to $16,105 over 5 years. (a) Compute the CAGR. (4 marks) (b) State the CAGR formula you used. (1 mark)
Q10. During a backtest an equity curve reaches a peak of $24,000, falls to a trough of $18,000, then recovers. (a) Compute the maximum drawdown as a percentage. (3 marks) (b) Briefly state why max DD matters to a trader. (2 marks)
Q11. A strategy trades 40 times in a year. Each round-trip incurs $5 commission and an estimated 0.10% slippage on a $10,000 position. (a) Compute total annual commission cost. (2 marks) (b) Compute total annual slippage cost. (3 marks) (c) Compute total annual trading cost. (2 marks)
Q12. A Monte Carlo simulation reshuffles a strategy's daily returns 1,000 times to build a distribution of final equity. (a) What question does this simulation help answer? (2 marks) (b) State one reason resampling returns can understate real-world risk. (2 marks)
Answer keyMark scheme & solutions
Section A
Q1. (3)
- Backtesting = simulating a trading strategy on historical data to estimate how it would have performed (1).
- One sentence, using rules exactly as they would trade live (1).
- Key assumption: the future market behaves statistically similarly to the historical period tested (stationarity of the edge) (1).
Q2. (3)
- Survivorship bias = using only stocks that still exist today, ignoring delisted/bankrupt/merged companies (1).
- This inflates returns because failures are excluded (1).
- Fix: use a point-in-time / survivorship-bias-free dataset that includes delisted securities (1).
Q3. (3)
- Look-ahead bias = using information in the backtest that would not have been available at the decision time (1).
- Example: computing a signal using today's closing price to place a trade at today's open; or using restated/revised fundamentals (2) (1 for valid example, 1 for correct reasoning).
Q4. (3)
- Commissions = fixed/known fees charged by broker/exchange per trade (1.5).
- Slippage = difference between expected execution price and actual fill price due to market movement/liquidity (1.5).
Q5. (3)
- In-sample = data used to build/optimise the strategy (1).
- Out-of-sample = fresh data withheld to validate it (1).
- In-sample-only results overstate performance because parameters were fitted (curve-fit) to that same data (1).
Q6. (3) — 1 mark each:
- pandas — data handling/manipulation of time-series price data.
- backtrader — event-driven backtesting engine for strategy simulation.
- zipline — backtesting/algorithmic-trading library (Quantopian lineage).
Q7. (3)
- Max DD = the largest peak-to-trough percentage decline in equity over the test period (2).
- A smaller value is preferable (less severe loss) (1).
Q8. (3)
- Paper trading = simulated live trading with real-time data but no real money (1.5).
- Recommended because it validates execution/latency/data issues and psychological discipline that a backtest cannot capture, before risking capital (1.5).
Section B
Q9. (5)
- Formula: (1)
- (2)
- (2)
Q10. (5)
- Max DD (3)
- Matters: shows worst loss an investor must psychologically/financially survive; drives position sizing and risk of ruin (2).
Q11. (7)
- (a) Commission =40\times\5=\mathbf{$200}$ (2)
- (b) Slippage per trade =0.10\%\times\10{,}000=$10=40\times$10=\mathbf{$400}$ (3)
- (c) Total cost =\200+$400=\mathbf{$600}$ (2)
Q12. (4)
- (a) It estimates the distribution of possible outcomes / range of drawdowns and returns, i.e. how much the single backtest result depended on the luck of ordering (2).
- (b) Resampling assumes returns are independent and identically distributed, so it destroys real autocorrelation/volatility clustering and tail-dependence, understating true risk (2).
[
{"claim":"Q9 CAGR = 10%","code":"Vf=16105; Vi=10000; n=5; cagr=(Rational(Vf,Vi))**(Rational(1,n))-1; result = abs(float(cagr)-0.10) < 0.001"},
{"claim":"Q10 Max DD = 25%","code":"dd=(24000-18000)/24000; result = abs(dd-0.25) < 1e-9"},
{"claim":"Q11a commission = 200","code":"result = 40*5 == 200"},
{"claim":"Q11b slippage = 400","code":"slip=40*(0.001*10000); result = abs(slip-400) < 1e-9"},
{"claim":"Q11c total cost = 600","code":"total=40*5 + 40*(0.001*10000); result = abs(total-600) < 1e-9"}
]