Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Quad, aliswee), 835 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: iVolatility options csv file to .t8 Zorro file [Re: SBGuy] #478797
12/21/19 03:11
12/21/19 03:11
Joined: Dec 2019
Posts: 6
I
interzonez Offline
Newbie
interzonez  Offline
Newbie
I

Joined: Dec 2019
Posts: 6
Thanks, yep using the script from the latest distro. Going around and around trying to match the format string to the CSV.

script and one line of my csv. probably I am missing something very simple and fundamental!

It parses 340648 SPX records. Then the error is: Error 013 invalid parameter 0

Date Expiry Under Strike Bid Ask OI Imp. vol fwd price Type
05/28/2019 12/20/2019 SPX C 100 2672.20 2675.80 533 1.696005 2810.23 E

Code

int Year = 2019;
string Ticker = "SPX"; // File name: SPX_2019.csv
string Format = "%m/%d/%Y,i,s,s,f,f,f,f,f,f,s"; // from the sample above

void main() 
{
// first step: parse the CSV file into a dataset
	int Records = dataParse(1,Format,strf("History\\%s_%i.csv",Ticker,Year));
	printf("\n%d %s Records parsed",Records,Ticker);
	if(!Records) return;
// second step: convert the raw data to the final CONTRACT format
	int i;
	for(i=0; i<Records; i++) {
		CONTRACT* O = dataAppendRow(2,9);
		O->time = dataVar(1,i,0);
		string PC = dataStr(1,i,3);
		string EA = dataStr(1,i,4);
		O->Type = ifelse(*PC == 'P',PUT,CALL) + ifelse(*EA == 'E',EUROPEAN,0);
		int Expiry = dataInt(1,i,1); 
		O->Expiry = 10000*(Expiry%10000) + Expiry/10000; // MMDDYYYY -> YYYYMMDD
		O->fStrike = dataVar(1,i,2);
		O->fAsk = dataVar(1,i,5);
		O->fBid = dataVar(1,i,6);
		O->fVol = dataVar(1,i,7);
		O->fVal = dataVar(1,i,8); // open interest
                O->fUnl = dataVar(1,i,9);
		if(!progress(100*i/Records,0)) break; // show a progress bar
	}
	dataSort(2);
	dataSave(2,strf("History\\%s_%1.t8",Ticker,Year));
}

Last edited by interzonez; 12/21/19 05:55.
Re: iVolatility options csv file to .t8 Zorro file [Re: SBGuy] #478800
12/21/19 06:00
12/21/19 06:00
Joined: Dec 2019
Posts: 6
I
interzonez Offline
Newbie
interzonez  Offline
Newbie
I

Joined: Dec 2019
Posts: 6
Update - I changed the output code to hard code the export file name:

dataSave(2,strf("History\\SPX_2019.t8",Ticker,Year));

I now have the .t8 file though can't interrogate it with ZHistoryEditor

Will try further tests

Re: iVolatility options csv file to .t8 Zorro file [Re: SBGuy] #478806
12/21/19 17:14
12/21/19 17:14
Joined: May 2018
Posts: 134
S
SBGuy Offline OP
Member
SBGuy  Offline OP
Member
S

Joined: May 2018
Posts: 134
A few problem areas I can see right off the bat.

1. Your source data doesn't looke like a CSV. I don't see any commas.
2. Your Expiry is 12/20/2019. That's not an Integer expected by format "i"
3. Your 4th element in your data is supposed to be Strike. I see "C"

Date Expiry Under Strike Bid Ask OI Imp. vol fwd price Type
05/28/2019 12/20/2019 SPX C 100 2672.20 2675.80 533 1.696005 2810.23 E

So just go through the source data very carefully and match it up with the Format string.
You might need another step to pre-process your source file to match the Zorro Format string. Getting data into Zorro t8 file is a process, not automatic. The sample script is just a guide.

Or... get another data source with better initial data format.

Page 2 of 2 1 2

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