您现在的位置:程序化交易>> 期货公式>> 金字塔等>> 金字塔知识>>正文内容

通过vba可以查出来,连续合约是哪个具体的合约吗? [金字塔]

  • 咨询内容: 请教:通过vba可以查出来,连续合约是哪个具体的合约吗?

     

  • 金字塔客服: 做遍历即可查到

     

  • 用户回复:

    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对应的主力合约

     

 

有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友

可联系技术人员 QQ: 1145508240  点击这里给我发消息进行 有偿 编写!不贵!点击查看价格!


【字体: 】【打印文章】【查看评论

相关文章

    没有相关内容