gpt4 book ai didi

c# - 如何从 Amibroker 持续导出数据

转载 作者:行者123 更新时间:2023-11-28 00:11:47 24 4
gpt4 key购买 nike

需要测试用于日内交易的算法交易工具。从 NSE 获取当日实时数据, 一些 vendors正在销售 Amibroker 的数据插件.要从 Amibroker 中获取数据,我打算使用 AFL(Amibroker 公式语言)。以下codeAFL 中为每个符号创建一次 .csv 文件。但是要使用实时数据,我需要全天不断地将传入数据附加到 .csv 文件。如何在不使 Amibroker 崩溃/重载的情况下做到这一点?

// created a directory on your C drive named AmiBroker data backup
dayhours = paramtoggle("Day hours only", "No|Yes");
fmkdir("c:\\AmiBackup\\");
setbarsrequired(100000,100000);
lname = Name(); // gets the name of the symbol
// note: if you have names with invalid characters like / you must rename the
file before you try to create a name
// add an IF line for each symbol you need to rename
if (lname == "ER2U8-GLOBEX-FUT") lname = "ER2U8";

fh = fopen( "c:\\AmiBackup\\" + lname + ".csv", "w");
if( fh )
{
if(interval() == inDaily OR interval() == inMonthly OR interval() == inweekly)
{
fputs( "Ticker,Date,Open,High,Low,Close,Volume \n", fh );
for( i = 0; i < BarCount; i++ )
{
y = Year();
m = Month();
d = Day();
fputs( Name() + "," , fh );
ds = StrFormat("%02.0f-%02.0f-%02.0f,", m[ i ], d[ i ], y[ i ] );
fputs( ds, fh );
qs = StrFormat("%.4f,%.4f,%.4f,%.4f,%.0f\n", O[ i ],H[ i ],L[ i ],C[ i
],V[ i ] );
fputs( qs, fh );
if(i == 65500 or i == 130000 or i == 196500 or i == 262000)
{
fclose( fh );
if(i == 65500 ) fh = fopen( "c:\\AmiBackup\\" + lname + " A.csv", "w");
if(i == 130000 ) fh = fopen( "c:\\AmiBackup\\" + lname + " B.csv", "w");
if(i == 196500 ) fh = fopen( "c:\\AmiBackup\\" + lname + " C.csv", "w");
if(i == 262000 ) fh = fopen( "c:\\AmiBackup\\" + lname + " D.csv", "w");
}
}
}
else // intraday so add time field
{
fputs( "Ticker,Date,Time,Open,High,Low,Close,Volume \n", fh );
y = Year();
m = Month();
d = Day();
r = Hour();
e = Minute();
n = Second();

for( i = 1; i < BarCount; i++ )
{
if (dayhours and lastvalue(timenum()) >= 92900 and lastvalue(timenum()) <=
161500)
{
fputs( Name() + "," , fh );
ds = StrFormat("%02.0f-%02.0f-%02.0f,", m[ i ], d[ i ], y[ i ] );
fputs( ds, fh );

ts = StrFormat("%02.0f:%02.0f:%02.0f,", r[ i ],e[ i ],n[ i ] );
fputs( ts, fh );

qs = StrFormat("%.4f,%.4f,%.4f,%.4f,%.0f\n", O[ i ],H[ i ],L[ i ],C[ i
],V[ i ] );
fputs( qs, fh );
}
else
{
fputs( Name() + "," , fh );
ds = StrFormat("%02.0f-%02.0f-%02.0f,", m[ i ], d[ i ], y[ i ] );
fputs( ds, fh );

ts = StrFormat("%02.0f:%02.0f:%02.0f,", r[ i ],e[ i ],n[ i ] );
fputs( ts, fh );

qs = StrFormat("%.4f,%.4f,%.4f,%.4f,%.0f\n", O[ i ],H[ i ],L[ i ],C[ i
],V[ i ] );
fputs( qs, fh );
}
if(i == 65500 or i == 130000 or i == 196500 or i == 262000)
{
fclose( fh );
if(i == 65500 ) fh = fopen( "c:\\AmiBackup\\" + lname + " A.csv", "w");
if(i == 130000 ) fh = fopen( "c:\\AmiBackup\\" + lname + " B.csv", "w");
if(i == 196500 ) fh = fopen( "c:\\AmiBackup\\" + lname + " C.csv", "w");
if(i == 262000 ) fh = fopen( "c:\\AmiBackup\\" + lname + " D.csv", "w");
}
}
}
fclose( fh );
}

Buy = 1;

最佳答案

您似乎一直在向服务器请求有关 100.000 个柱的数据,而它只需要最后一个。

我将创建此概览一次,如果已完成,则在代码中设置一个标志,完成后仅通过向后迭代更新数据,直到接收到的 barOpen 时间等于概览中已有的柱。

关于c# - 如何从 Amibroker 持续导出数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32665401/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com