后台程序化交易 逐k线模式 间隔1s轮循
我程序里写了一段止损的代码
止损部分代码如下
if c<stoplong and notrade>0 then
begin
if notrade=2 then
begin
tsell(1,hands,LMT,close-1);
debugfile('c:\weistock_log.txt','zhiduo2 stoplong %f',stoplong);
debugfile('c:\weistock_log.txt','zhiduo2 close %f',c);
notrade:=3;
end
if notrade=1 then
begin
tsell(1,hands1,LMT,close-1);
debugfile('c:\weistock_log.txt','zhiduo1 stoplong %f',stoplong);
debugfile('c:\weistock_log.txt','zhiduo1 close %f',c);
notrade:=3;
end
end
log结果如下:
2012-10-24 11:15:33.202 stoplong1 2323.523951
2012-10-24 11:15:33.202 notrade 1.000000
2012-10-24 11:15:33.202 stoplong 2323.523951
2012-10-24 11:15:33.202 stopshort 100000.000000
2012-10-24 11:15:33.202 close 2335.199951
可以看到notrade是等于1的 并且c<stoplong是不满足的
2012-10-24 11:15:34.730 notrade 3.000000
2012-10-24 11:15:34.731 stoplong 2323.523951
2012-10-24 11:15:34.731 stopshort 100000.000000
2012-10-24 11:15:34.731 close 2335.199951
但是到下一秒notrade变成3了
其他任何地方都没有notrade变成3的可能
请问是怎么回事
因为notrade变成3导致止损失败了好几次
希望找到问题到底在哪里
结尾有一段收盘前清仓的代码 但是time>151300更不可能满足了
其他地方都没有notrade:=3的语句
if time>=151300 then
begin
if notrade=2 then
begin
tsell(1,hands,LMT,close-1);
end
tsell(TBUYHOLDING(0)>0,0,LMT,close-1);
tsellshort(TSELLHOLDING(0)>0,0,LMT,close-1);
notrade:=3;
end
我只能给到邮件里这么多了
我感觉就是程序bug
不管怎么运行 都不可能从notrade=1直接跳到notrade=3却没有在log里有记录的
哥们
你觉得我还能用什么调试方法?
debugfile把所有的变量都打印出来了
还能咋办
程序化交易你们提供的调试机制就是debugout debugfile两种
还能怎么调试
你要是仔细看过我发给你的邮件
你就能看出来
notrade:=3只有3句
两句是和debugfile在一起的 log里没有输出 所以应该不可能是这里出现的吧
最后一个是在if time>151300 下面的,如果上午走到这句里面了也不可能吧
那只能是程序bug了
如果你看不懂就转给你们研发部门的同事看一下
做客服要尽职尽责 别敷衍
反正是按交易量抽手续费的
大不了换TB交易