0
$\begingroup$

I understand lookahead bias is pretty common industry knowledge. But I cannot wrap my head around how I am introducing it and could use a nice and easy explanation. Here's my thought process.

I have $N$ data points of OHLC data. Lets say for the sake of argument I pull $t = 1$ to $N$ from a database.

I train a model on the closing price of this instrument to predict the $t + 1$th value. I understand that by doing so I have introduced lookahead bias.

Where I struggle with is - when I go to predict the next time period's close with live data I'm going to

  1. Pull $N - 1$ data points
  2. Wait for this current candle to close (for the sake of argument, lets say I get this data as fast as possible)
  3. Add the new data point to the list of $N -1 $ data points I have pulled from my database
  4. Predict the $N+1$th data point (the NEXT time periods data point, in other words the now current data point's close)
  5. Make my trade

I feel like this is what I am doing in the training procedure, assuming that when I train on the $N$ data points, the $N$th data point has closed already.

Could someone take this example and explain to me where I'm making a mistake in my reasoning? I would really appreciate it.

EDIT

I should be more specific. Assuming I generate a $-1$ or $1$ signal for sell and buy respectively, and I am using a log return series.

$\endgroup$
2
$\begingroup$

The issue is how do you evaluate the success of your trades. If the P&L in your simulation is measured as C(t+1)-C(t) then your simulation is not completely realistic, because in real life by the time you compute the signal based on C(t), even if you do so quickly, the price C(t) will not be the current price and you will not be able to buy at that price. How big a problem this is depends on how liquid and volatile the market is.

One solution might be to measure the P&L as C(t+1)-O(t+1). This assumes that you will buy at the next bar open, based on the signal computed at the previous bar close.

$\endgroup$
  • $\begingroup$ The error depends not only on the characteristics of the market, but also more importantly on the kind of trading rule being tested. In implementing a "momentum", or "trend-following rule", which basically says to "buy when things are going up" you will find that C(t) tends to systematically understate the price at which you actually buy, since the price is moving against you. Conversely for a "Value" or "mean reversion" rule C(t) may be a reasonable estimate of your actual buy price even though you buy at $t+\epsilon$ and not $t$. $\endgroup$ – noob2 Jan 23 '17 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy