以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  高级功能研发区  (http://weistock.com/bbs/list.asp?boardid=5)
----  建议:打开了允许主力连续合约下单交易时,Code对应返回主力合约编码  (http://weistock.com/bbs/dispbbs.asp?boardid=5&id=6163)

--  作者:guotx2010
--  发布时间:2011/4/15 14:52:56
--  建议:打开了允许主力连续合约下单交易时,Code对应返回主力合约编码

建议:打开了允许主力连续合约下单交易时,Code对应返回主力合约编码:

现在的情况是:勾选了“下单设置”下的“允许主力连续合约下单交易”,使用VBA后台交易,可以开单,但是查询持仓情况时,因为这时的品种代码是IF00(以股指为例),结果查不到持仓,应该是自动返回当前的主力合约编码,比如,今天的,应该返回IF05。

 

或者:增加一个VBA函数,通过这个函数可以返回连续合约的对应主力合约编码。

 

 


--  作者:王锋
--  发布时间:2011/4/15 15:21:06
--  

后面检查一下代码


--  作者:guotx2010
--  发布时间:2011/4/15 15:33:29
--  

我增加了一段代码,用于获取主力合约

这样就可以了,但是如果金字塔能直接处理这个问题就更好了。

 

Sub GetContractCode(sMarketCode)    \'根据市场编码取得主力合约编码
 If sMarketCode="" then
  sMarketCode="ZJ"
 End if 
 
 contractvolume = 0
  
 n = marketdata.GetReportCount(sMarketCode)
 For j = 0 To n - 1
  Set report1 = marketdata.GetReportDataByIndex(sMarketCode, j)
  suffixlabel = Right(report1.Label, 2)

  If suffixlabel = "00" Then
   contractvolume = 0
  End If

  If suffixlabel >= "01" And suffixlabel <= "12" Then
   If report1.volume > contractvolume Then
    contractlabel = report1.Label
    contractvolume = report1.volume
   End If
  End If
 Next

 If  Contractlabel<>"" and Right(Contractlabel,2)<>"00" then
  VBA_Code=Contractlabel                \'这就是我要的品种代码。
 End if
End Sub


--  作者:三人行必有师
--  发布时间:2011/4/19 10:37:33
--  
学习