Future%Chg needs an offset otherwise its only able to use "previous close"

I am trying to use Future%Chg as a label for some machine learning, but it looks like it captures the previous day’s close only. If the data we use for simulations is as of Saturday, then the label needs to reflect the return from the monday to the next monday, not the previous friday to the next friday.

Adding an offset would work? Something like Future%Chg(bars, offset) so if you set the offset = 1, it shifts forward a day so that it reflects buying the stock at the next close.

Or maybe the offset should be -1 to be clear that its moving to the future.

Are you talking about monday to monday closes ?
Or monday open to monday open ?

In any case we will fix Future%Chg to always start with next bar close

You can also computed yourself

100 * (Close(-6)/Close(-1) - 1)

I was talking about monday to monday closes, but perhaps some people would like to use monday to monday open… maybe you should make it an option like how in the sim you can select prev close / next open / next close?

Probably not necessary for training purposes. We can always add parameters. Main thing is to remove the price in the past, that is Friday’s close.

But maybe there are use cases for including Friday’s close, for example if you are training a model to give you sell signals for holdings. In that case you want include Friday’s close I think

In other words, maybe we should just add an offset after all and default it to 1.


@marco Was this ever done? Looks like it still does Friday to Friday close prices.

Using Close(-6) / close(-1) doesn’t work well over long periods because holidays cause overlapping returns. Looks to me like future%chg does not have this issue.

Hi Phil , we are talking about it. It’s not as simple as it sounds. The solution has to work for different series (bars, weekly, weekday) and be intuitive.

There are two main routes:

  1. Use a starting offset to -1 instead of 0.
  2. Add an offset parameter so that you decide.

Route 1 is more intuitive but has challenges for weekly time series (weekly series do not have access to Monday’s close). Route 2 is the most flexible but harder to use. And both this solutions will cause different results for whoever is using Future function. But that’s probably preferable since it’s more correct and usage is still light.

Yes this is a problem with bars and short periods. You should use Close_D(-6)/Close_D(-1) . This will always be Monday to Monday (when Monday is a holiday Close_D(-1) will return Tuesday’s close).

So until we have a fix for the future functions try using Close_D. This should work as expected for you.


1 Like

The problem that I am having is not when Monday is a holiday its when Tues / Wed / Thurs / Fri is a holiday because then it skips to the follow Tuesday’s close. So then you have a Monday to Tuesday return and then the following week is Monday to Monday so you get the following Monday twice. I’m not 100% sure but I don’t think Close_D fixes this problem.

1 Like

Just to clarify what the 1 week future return is under each of these cases:

  1. if there are no holidays it’s the % return from Monday to Monday.
  2. if the closest Monday is a holiday then it’s the % return is from Tuesday to Monday.
  3. if the next Monday is a holiday then it’s the % return is from Monday to Tuesday.
  4. if both Monday’s are holidays then it’s the % return from Tue to Tue

Only close prices are used and holidays in any other day have no effect (assuming there are no contiguous holidays)

NOTE: the above is not possible at the moment without a a way to check if an offset is a holiday.

OK that logic should fix the problem I’m experiencing (but doesn’t seem to). Let me check again and come back to you.