无法用VBA实现直接下单操作,可以间接做一些辅助的二次开发工作
但我用模拟账号,调用order对象,什么反应都没有,请问是什么原因?
下面这代码,开仓条件应该是恒成立的,但运行后什么反应都没
Sub TLStart()
call marketdata.RegReportNotify("IC00","ZJ")
call marketdata.RegReportNotify("IF00","ZJ")
End Sub
Sub MARKETDATA_ReportNotify()
Set Report1 = marketdata.GetReportData("IC00","ZJ")
Set Report2 = marketdata.GetReportData("IF00","ZJ")
msgbox Report1.SellPrice1
msgbox Report2.BuyPrice1
dim BuyHoding1
dim BuyHlding2
dim BuyTodayHoding1
dim BuyTodayHoding2
dim SellHoding1
dim SellHoding2
dim SellTodayHoding1
dim SellTodayHoding2
dim BuyCost
dim SellCost
dim PNL
Dim UseMargin
call Order.HoldingInfoByCode2("IC00","ZJ",BuyHoding1,BuyCost,BuyTodayHoding1,SellHoding1,SellCost,SellTodayHoding1,PNL,UseMargin)
call Order.HoldingInfoByCode2("IF00","ZJ",BuyHoding2,BuyCost,BuyTodayHoding2,SellHoding2,SellCost,SellTodayHoding2,PNL,UseMargin)
Diff = Report1.SellPrice1 - Report2.BuyPrice1 '分别取卖价和买价计算差价
if Diff > 2800 and BuyHoding1 = 0 then
call Order.Buy(0,1,Report1.SellPrice1,0,"IC00","ZJ","",0)
call Order.BuyShort(0,1,Report2.BuyPrice1,0,"IF00","ZJ","",0)
end if
Diff = Report1.BuyPrice1 - Report2.SellPrice1
if diff < 2800 and BuyHoding1 > 0 then
call Order.Sell(0,1,Report1.BuyPrice1,0,"IC00","ZJ","",0)
call Order.Sellshort(0,1,Report2.SellPrice1,0,"IF00","ZJ","",0)
end if
End Sub
Diff = Report1.BuyPrice1 - Report2.SellPrice1
application.msgout diff
if diff < 2800 and BuyHoding1 > 0 then
call Order.Sell(0,1,Report1.BuyPrice1,0,"IC00","ZJ","",0)
call Order.Sellshort(0,1,Report2.SellPrice1,0,"IF00","ZJ","",0)
end if
另一个贴中回复您了,类似这样自己做下调试输出,看下是不是条件不满足