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!