Sub ORDER_OrderStatusEx2(OrderID, Status, Filled, Remaining, Price, Code, Market, OrderType, Aspect, Kaiping, Account, AccountType)
application.msgout("调用成功!"&Code&":"&Status)
if Code=cizhuliheyue then
application.MsgOut("次主力合约交易动向!")
Select Case Status
Case "Inactive"
tradeflag=1
Case "Submitted"
tOrderTime=now()
application.msgout("Submitted!")
tradeflag=0
application.MsgOut("tradeflag="&tradeflag)
exitflag=0
Ms=0
timeflag=Ms-waitingtime
do while exitflag=0 and timeflag<0
Ms=DateDiff("s",CDate(tOrderTime),Cdate(now()))
timeflag=Ms-waitingtime
if kongzhiflag=1 then
update=abs(Price-zhuliprice)-shedingjicha+(huandiannumber+plustick)*MinTick
else
update=abs(Price-zhuliprice)-shedingjicha-(huandiannumber+plustick)*MinTick
end if
if ((update<0 and kongzhiflag=1) or (update>0 and kongzhiflag=0)) and Remaining>0 then//等待时间之内设定撤单条件
order.CancelOrder(OrderID)
huanyue_ts1.AddItem time()& cizhuliheyue&" 不符合条件,准备撤单 "&OrderID
exit do
end if
application.msgout("Remaining="&Remaining)
if Remaining=0 then//若成交,则exit
exitflag=1
exit do
end if
loop
application.MsgOut("exitflag1=")
application.MsgOut(exitflag)
if exitflag=0 then
huanyue_ts1.AddItem time()& cizhuliheyue&"委托超时, 准备撤单 "&OrderID
order.CancelOrder(OrderID)
end if
Case "Filled" \'then\'(Status="Tradeing" and Filled>0) or Status="Filled" then
application.msgout("成交了次主力合约!"&OrderID)
if zhi<=0 then
sellid=Order.buyshort(0, 1,zhuliprice-100,0,zhuliheyue,marketzhuli,"",0)
huanyue_ts1.AddItem time()& zhuliheyue&" 自动发出移仓"&sellid&" 买入空仓指令 "&"价格为"&zhuliprice
else
sellid=Order.sell(0, 1,zhuliprice-100,0,zhuliheyue,marketzhuli,"",0)
huanyue_ts1.AddItem time()& zhuliheyue&" 自动发出移仓"&sellid&" 卖出平仓指令 "&"价格为"&zhuliprice
end if
jiaoyicitemp=jiaoyicitemp+1
tradeflag=1
case "Cancelled"
huanyue_ts1.AddItem time()& cizhuliheyue&"撤单成功 "&OrderID
tradeflag=1
CancelNum=CancelNum+1
End Select
end if
end sub