Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/20/24 06:09
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (flink, Edgar_Herrera), 695 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Use this to convert t8 options data to CSV #481827
11/05/20 21:54
11/05/20 21:54
Joined: Dec 2018
Posts: 24
K
Kaga Offline OP
Newbie
Kaga  Offline OP
Newbie
K

Joined: Dec 2018
Posts: 24
Select "CSVfromHistory" in Zorro and click "Edit". Then do the following steps

1) Comment out the `#define MAX_RECORDS 10000` line, since options data has many more lines than that.
2) Find the line with the `string Source` definition and replace it by
Code
string Source = file_select("History","T1,T6,T8\0*.t1;*.t6;*.t8\0\0");

3) Just before the line `printf("\nDone!");` insert the following code
Code
else if(strstr(Source,".t8")) {
		CONTRACT *Ticks = file_content(Source);
		int Records = file_length(Source)/sizeof(CONTRACT);
		printf("\n%d records..",Records);
#ifdef MAX_RECORDS
		Records = min(Records,MAX_RECORDS);
#endif
#ifdef ASCENDING
		int nTicks = Records;
		while(--nTicks) 
#else
		int nTicks = -1;
		while(++nTicks < Records) 
#endif
		{
			CONTRACT *t = Ticks+nTicks;
			string otype,otype2;
			switch(t->Type){  
				case PUT:    
					otype="P";otype2="A";   
					break;  
				case CALL:    
					otype="C";otype2="A";   
					break;  
				case PUT+EUROPEAN:    
					otype="P";otype2="E";
					break;  
				case CALL+EUROPEAN:    
					otype="C";otype2="E";    
					break;
				default:    
					printf("None of them! ");
			}
//format: date, put/call, american/european, expiry date, strike, ask, bid, volume, open interest, underlying closing price
			file_append(Target,strf("%s,%s,%s,%d,%.2f,%.2f,%.2f,%d,%d,%.2f\n",
				strdate("%Y-%m-%d",t->time),
				otype,otype2,(int)t->Expiry,(var)t->fStrike,(var)t->fAsk,(var)t->fBid,(int)t->fVol,(int)t->fVal,(var)t->fUnl));
			if(!point(nTicks)) return;
		}
	}

Congratulations, now your CSVfromHistory script can handle t8 options data files!
But beware, the conversion takes some time. For example, the most recent SPY.t8 took about 30 min to convert.

Last edited by Kaga; 11/05/20 22:37.
Re: Use this to convert t8 options data to CSV [Re: Kaga] #481828
11/05/20 23:29
11/05/20 23:29
Joined: Oct 2017
Posts: 56
Munich
K
kalmar Offline
Junior Member
kalmar  Offline
Junior Member
K

Joined: Oct 2017
Posts: 56
Munich
Thank you, Kaga!

Re: Use this to convert t8 options data to CSV [Re: Kaga] #482529
02/18/21 13:00
02/18/21 13:00
Joined: Jan 2021
Posts: 22
Singapore
S
strimp099 Offline
Newbie
strimp099  Offline
Newbie
S

Joined: Jan 2021
Posts: 22
Singapore
contractPrint () too


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1