2 registered members (AndrewAMD, VoroneTZ),
779
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: New Zorro version 2.40.2
[Re: jcl]
#483844
08/03/21 00:49
08/03/21 00:49
|
Joined: May 2018
Posts: 134
SBGuy
Member
|
Member
Joined: May 2018
Posts: 134
|
hi jcl, It looks like the problem is not the month() function, but rather the month(1) offset at the 1st bar of a new month. As you can see from the log snippet below, the first bar on 21-02-01 shows: month(0)=2 and month(1)=2. You agree that it should be: month(0)=2 and month(1)=1?
function tock()
....
printf("\n[%d] TOCK -- [%s] month()=%d month(1)=%d... ",utcHHMM, Asset,month(),month(1));
if(month()!=month(1) or Init) {
sprintf(OptionFile,"%s\\%s_%d%02d_m1.t8", HistFolder, Asset, year(),month());
printf("T8: %s\n",OptionFile);
}
..................Log entry................ [974: Fri 21-01-29 20:58] 3730.72/3734.22\3727.72/3727.72 -0.01 [2058] TOCK -- [SPX] month(0)=1 month(1)=1... [975: Mon 21-02-01 14:30] 3727.72/3727.72\3703.61/3707.86 -0.01 [1430] TOCK -- [SPX] month(0)=2 month(1)=2...
|
|
|
Re: New Zorro version 2.40.2
[Re: jcl]
#483847
08/03/21 12:32
08/03/21 12:32
|
Joined: May 2018
Posts: 134
SBGuy
Member
|
Member
Joined: May 2018
Posts: 134
|
hi jcl, I hear what you're saying. But I still believe there is a problem in 2.40 when tock was moved to execute after tick, which makes sense conceptually. Take a look at these log clippings and you'll see the problem. In v2.35, tock is executed before run(), and tock() has the same time stamp and BarNum as the upcoming run() , which make sense. In v2.40, tock is executed before run(), and tock() has the new BarNum, BUT..... old timestamp of the previous bar. This probably causes month(1) to equal month(0). I also did do as you suggested and check for month change in run(). But because of this problem, I am only able to detect a month change in bar 2 of the new month. FYI, this the formula I used for the timestamp printed in the log. int utcHHMM = hour()*100+minute();
..................... v 2.35 and before .........................
[1430] Bar[975] TOCK -- [SPX]
[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]
[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 ............................................
[974: Fri 21-01-29 20:58] 3730.72/3734.22\3727.72/3727.72 -0.01
[2058] Bar[974] run() -- price=3727.72
[2058] Bar[975] TOCK -- [SPX] <------------------------ bad time stamp for Bar 975. it should be 1430
[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] TOCK -- [SPX] <--------------------------- bar time stamp for Bar 976. it should be 1432
[976: Mon 21-02-01 14:32] 3751.48/3753.72\3751.48/3753.72 -0.01
[1432] Bar[976] run() -- price=3753.72
Last edited by SBGuy; 08/03/21 12:33.
|
|
|
Re: New Zorro version 2.40.2
[Re: jcl]
#483852
08/04/21 09:01
08/04/21 09:01
|
Joined: Feb 2021
Posts: 19
CpOo
Newbie
|
Newbie
Joined: Feb 2021
Posts: 19
|
Ah, ok. We'll check that and when it happens here too, it will be fixed. Since you found a bug in a release candidate, you're entitled for a 3 months free Zorro S subscription or support period - please contact Support for claiming the reward. Thanks!
|
|
|
Re: New Zorro version 2.40.2
[Re: jcl]
#483855
08/04/21 15:26
08/04/21 15:26
|
Joined: May 2018
Posts: 134
SBGuy
Member
|
Member
Joined: May 2018
Posts: 134
|
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.
................... 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
#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());
}
|
|
|
Re: New Zorro version 2.40.2
[Re: jcl]
#483861
08/05/21 17:09
08/05/21 17:09
|
Joined: May 2018
Posts: 134
SBGuy
Member
|
Member
Joined: May 2018
Posts: 134
|
I'm not sure I know enough about the internals of Zorro to opine on your question. But let me ask you this in the context of my specific application, using the details of the log entries below: If contractUpdate() is called in Bar 976 TOCK, or tick, which has a timestamp of 1430, which contract chain do you think will be loaded? (a) the chain for time of 1430 (the tick/tock timestamp) (b) the chain for time of 1432 (the Bar 976 time)
.................. 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
|
|
|
|