各位计算机配置不是太好的兄弟有幅了
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
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