Dim ID1
Sub TLStart()
\'注册CF09和CF11品种
call marketdata.RegReportNotify("CU05","SQ")
call marketdata.RegReportNotify("AL05","SQ")
End Sub
\'响应注册的品种行情变化通知
Sub MARKETDATA_ReportNotify(ReportData)
\'得到这两个品种的行情报价
Set Report1 = marketdata.GetReportData("CU05","SQ")
Set Report2 = marketdata.GetReportData("AL05","SQ")
\'得到品种的持仓量等信息
dim BuyHoding1
dim BuyHlding2
dim BuyTodayHoding1
dim BuyTodayHoding2
dim SellHoding1
dim SellHoding2
dim SellTodayHoding1
dim SellTodayHoding2
dim BuyCost
dim SellCost
dim PNL
Dim UseMargin
Dim cs1
\'取指定持仓品种信息
call Order.HoldingInfoByCode2("CU05","SQ",BuyHoding1,BuyCost,BuyTodayHoding1,SellHoding1,SellCost,SellTodayHoding1,PNL,UseMargin)
call Order.HoldingInfoByCode2("AL05","SQ",BuyHoding2,BuyCost,BuyTodayHoding2,SellHoding2,SellCost,SellTodayHoding2,PNL,UseMargin)
num = ORDER.ORDERNUM2
\'当差价出现大于1800时进行套利开仓
Diff = Report1.SellPrice1 - Report2.BuyPrice1 \'分别取卖价和买价计算差价
application.MsgOut TIME&", "&Report1.SellPrice1&", "&Report2.BuyPrice1&", "&Diff
if Diff < 33315 then
CS1= CS1+1
End if
if CS1=1 then
ID1 = Order.Buy(0,1,46100,0,"CU05","SQ","",0)
ID2 = Order.BuyShort(1,1,Report2.BuyPrice1,0,"AL05","SQ","",0)
application.MsgOut TIME&", "&ID1&","&ID2
end if
application.MsgOut CS1
End Sub