How To Import Multiyear Data History (Modifying CSVtoT6.c)

Posted By: Alphatecht

How To Import Multiyear Data History (Modifying CSVtoT6.c) - 07/28/17 14:15

Hi.

I am trying importing bulk EOD stock price data (e.g. 15 years of data for 100 stocks) into Zorro.

However as the manual says: "For converting price data from an external source to the Zorro format, separate it into years, convert it to a list of T6 or T1 structs, and store it in a binary file with the name described above."

I tried using CSVtoT6.c script. It worked for a single year, but not for multiyear data.

Therefore, in order to import my database, I need to run CSVtoT6.c script for 15x100=1500 files.

Would anybody help me for writing a lite-c script which:
- Performs a for loop
- At each iteration of the loop, it reads the names of available csv files within a specific folder
- And calls CSVtoT6.c for that csv file, by changing InName and OutName arguments of the c file

Thanks
Posted By: Ger1

Re: How To Import Multiyear Data History (Modifying CSVtoT6.c) - 06/11/18 05:24

Hi Alphatect,

I used below script. All you have to do is to create an assetList containing all of your stock symbols and save as csv. Afterwards change following line in below code.

assetList("HistorySP500AssetsSP500.csv");

This will convert all of your csv files into t6 very quickly.


#define SPLIT // split into separate years


string Format = "+%d/%m/%Y,f3,f1,f2,f4,f6,f5";

int n;

function convert(string InName, string OutName)
{
int Records = dataParse(n,Format,InName);
printf("n%d lines read",Records);

#ifndef SPLIT
if(Records) dataSave(n,OutName);
#else

int i, Start = 0, Year, LastYear = 0;
for(i=0; i<Records; i++)
{
Year = atoi(strdate("%Y",dataVar(n,i,0)));
if(!LastYear) LastYear = Year;
if(i == Records-1)
{ // end of file
LastYear = Year; Year = 0;
}
if(Year != LastYear)
{
string NewName = strf("%s_%4i.t6",strxc(OutName,'.',0),LastYear);
printf("n%s",NewName);
dataSave(n,NewName,Start,i-Start);
Start = i;
LastYear = Year;
}
}
#endif
}

function main()
{
int x = assetList("HistorySP500AssetsSP500.csv");
int i;
n=1;

for(i=0; i<x; i++)
{
string down = Assets[i];
convert(down,down);
n++;
}
}
© 2024 lite-C Forums