Gamestudio Links
Zorro Links
Newest Posts
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:48
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
3 registered members (Quad, VoroneTZ, 1 invisible), 648 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 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