hi jcl,

My understanding in 2.40 is that execution order is now: tick, TOCK, TMF, run.... instead of TOCK, tick, TMF, run as in 2.35.

My observation from this log snippet below is that a contractUpdate() in Bar 976 tock, will load the options chain from time 1430, which is Bar 975. The TMF that executes before run will used the options chain from 1430. This problem may not be that big using 2 minutes bars, but will be a big problem longer bars.

So... in short, my original month detection problem has evolved to a potential tick/tock/run timing problem.

See the log below.

In v2.35 all the bars have the same time stamp, i.e. tick, tock, run associated with Bar 976 have a timestamp of 1432, which makes sense.
In v2.40 tick, tock in Bar 976 have a time of 1430, and run has a time of 1432... doesn't look right to me.

Thanks for looking closer at this.

Code

................... v2.35 ......................... TOCK, tick, TMF, run

[1430] Bar[975] TOCK -- [SPX] LastMonth[1] RunMonth[1] NewMonth[0]... USE NEW T8: C:\Zorro\History\SPX-Options\\SPX_202102_m1.t8
[1430] Bar[975] tick -- [SPX] LastMonth[1] RunMonth[1] NewMonth[0]... 
[975: Mon 21-02-01 14:30] 3727.72/3727.72\3703.61/3707.86 -0.01
[1430] Bar[975] run() -- price=3707.86

[1432] Bar[976] TOCK -- [SPX] LastMonth[1] RunMonth[2] NewMonth[1]... USE NEW T8: C:\Zorro\History\SPX-Options\\SPX_202102_m1.t8
[1432] Bar[976] tick -- [SPX] LastMonth[1] RunMonth[2] NewMonth[1]... 
[976: Mon 21-02-01 14:32] 3751.48/3753.72\3751.48/3753.72 -0.01
[1432] Bar[976] run() -- price=3753.72

.................. v2.40 ......................... tick, TOCK, TMF, run

[2058] Bar[975] tick -- [SPX] LastMonth[1] RunMonth[1] NewMonth[0]... 
[2058] Bar[975] TOCK -- [SPX] LastMonth[1] RunMonth[1] NewMonth[0]... 
[975: Mon 21-02-01 14:30] 3727.72/3727.72\3703.61/3707.86 -0.01
[1430] Bar[975] run() -- price=3707.86

[1430] Bar[976] tick -- [SPX] LastMonth[1] RunMonth[2] NewMonth[1]... 
[1430] Bar[976] TOCK -- [SPX] LastMonth[1] RunMonth[2] NewMonth[1]... USE NEW T8: C:\Zorro\History\SPX-Options\\SPX_202102_m1.t8
[976: Mon 21-02-01 14:32] 3751.48/3753.72\3751.48/3753.72 -0.01
[1432] Bar[976] run() -- price=3753.72



The test script

Code
#include <stdio.h>
#include <default.c>

#define TICKER			"SPX"

string HistFolder[200];
string OptionFile[200];

bool NewMonth;
int LastMonth, RunMonth;

void main()
{	
	sprintf(HistFolder,"C:\\Zorro\\History\\%s-Options\\",TICKER);		
}


function tick()	
{
	int utcHHMM = hour()*100+minute();
	printf("\n[%d] Bar[%d] tick -- [%s] LastMonth[%d] RunMonth[%d] NewMonth[%d]... ",utcHHMM, Bar, Asset,LastMonth, RunMonth, NewMonth);	
}

function tock()	
{
	int myHour = lhour(ET);
	int myMins = minute();
	int HHMM = myHour*100+myMins;
	
	int utcHHMM = hour()*100+minute();

	printf("\n[%d] Bar[%d] TOCK -- [%s] LastMonth[%d] RunMonth[%d] NewMonth[%d]... ",utcHHMM, Bar, Asset,LastMonth, RunMonth, NewMonth);
	if(month(0)!=LastMonth) {		
		sprintf(OptionFile,"%s\\%s_%d%02d_m1.t8", HistFolder, Asset, year(),month());
		printf("USE NEW T8: %s\n",OptionFile);
		//contractUpdate().....
	}
}


void run() 
{
	NewMonth = month(0)!=month(1);
	RunMonth = month(0);
	LastMonth = month(1);
	
	int utcHHMM = hour()*100+minute();

	Verbose = 3;	//7|DIAG;

	StartDate = 20210301;
	EndDate = 	20210303;	
		
	static char HistoryPath[100];
	strcpy(HistoryPath,strf("%s\\*_mm.t6",HistFolder));
	History = HistoryPath;		

	BarPeriod = 2;		
	LookBack = 115*30;	// 115 1-hour bar look back
	
	BarZone = ET;
	StartMarket = 0930;			//ET Time
	EndMarket = 1600;				//ET Time
	BarMode = BR_WEEKEND+BR_MARKET+BR_SLEEP;
	TickTime = 1*60*1000;
	TockTime = 1*60*1000;
	set(PRELOAD);
	set(LOGFILE);
	
	asset("SPX");
	printf("\n[%d] Bar[%d] run() -- price=%.2f\n", utcHHMM, Bar, priceClose());
	
}