图表交易,每次发出信号时,即时写入一个txt文件,按以下格式。
感觉应该是用debugfile函数,但研究了半天不会写。(最后一栏是策略名称)
[orders]
20160114-14.45 [开多]=[rb1605] [1] [TPIF01]
20160112-9.15 [开空]=[pp1605] [1] [TPIF01]
20160113-9.45 [开空]=[SR1605] [3] [SP_063_178]
20160112-22.45 [开多]=[ZC1605] [1] [TPIF01]
20160113-9.15 [平多]=[ZC1605] [1] [TPIF01]
20160113-9.3 [开空]=[ZC1605] [1] [TPIF01]
20160114-10.45 [平空]=[jd1605] [1] [TPIF01]
20160112-14.3 [开空]=[rb1605] [1] [TPIF01]
20160112-21.15 [平空]=[ru1605] [1] [TPIF01]
20160112-10 [开多]=[m1605] [1] [TPIF01]
20160111-14.45 [开空]=[IC1602] [1] [TPIF01]
20160114-14.45 [开多]=[rb1605] [1] [TPIF01]
请解释一下这里每个元素的意思
20160114-14.45 [开多]=[rb1605] [1] [TPIF01] |
一共六个元素
1、日期 2、时间(小时和分钟,中间用小数点隔开) 3、动作属性(开多、平多、开空、平空) 4、交易合约名称 5、手数 6、策略名称
一定要按照模板的细节格式写。谢谢
t1:=date+19000000;
t2:=floor(time/10000);
t3:=floor((time-floor(time/10000)*10000)/100);
if 开多条件 and holding=0 then begin
开多语句;
debugfile('d:\test.txt',numtostr(t1,0)+'-'+numtostr(t2,0)+'.'+numtostr(t3,0)+' [开多=] ['+stklabel+'] [%.0f] [tpif01]',entervol);
end
if 开空条件 and holding=0 then begin
开空语句;
debugfile('d:\test.txt',numtostr(t1,0)+'-'+numtostr(t2,0)+'.'+numtostr(t3,0)+' [开空=] ['+stklabel+'] [%.0f] [tpif01]',entervol);
end
策略名称需要自行指定,不能用代码替代
运行了一下,结果如下
2016-05-30 11:18:30.024 20160530-11.18 [平多]= [RB00] [1] [tpif01]
2016-05-30 11:18:30.025 20160530-11.18 [开空]= [RB00] [1] [tpif01]
前面两列是多余的,怎么去掉?