Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (PeroPero), 860 guests, and 4 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
Problem with Date in .t8 files #482273
01/22/21 18:14
01/22/21 18:14
Joined: Jan 2021
Posts: 9
P
pieran Offline OP
Newbie
pieran  Offline OP
Newbie
P

Joined: Jan 2021
Posts: 9
Hello,

I am new in this forum and I hope there is someone who can help. This might be a silly question but I cannot figure out, how to create a vaild .t8 file from a csv file.
Did a copy of CSVtoOptions.c and adjusted it to the csv format.

The csv format is:

optionkey,Symbol,ExpirationDate,AskPrice,AskSize,BidPrice,BidSize,LastPrice,PutCall,StrikePrice,Volume,openinterest,UnderlyingPrice,DataDate
SPY2019-01-02c100.002019-01-02,SPY,2019-01-02,151.45,10,149.02,310,0.00,call,100.00,0,0,250.24,2019-01-02
SPY2019-01-02c105.002019-01-02,SPY,2019-01-02,146.45,10,143.58,2,0.00,call,105.00,0,0,250.24,2019-01-02

and this is the code I am using


int Year = 2019;
string Ticker = "SPY";
string Format = ",,%Y-%m-%d,f,,f,,f,s,f,f,f,f,%Y-%m-%d";

void main()
{
int Records = dataParse(1,Format,strf("History\\%i_%s.csv",Year,Ticker));
printf("\n%d %s Records parsed",Records,Ticker);
if(!Records) return;

int i;
for(i=0; i<Records; i++) {
CONTRACT* O = dataAppendRow(2,9);
O->time = dataVar(1,i,9);
string PC = dataStr(1,i,4);
string EA = "A";
O->Type = ifelse(*PC == 'put',PUT,CALL) + ifelse(*EA == 'E',EUROPEAN,0);
O->Expiry = dataVar(1,i,0);
O->fStrike = dataVar(1,i,5);
O->fAsk = dataVar(1,i,1);
O->fBid = dataVar(1,i,2);
O->fVol = dataVar(1,i,6);
O->fVal = dataVar(1,i,7); // open interest
O->fUnl = dataVar(1,i,8);
if(!progress(100*i/Records,0)) break; // show a progress bar
//watch(O->time);
}

dataSort(2);
dataSave(2,strf("History\\%s_%i.t8",Ticker,Year));




It works fine except for the date fields "Date" and "Expiry".

[Linked Image]


Could anybody please suggest what I am doing wrong?
Thank you!

Re: Problem with Date in .t8 files [Re: pieran] #482275
01/23/21 14:14
01/23/21 14:14
Joined: Jan 2021
Posts: 9
P
pieran Offline OP
Newbie
pieran  Offline OP
Newbie
P

Joined: Jan 2021
Posts: 9
I reformatted the input file to match the date format of the original CSVtoOptions.c
Then I made sure that the Date was in Column 0. Than it worked. Kind of strange but luckily it worked :-)

Last edited by pieran; 01/23/21 14:15.
Re: Problem with Date in .t8 files [Re: pieran] #482296
01/26/21 07:21
01/26/21 07:21
Joined: Jan 2021
Posts: 22
Singapore
S
strimp099 Offline
Newbie
strimp099  Offline
Newbie
S

Joined: Jan 2021
Posts: 22
Singapore
Have a look at the trading.h file and find the CONTRACT struct which defines what each field in the .t8 file needs to look like. Quote datetime field DataDate in your file is of DATE format so your '%Y-%m-%d' string format will work. However the Expiry is a type Long of format YYYYMMDD so you need to use an "%i" string format. Also note that only those fields in the struct are necessary for the parser as those are the only ones that end up in your .t8 file.

Last edited by strimp099; 01/26/21 07:24.

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1