Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by M_D. 04/26/24 20:22
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (M_D, AndrewAMD, Quad, Ayumi), 806 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 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