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
w = 0
'计算该市场中该品种所有合约的持仓量
Set History = marketdata.GetHistoryData(lxLabel,market,CycType)
for k = 0 to History.Count-1
ccl = 0
lxdate = History.date(k)
close = History.close(k)
for w = 0 to Count-1
Set ReportData2 = MarketData.GetReportDataByIndex(market,w)
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) = lxdate then
' Openint = History1.Openint(i)
' end if
' next
' ccl = ccl+Openint
end if
next
History.Openint(k) = ccl
application.MsgOut lxdate&" "&close
' call History.SaveData(lxLabel,market,CycType)
next
application.MsgOut lxLabel&" "&lxStockName&" "&"持仓更新完毕!"
else
application.MsgOut "该周期没有数据需要更新!"
end if
End Sub
输出的数据有点问题,最后一段时间时间和数据怎么都为0呢,哪里错了,请指教
2010-4-22 3236.2
2010-4-19 3320
2010-4-20 3353
2010-4-21 3409
2010-4-22 3387.4
2010-4-23 3385
2010-4-26 3390.4
2010-4-27 3338.2
2010-4-28 3339.8
2010-4-29 3298.2
2010-4-30 3326.8
2010-5-4 3294
2010-5-5 3278
2010-5-6 3195
2010-5-7 3100
2010-5-10 3078
2010-5-11 2948.6
2010-5-12 2940
2010-5-13 2996.8
2010-5-14 2965.8
2010-5-17 2757
2010-5-18 2871.6
2010-5-19 2855
2010-5-20 2846.6
2010-5-21 2898.8
2010-5-24 3021.8
2010-5-25 2927.2
2010-5-26 2946.8
2010-5-27 3007
2010-5-28 2969.6
2010-5-31 2890.2
2010-6-1 2858.4
2010-6-2 2872.4
2010-6-3 2842.2
2010-6-4 2853.6
2010-6-7 2782
2010-6-8 2796
2010-6-9 2867.2
2010-6-10 2851
2010-6-11 2864.4
2010-6-17 2843.4
2010-6-18 2804.2
2010-6-21 2895.2
2010-6-22 2888.6
2010-6-23 2853.2
2010-6-24 2857
2010-6-25 2840
2010-6-28 2828
2010-6-29 2688.4
2010-6-30 2664.8
2010-7-1 2626.4
2010-7-2 2637
2010-7-5 2615.6
2010-7-6 2649
2010-7-7 2649.6
2010-7-8 2645.2
2010-7-9 2724.6
2010-7-12 2729
2010-7-13 2692.4
2010-7-14 2710.8
2010-7-15 2662
2010-7-16 2667.2
2010-7-19 2737.8
2010-7-20 2794
2010-7-21 2790.8
2010-7-22 2830
2010-7-23 2834
2010-7-26 2848
2010-7-27 2830
2010-7-28 2938
2010-7-29 2928.6
2010-7-30 2926.6
2010-8-2 2982.2
2010-8-3 2909.8
2010-8-4 2931
2010-8-5 2900.8
2010-8-6 2973
2010-8-9 2964.2
2010-8-10 2885.4
2010-8-11 2890.2
2010-8-12 2873
2010-8-13 2901
2010-8-16 2977
2010-8-17 3003.4
2010-8-18 2999.4
2010-8-19 3027.6
2010-8-20 2965.6
2010-8-23 2942
2010-8-24 2950
2010-8-25 2891
2010-8-26 2904
2010-8-27 2912
2010-8-30 2971.8
2010-8-31 2951.4
2010-9-1 2934.8
2010-9-2 2972.2
2010-9-3 2973.6
2010-9-6 3035.2
2010-9-7 3040
2010-9-8 3037.4
2010-9-9 2983
2010-9-10 2976
2010-9-13 3010
2010-9-14 3007
2010-9-15 2959.2
2010-9-16 2910.8
2010-9-17 2907
2010-9-20 2899
2010-9-21 2897.2
2010-9-27 2929
2010-9-28 2915
2010-9-29 2917
2010-9-30 2973.6
2010-10-8 3082.4
2010-10-11 3169.4
2010-10-12 3184.8
2010-10-13 3247
2010-10-14 3266.6
2010-10-15 3410.8
2010-10-18 3349.6
2010-10-19 3439.6
2010-10-20 3481.2
2010-10-21 3472.8
2010-10-22 3485
2010-10-25 3631.6
2010-10-26 3591.6
2010-10-27 3527.6
2010-10-28 3569.6
2010-10-29 3469.8
2010-11-1 3600.2
2010-11-2 3552
2010-11-3 3533
2010-11-4 3605
2010-11-5 3686.4
2010-11-8 3651
2010-11-9 3621.4
2010-11-10 3577
2010-11-11 3573.4
2010-11-12 3342.4
2010-11-15 3352.8
2010-11-16 3211.2
2010-11-17 3156
2010-11-18 3190.4
2010-11-19 3244
2010-11-22 3189
2010-11-23 3121.4
2010-11-24 3197.4
2010-11-25 3227.6
2010-11-26 3213
2010-11-29 3212
2010-11-30 3153.2
2010-12-1 3145.6
2010-12-2 3167.8
2010-12-3 3175
2010-12-6 3171
2010-12-7 3221.8
2010-12-8 3159.6
2010-12-9 3139.8
2010-12-10 3171.6
2010-12-13 3275.6
2010-12-14 3277.8
2010-12-15 3252.8
2010-12-16 3228.4
2010-12-17 3221.2
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
0:00:00 0
IF00 股指连续 持仓更新完毕!
我怀疑就这里面有问题,但不知道问题出在哪里
for w = 0 to Count-1
Set ReportData2 = MarketData.GetReportDataByIndex(market,w)
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) = lxdate then
' Openint = History1.Openint(i)
' end if
' next
' ccl = ccl+Openint
end if
next