Re VIX future.
I need to know the days till expiration of each futures contract within a backtester. Currently, I can get the days until roll for the current moment future. However, I need the exact days until expiration for each future.
Under Market Data -> Global Merge Policy, I have 'Merge Back Adjusted'
----------------------------------------------------------------------------------
Print(Time[0] + " " + this.Instrument.MasterInstrument.GetNextRolloverDa te(DateTime.Now).Subtract(Time[0]).TotalDays + " Days till Roll");
The above gives me the current-most future's Roll Date but does not seem to properly roll for farther back futures. For example, the backtester automatically rolls the "ES 09-20" contract for a 3 year lookback for a backtester such that, in say July of 2019, the backtester is 'trading' the Sep 19 contract, not today's front contract which is Sep 20. (Even though I type in "ES 09-20" for the Instrument in Strategy Analyzer. Am I understanding this correctly?)
But when I print the above Print row in a larger backtester, it only gives me the number of days until the current front contract. For example, if I use "ES 09-20" as the backtested product and a 12 month historical window, the above printed row for 01/06/2020 12:00:00 PM says there are 247 days till expiration. This is the number of days until the "ES 09-20" expires which is NOT what the backtester is actually trading on 01/06/2020. On 01/06/2020 it is trading I think "ES 03-20" and so within the backtester on 01/06/2020 I need the number of days till expiration for the then front contract, "ES 03-20".
So the above is as close as I have gotten. I need days till expiration for the front contract for each point in the backtester.
Thoughts?
Thanks,
Tim
Comment