Function GetContractCode(sMarketCode,sStockPre) '根据市场编码取得主力合约编码
GetCAX" then sStockPre="AY"
if sStockPre="SRX" then sStockPre="SRY"
For j = 1 To 12
if j<10 then
m="0" & cstr(j)
else
m=cstr(j)
end if
Stock=ucase(sStockPre & m)
'application.MsgOut sMarketCode & "," & Stock
on error resume next
' Set report1 = marketdata.GetReportData(Stock,sMarketCode)
' if cdbl(report1.volume)>contractvolume then
' contractvolume=cdbl(report1.volume)
' ZhuLiCode = report1.Label
' end if
if marketdata.IsExistStock(Stock,sMarketCode) then
set report1=marketdata.GetReportData(Stock,sMarketCode)
if report1.IsMainInstrument=1 then
GetContractCode=Stock
exit function
end if
end if
Next
End Function
以上函数返回主力合约代码,调用方法是:aaa=GetContractCode("ZJ","IF00"),aaa就是IF对应的主力合约