以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  高级功能研发区  (http://weistock.com/bbs/list.asp?boardid=5)
----  单个品种周期持仓量汇总  (http://weistock.com/bbs/dispbbs.asp?boardid=5&id=4985)

--  作者:明心
--  发布时间:2011/1/25 16:12:25
--  单个品种周期持仓量汇总

各位计算机配置不是太好的兄弟有幅了

 

Sub lianxuchicang()
    \' 得到框架名称为"Technic",窗格名称为"Main"的窗格对象
    Set Grid = Technic.GetGridByName("Main")
    Market = Grid.Market
    StockName = Grid.StockName
    StockLabel = Grid.StockLabel
    CycType = Grid.CycType
    lenname = len(StockName)
    name = left(StockName,2)

 

if CycType=5 then \'根据自己需要修改,一般的为0、1、5
    
    \'寻找该品种连续合约
    Count = MarketData.GetReportCount(market)
    for w =0 to Count-1
        Set ReportData1 = MarketData.GetReportDataByIndex(market,w)
        if right(reportData1.Label,2) ="00" and  left(reportData1.StockName,2) = name  then
        lxLabel = reportData1.Label
        lxStockName = reportData1.StockName
        \'application.MsgOut lxLabel&" "&lxStockName
        end if      
    next
    \'计算该市场中该品种所有合约的持仓量
    Set History = marketdata.GetHistoryData(lxLabel,market,CycType)
            for k = 0 to History.Count-1
                date1 =  History.date(k)
               if Right(ReportData1.Label,2) >= "01" And Right(ReportData1.Label,2) <= "12" and  left(reportData1.StockName,2) =

name Then
                  Set History1 = marketdata.GetHistoryData(ReportData1.Label,market,CycType)
                      for i = 0 to History1.Count-1
                         if History1.Date(i) = date1  then
                            Openint = History1.Openint(i)
                           ccl = ccl+Openint
                         end if
                     next
               end if
               History.Openint(k) = ccl
               call History.SaveData(lxLabel,market,CycType)
           next
    application.MsgOut lxLabel&" "&lxStockName&" "&"持仓更新完毕!"
else
    application.MsgOut "该周期没有数据需要更新!"
end if
End Sub

[此贴子已经被作者于2011-1-25 16:13:34编辑过]

--  作者:明心
--  发布时间:2011/1/25 16:13:00
--  
要求加精给金币。图片点击可在新窗口打开查看
--  作者:明心
--  发布时间:2011/1/25 17:02:17
--  

Sub lianxuchicang()
    \' 得到框架名称为"Technic",窗格名称为"Main"的窗格对象
    Set Grid = Technic.GetGridByName("Main")
    Market = Grid.Market
    StockName = Grid.StockName
    StockLabel = Grid.StockLabel
    CycType = Grid.CycType
    lenname = len(StockName)
    name = left(StockName,2)

if CycType = 5 then
   
    \'寻找该品种连续合约
    Count = MarketData.GetReportCount(market)
    for w =0 to Count-1
        Set ReportData1 = MarketData.GetReportDataByIndex(market,w)
        if right(reportData1.Label,2) ="00" and  left(reportData1.StockName,2) = name  then
        lxLabel = reportData1.Label
        lxStockName = reportData1.StockName
        application.MsgOut lxLabel&" "&lxStockName
        end if      
    next
    \'计算该市场中该品种所有合约的持仓量
    Set History = marketdata.GetHistoryData(lxLabel,market,CycType)
            for k = 0 to History.Count-1
                date1 =  History.date(k)
                Count1 = MarketData.GetReportCount(market)
                for q = 0 to Count1-1
                Set ReportData2 = MarketData.GetReportDataByIndex(market,q)
                    if Right(ReportData2.Label,2) >= "01" And Right(ReportData2.Label,2) <= "12" and  left(reportData2.StockName,2) = name Then
                       Set History1 = marketdata.GetHistoryData(ReportData2.Label,market,CycType)
                           for i = 0 to History1.Count-1
                              if History1.Date(i) = date1  then
                                 Openint = History1.Openint(i)
                                 ccl = ccl+Openint
                             end if
                           next
                    end if
               next
               History.Openint(k) = ccl
               call History.SaveData(lxLabel,market,CycType)
           next
    application.MsgOut lxLabel&" "&lxStockName&" "&"持仓更新完毕!"
else
    application.MsgOut "该周期没有数据需要更新!"
end if
End Sub


--  作者:明心
--  发布时间:2011/1/25 17:03:02
--  
修改后还是不行。网高手指教。3楼只最新的。