\'-------------------------------------------------------------K开始---------------------------------------------------
dim qj
qj=0
dim StartIndex
StartIndex = 0
dim minuteout\'
minuteout = 0
dim timeString
timeString=""
dim KstartTime
KstartTime =0
dim shanchu
shanchu=1
dim dangtianshuju \'当日是否有数据,0为没有
dangtianshuju = 0
dim bili
bili = 0.002
dim xinheyue
xinheyue = "IF88"
dim xinmingcheng
xinmingcheng = "IFK线"
dim xinshichang
xinshichang = "ZJ"
dim laoheyue
laoheyue = "IF00" \'标的合约代码
dim laoshichang
laoshichang = "ZJ" \'标的合约市场
dim laozhishu
laozhishu = "IF13"
dim laoheyueStartDate
laoheyueStartDate = laoheyue+"StartDate" \'
dim laoheyueDataCount
laoheyueDataCount = laoheyue+"DataCount" \'
dim newKOpen\'
newKOpen=0
dim newKClose\'
newKClose=0
dim newKHigh\'
newKHigh=0
dim newKLow\'
newKLow=0
dim newKVolume
newKVolume=0
dim mxVolume\'
mxVolume=0
dim newKDate\'
newKDate=0
dim newkOpenInt\'
newkOpenInt=0
dim PKOpenP
dim PKClose
dim PKHigh
dim PKLow
dim PKVolume
dim PKDate
dim PKOpenInt
Sub lishishuju()
\'查询品种是否存在,不存在则新建
cunzai = marketdata.IsExistStock(xinheyue,xinshichang)
if cunzai = 0 then
call marketdata.AddStock(xinheyue,xinshichang, xinmingcheng)
else
\'call marketdata.DeleteStock(xinheyue,xinshichang)
\'call marketdata.AddStock(xinheyue,xinshichang, xinmingcheng)
end if
\'删除历史数据,创建第一根K线
if shanchu = 0 then
Set History1 =marketdata.GetHistoryData(xinheyue,xinshichang,0)
for j = 0 to History1.Count-1
History1.RemoveAt(j)
next
call History1.SaveData(xinheyue,xinshichang,1)
application.MsgOut
end if
\'+++++++++++++++++++更新新合约的历史数据++++++++++++++++++++++++++
VarStartDate=Document.GetExtString(laoheyueStartDate)\'取存储的老合约1分钟数据的0号数据的时间
VarDataCount=Document.GetExtData(laoheyueDataCount)\'取储的新合约1分钟数据的数据的个数
Set History00=marketdata.GetHistoryData(laoheyue,laoshichang,0)\'取老合约1分钟数据
Hs00PosDate=History00.date(0)\'按时间取老合约1分钟数据的,看是否为0号数据
Hs00DataCount=History00.count\'取老合约1分钟数据的数据的个数
application.MsgOut "instr(VarStartDate,Hs00PosDate) <>0 or VarDataCount<>Hs00DataCount【创建成功】CStr(History00.Count)" +CStr(History00.Count)
Set PKOpen=CreateObject("Stock.Array")
Set PKClose=CreateObject("Stock.Array")
Set PKHigh=CreateObject("Stock.Array")
Set PKLow=CreateObject("Stock.Array")
Set PKVolume=CreateObject("Stock.Array")
Set PKDate=CreateObject("Stock.Array")
Set PKOpenInt=CreateObject("Stock.Array")
h00=History00.Count-1
for i = 0 to H00
PKOpen.AddBack(History00.Open(i))
PKClose.AddBack(History00.close(i))
PKHigh.AddBack(History00.high(i))
PKLow.AddBack(History00.low(i))
PKVolume.AddBack(History00.Volume(i))
PKDate.AddBack(History00.date(i))
PKOpenInt.AddBack(History00.OpenInt(i))
if i=h00 then
\'加载当天分时数据
for j = KstartTime to mc-2
PKOpen.AddBack(minutedata.Open(j))
PKClose.AddBack(History00.close(j))
PKHigh.AddBack(minutedata.high(j))
PKLow.AddBack(minutedata.low(j))
PKVolume.AddBack(minutedata.Volume(j))
PKDate.AddBack(minutedata.date(j))
PKOpenInt.AddBack(minutedata.OpenInt(j))
next
end if
Next