|
Re: Could I use Zorro to test as an EOD?
[Re: boatman]
#453958
08/21/15 08:22
08/21/15 08:22
|
Joined: Jul 2000
Posts: 27,986 Frankfurt
jcl
Chief Engineer
|
Chief Engineer
Joined: Jul 2000
Posts: 27,986
Frankfurt
|
Here's a script for converting Yahoo data:
// generate data files from .csv
#define YAHOO
#ifdef YAHOO
string InName = "History\\table.csv"; // name of the CSV file
string OutName = "History\\Stock.bar";
#endif
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME;
API(SystemTimeToVariantTime,oleaut32)
int _stdcall SystemTimeToVariantTime(SYSTEMTIME* lpSystemTime, double* pvtime);
DATE ConvertTime(int Year,int Month,int Day,int Hour,int Minute,int Second)
{
SYSTEMTIME Time;
memset(&Time,0,sizeof(SYSTEMTIME));
if(Year < 50) Year += 2000;
else if(Year < 100) year += 1900;
Time.wYear = Year;
Time.wMonth = Month;
Time.wDay = Day;
Time.wHour = Hour;
Time.wMinute = Minute;
Time.wSecond = Second;
DATE vTime;
SystemTimeToVariantTime(&Time,&vTime);
return vTime;
}
string readTick(string content,TICK* tick)
{
// tokenize a single line
char* line = strtok(content,"\n");
if(!line) return 0;
int Year, Month, Day, Hour, Minute, Second;
#ifdef YAHOO // line format "2015-05-29,43.45,43.59,42.81,42.94,10901500,42.94"
if(7 != sscanf(line,"%4d-%2d-%2d,%f,%f,%f,%f",
&Year, &Month, &Day,
&tick->fOpen, &tick->fHigh, &tick->fLow, &tick->fClose))
return 0;
#endif
// store the time in DATE format
tick->time = ConvertTime(Year,Month,Day,0,0,0);
// return pointer to next line
return line+strlen(line)+1;
}
function main()
{
if(!file_length(InName))
quit("Data file not found!");
string content = file_content(InName);
// allocate TICK array
int maxticks = 60*24*365;
TICK* ticks = malloc(maxticks*sizeof(TICK));
#ifdef YAHOO
// skip the header
content = strstr(content,"\n")+1;
// already contains ticks in reverse order
TICK* tick = ticks;
while(content) {
content = readTick(content,tick++);
}
// store the ticks
int size = (int)(tick-1)-(int)(ticks);
file_write(OutName,ticks,size);
#endif
free(ticks);
printf("\nRead %d ticks",size/sizeof(TICK));
}
|
|
|
Re: Could I use Zorro to test as an EOD?
[Re: jcl]
#462186
09/13/16 10:34
09/13/16 10:34
|
Joined: Aug 2016
Posts: 61
dr_panther
Junior Member
|
Junior Member
Joined: Aug 2016
Posts: 61
|
Please help me to understand, how you "control" the Commission, from the AssetsIB.csv:
Name,Price,Spread,RollLong,RollShort,PIP,PIPCost,MarginCost,Leverage,LotAmount,Commission,Symbol
AAPL,118.44,0.01,0,0,0.01,0.009,0,4,1,0.02,
Doesn't that mean the Commission is 2 PIPs? But with Stocks the Commisisions should be a static value, not dependent on PIPs, or am I wrong? Eg, what happens with that configuration, if I have a penny stock and trade 10.000 of them?
|
|
|
|