采用1秒周期进行高频下单,
2013-02-06 14:24:12.703 【后台】IF00 TSellShort 已成功触发下单操作 价格:0.000000 数量:5 类型:1 账户: 品种:IF00
2013-02-06 14:24:12.703 【后台】实际账户持仓 10
2013-02-06 14:24:12.704 【后台】下单已发送
2013-02-06 14:24:12.704 【后台】IF00 TBuy 已成功触发下单操作 价格:0.000000 数量:5 类型:1 账户: 品种:IF00
2013-02-06 14:24:12.705 【后台】下单已发送
2013-02-06 14:24:12.706 【下单】IF02 价0.000000 量5 买卖0 类型1 开平1 账户802507 Formula 1
2013-02-06 14:24:12.706 【下单】IF02 价0.000000 量5 买卖0 类型1 开平0 账户802507 Formula 1
2013-02-06 14:24:12.706 当前尚有未处理完事件 - 6021
2013-02-06 14:24:12.708 【后台】IF00 运行结束
为什么会显示价格为0?程序代码如下:
input:habove(3,0,100000,1),delay(120,0,1000,1),n(1,1,10,1),zyd(5,0,103,1),zsd(5,0,77,1),lots(5,0,100,1),maxlots(5,0,100,1),hd(40,1,100,1);
DATABASE('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\test.mdb');
DBTABLE('Select * From pursueextrem where stockcode = "IF"');
mark:=dbvalue('remark'); //从数据库中取值,用于标记之前是否有下单
//------------------------------开仓设置-------------------------
dk:=c>(ref(llv(l,80),1)+habove) and mark<=0 and tisprvremain(0)=0;
kk:=c<(ref(hhv(h,80),1)-habove) and mark>=0 and tisprvremain(0)=0;
//-----------------------------开仓下单---------------------------
if dk then
BEGIN
if mark<0 then
begin
tsellshort(1,lots,mkt);
end;
tbuy(1,lots,mkt);
DBEXECUTE('update pursueextrem set remark=1 where stockcode = "IF"');
end;
if kk then
BEGIN
if mark>0 then
begin
tsell(1,lots,mkt);
end;
tbuyshort(1,lots,mkt);
DBEXECUTE('update pursueextrem set remark=-1 where stockcode = "IF"');
end;
if tsubmit(1)>delay or tsubmit(3)>delay then
BEGIN
DBEXECUTE('update pursueextrem set remark=0 where stockcode = "IF"');
if TSUBMIT(1)>delay then TCANCEL(1,1); //开仓单120秒后未成交撤单
if tsubmit(3)>delay then tcancel(1,3);
end;
mark:=dbvalue('remark'); //从数据库中取值,用于标记之前是否有下单
//----------------------------------平仓-------------------------------------
//持多仓阶段的止损止盈
if mark>0 and tisprvremain(1)=0 then //mark>0 and tisprvremain(1)=0代表多单挂单成交
begin
if c>=(TENTERPRICE+zyd) then
begin
tsell(1,lots,mkt),ALLOWREPEAT;
DBEXECUTE('update pursueextrem set remark=0 where stockcode = "IF"');
end;
if c<=(tenterprice-zsd) then
begin
tsell(1,lots,lmt,tenterprice-zsd-hd*mindiff),ALLOWREPEAT;
DBEXECUTE('update pursueextrem set remark=0 where stockcode = "IF"');
end;
end;
//持空仓阶段的止损止盈
if mark<0 and tisprvremain(3)=0 then //mark<0 and tisprvremain(3)=0代表空单挂单成交
BEGIN
if c<=(tenterprice-zyd) then
BEGIN
tsellshort(1,lots,mkt);
DBEXECUTE('update pursueextrem set remark=0 where stockcode="IF"');
end;
if c>=(tenterprice+zsd) then
begin
tsellshort(1,lots,lmt,tenterprice+zsd+hd*mindiff);
DBEXECUTE('update pursueextrem set remark=0 where stockcode="IF"');
END;
end;
市价单下单价格就为0,系统就是这样设定的
关于市价单的下单价格原理,参考新手帖里面关于几个交易所市价单的下单原则