Gamestudio Links
Zorro Links
Newest Posts
New Zorro version 2.35
by jcl. 02/24/21 14:40
findContract not finding a contract
by strimp099. 02/24/21 07:33
Zorro - import diff time zones csv
by AndrewAMD. 02/23/21 17:52
Using stablecoin as CCY on binance
by marr. 02/23/21 03:08
dataNew broken?
by DdlV. 02/23/21 00:55
Stop and profit/loss targets
by jpslvie. 02/22/21 19:08
Higher for at least N days in a row
by strimp099. 02/22/21 07:53
general questions about multitasking
by faustf. 02/21/21 23:36
AUM Magazine
Latest Screens
Scheherazade's Journey
Paradox Vector
The Space Between
Pogostuck: Rage With Your Friends
Who's Online Now
6 registered members (Santofimio, AndrewAMD, dpn, Quad, Dooley, 1 invisible), 446 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LorraineJones, SkNiX, wongkrezi, Wolf19, traderlivy
18599 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: 2
P
pieran Offline OP
Guest
pieran  Offline OP
Guest
P

Joined: Jan 2021
Posts: 2
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: 2
P
pieran Offline OP
Guest
pieran  Offline OP
Guest
P

Joined: Jan 2021
Posts: 2
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: 21
Singapore
S
strimp099 Offline
Newbie
strimp099  Offline
Newbie
S

Joined: Jan 2021
Posts: 21
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