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.
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:
Use a starting offset to -1 instead of 0.
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.
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.
@marco , I tested a case for this year's Sep 2 which is holiday and is Monday also, when I get close_d(-1) with the asOfDate Aug 31, it will return the close price of previous Friday rather than next Tuesday's close price. I think close(0) should be filled with the previous closest price if the day is holiday, but for close_d(x) should be filled with the next closest price if the day is holiday.
Thanks