Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Trading Journey
by howardR. 04/24/24 20:04
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (wandaluciaia, AndrewAMD, 1 invisible), 765 guests, and 6 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
How To Import Multiyear Data History (Modifying CSVtoT6.c) #467365
07/28/17 14:15
07/28/17 14:15
Joined: Jul 2017
Posts: 8
A
Alphatecht Offline OP
Newbie
Alphatecht  Offline OP
Newbie
A

Joined: Jul 2017
Posts: 8
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

Re: How To Import Multiyear Data History (Modifying CSVtoT6.c) [Re: Alphatecht] #473040
06/11/18 05:24
06/11/18 05:24
Joined: Mar 2017
Posts: 65
G
Ger1 Offline
Junior Member
Ger1  Offline
Junior Member
G

Joined: Mar 2017
Posts: 65
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++;
}
}


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1