Python and data for quants
A backtest computes pnl = signal * returns, where both are indexed by day. What is wrong?
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
Try it
Pick an answer
Next free question: You need the quote in force at the instant of each trade. Which join?
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.
Report an issue with this question
Learn the method
Of the kind reported at
Citadel Securities, Two Sigma, Jump Trading, Point72 and Cubist
More python and data for quants questions
- You need the quote in force at the instant of each trade. Which join?Applied · Free solution
- A feature is standardised by subtracting its mean and dividing by its standard…Advanced · Premium
- You build a ten-year backtest on the stocks currently in an index.Advanced · Premium
- Building one-minute bars, part 3 of 3Advanced · Premium
- The New York equity open is 9:30 local time.Foundation · Premium
- Building one-minute bars, part 1 of 3Foundation · Premium