A backtest computes pnl = signal * returns, where both are indexed by day. What is wrong?
- ANothing – that is the standard vectorised form
- BThe signal earns the same day’s return, which it could not have known
- CThe returns should be log returns rather than simple ones
- DTransaction costs are missing from the expression
Show the answer and worked solution
Answer: B – The signal earns the same day’s return, which it could not have known
The expression pays the signal at time the return realised at time , which is a return you could not have known when you formed the position. Every backtest written this way is trading on information from the future, and the effect is usually large enough to turn noise into a Sharpe ratio of several. The fix is signal.shift(1) * returns, and more than one period of lag if execution happens later than the close the signal was computed from. Missing costs and the choice between log and simple returns are real issues and both are worth far less than this one.
Worked solution
- Formula
- Substitute
- Solve
- Answer
Sanity check. Lag further when execution happens later than the close the signal was computed from.
- A. It is the standard bug. The signal must be lagged relative to the return it earns.
- B. Correct. Use
signal.shift(1) * returns, and lag further if execution happens later than the close. - C. A reasonable preference, but not the error here.
- D. True but secondary; the alignment error is worth far more than the costs.
Takeaway: Shift the signal, not the return.
Answer it in practice – your answer is marked and recorded.
Learn the method
Reported in interviews at
Citadel Securities, Two Sigma, Jump Trading, Point72 and Cubist
More python and data for quants questions
- The New York equity open is 9:30 local time.Foundation
- Building one-minute bars, part 1 of 3Foundation
- You need the quote in force at the instant of each trade. Which join?Applied
- A $100 stock goes ex-dividend by $2.Applied
- Prices go 100 → 110 → 99. What is the total log return, to five decimals?Applied
- Building one-minute bars, part 2 of 3Applied