Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共4 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:写一个次主力合约

1楼
明心 发表于:2012/3/23 16:15:49
最近在研究跨期套利,想写一个次主力合约的数据输出,或者直接在指定板块新建一个“次主力”合约,写了好久还是没有搞定。高手们能指教一下吗?
2楼
明心 发表于:2012/3/23 16:18:20

Sub getcizhuli()

pz = "cu "'定义品种
pzzms = 2
sc = "sq" '定义市场
maxOpenint = 0
midOpenint = 0
minOpenint = 0


lxhy = pz&"00"
Set History = marketdata.GetHistoryData(lxhy,sc,5)
    Count = History.Count-1
    for i=0 to Count
    mxdate = History.Date(i)
    Openint = History.Openint(i)
   
    n = marketdata.GetReportCount(sc)
    For j = 0 To n - 1
        Set report1 = marketdata.GetReportDataByIndex(sc, j)
            If left(report1.Label,2) = pz  Then
               Set History1 = marketdata.GetHistoryData(report1.Label,sc,5)
                    Count1 = History1.Count-1         
                    for m=0 to Count1
                    date1 = History1.Date(m)
                        if date1=mxdate then
                           Openint1 = History1.Openint(m)
                          
                              if Openint1 > maxOpenint then
                              maxOpenint = Openint1
                              elseif  Openint1 > midOpenint then
                              midOpenint = Openint1
                              else
                              minOpenint = Openint1
                              end if
                          
                
                        end if
                    next
              'application.MsgOut mxdate&" "&report1.Label
            End If
          
    Next
   
    application.MsgOut mxdate&" "&midOpenint
    next


End Sub

 

以上红色部分数据输出有问题,请指教

 

3楼
solarhe2006 发表于:2020/7/21 14:50:56
次主力合约这么久也没搞出来?
4楼
solarhe2006 发表于:2020/7/25 18:11:49
Sub usgetdominantcontracts()
   On Error resume Next
    Dim block
    Dim market
   
    Set block = CreateObject("stock.block")
   
    For i = 0 To block.Count - 1
        block.removeat (0)
    Next
   
    'market = Array("CB","CM","NM","NB","HZ","SG")'外盘石油、黄金、股指期货
    market = Array("SQ","dq","zq","zj","IN")'添加原油
    c">    c">    contractopenint = 0
   
    For i = 0 To UBound(market)
        n = marketdata.GetReportCount(market(i))
        For j = 0 To n - 1
            Set report1 = marketdata.GetReportDataByIndex(market(i), j)
            suffixlabel = Right(report1.Label, 2)
           
            If suffixlabel = "00" Then
                block.addstock contractmarket, contractlabel
                c">                c">                contractopenint00 = report1.OpenInt
               
            End If
           
            If (suffixlabel >= "01" And suffixlabel <= "12")and (report1.OPENINT<contractopenint00) Then
                If report1.OPENINT > contractopenint00/5  Then
                    contractlabel = report1.Label
                    contractmarket = market(i)
                    contractopenint = report1.OPENINT

               End If
            End If
        Next
    Next
   
    block.addstock contractmarket, contractlabel
    block.tosave "自选","次主力合约"

     '打开市场指定分类名称的板块
     call block.open("次主力合约",0)
application.msgout Now&"  次主力合约筛选完毕"

End Sub
共4 条记录, 每页显示 10 条, 页签: [1]


Powered By Dvbbs Version 8.3.0
Processed in .01563 s, 2 queries.