Target Lookahead

I have noticed that in some of my AI factors, when using the target 'FutureRel%Chg_D(21, #Bench),' I sometimes get a target lookahead of 5 weeks and other times 4 weeks. The same happens when using 63 days; sometimes I get 12 weeks and other times 13 weeks. It's not consistent...

The Future functions use the 'next' close as the end price. Lookahead expresses how many weeks it has to go back before it sees a value, with the dataset end date moved back to a fundamental (Saturday) date, meaning end price will always be a Monday historically. So Saturday through Monday*, you will see a different value for lookahead. Even though it flips between two values, it will always allow you to load the latest available forward-looking data into the dataset.

* Sometimes it will be through Tuesday due to holidays because weekday-flavor functions do not fill past the latest available bar of a series.

So when Using 21days future return I'm more likely looking at 4w return or 5w returns? If there is holdidays in one contry, I might looking at 5w for stocks listed in that country and 4w on other stocks?

Is it not better to use FutureRel%Chg_W(4, #Bench) instead?
I can not find FutureRel%Chg_W in the factor reference, but it seems to work.

Usually, FutureRel%Chg_D(21, #Bench) will cover the exact same date range from stock to stock and will cover the number of bars requested for any given stock.
There are two cases that cause this to not be the case:

  • When a price history stops before another, (especially when the most recent trading date is a holiday in some countries,) is when you can see misalignment, but the result will still be based on 21 bars, never 5 weeks.
  • Historical holidays, (i.e., those with subsequent price bars,) cause the end price used to be the one prior to the holiday, yielding a date range a bar or two shorter than expected.

Future _W is not recommended because it had an issue that couldn't be resolved and has been hidden from the reference accordingly.

Lookahead expresses how many weeks it has to go back before it sees a value, with the dataset end date moved back to a fundamental (Saturday) date, meaning end price will always be a Monday historically.

What you write here is confusing for me. Just to be clear that I my understanding is correct.

  • The model looks forward in time to find the target price, and the target start price is typically tied to a Monday, not the end price?
  • The Lookahead expresses how many weeks it has to go forward in time before it sees the end price?
  • The features uses the (Saturday) fundamental that we can see on the monday wea rebacktesting from, we are not looking weeks forward or back in time or in the future to find features?

Target lookahead is determined before dataset load to ensure it doesn't try to load a date that has NA's in the target for the entire universe. The implementation actually uses a screen backtest to determine target lookahead, and the result of this screen backtest is driven solely by the behavior of the universe and the formula. You can see it yourself by running a screen backtest with rule (TargetFormula) != NA and counting weeks with 0 stocks. Target lookahead will always be as low as possible so you can use the latest possible forward-looking data for your AI Factor's dataset.

Since dataset runs Saturdays, the future % function will always start on a Monday and will go that many bars after Monday for the end price. As detailed above, the start and end price can resolve to the preceding bar in certain circumstances. (Not mentioned specifically is that the benchmark may also be misaligned by these same circumstances.)

In the case of FutureRel%Chg_D(21, #Bench), it will usually use a Tuesday bar for the end price. If you want 4 weeks (Monday to Monday), you should use 20 instead of 21 just like the predefined target 4WRel does.

1 Like