以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  高级功能研发区  (http://weistock.com/bbs/list.asp?boardid=5)
----  如何枚举市场中的所有合约  (http://weistock.com/bbs/dispbbs.asp?boardid=5&id=1176)

--  作者:wattwei
--  发布时间:2010/3/21 16:31:07
--  如何枚举市场中的所有合约
 例如列出所有上期的合约
--  作者:admin
--  发布时间:2010/3/21 16:35:11
--  
此功能暂时没有,将做为升级事项,加入日后的升级版中
--  作者:admin
--  发布时间:2010/3/21 22:08:54
--  
已经写好,过几天的正式升级版将增加
--  作者:drzwz168
--  发布时间:2010/3/21 23:41:01
--  

似乎可暂时用这种方法列出合约代码?

 

Sub test1_CommandButton1_Click()
 dim str
 str=""
 set b=CreateObject("Stock.Block")
 if b.Open("上海期货",0)=1 then
  for i=0 to b.Count-1
   str=str & b.GetStockMarket(i) & b.GetStockCode(i) & vbcrlf
  next  
 end if
 msgbox str
End Sub


--  作者:王锋
--  发布时间:2012/8/8 9:34:58
--  

‘该示例从郑州市场筛选SR合约得最大持仓量做为主力合约

 Sub Test()
 
 Dim MaxCode
 Dim MaxVolume
 
 \'得到市场所有品种
 Count = MarketData.GetReportCount("ZQ")
 
 For i = 0 To Count-1
  Set Report1 = MarketData.GetReportDataByIndex("ZQ",i)
  \'只处理SR合约
  if Left(Report1.Label,2) = "SR" Then
   \'只处理有效合约
   if Right(Report1.Label,2) >= "01" And Right(Report1.Label,2) <= "12" Then
    If Report1.Volume > MaxVolume Then
     MaxCode = Report1.Label
     MaxVolume = Report1.Volume
    End if
   end if
  End if
 Next
 
 \'显示成交量最大得合约
 MsgBox MaxCode
 
End Sub