sub exportdata()
markets=array("sq","dq","zq","zj","sy")
set block=createobject("stock.block")
set fso = createobject("scripting.filesystemobject")
futureday=base&"\\futureday\\"
futuremin=base&"\\futuremin\\"
futuretick=base&"\\futuretick\\"
createpath fso,futureday
createpath fso,futuremin
createpath fso,futuretick
for i=0 to ubound(markets)
for j=0 to marketdata.getreportcount(markets(i))-1
set myreport=marketdata.getreportdatabyindex(markets(i),j)
code=myreport.label
market=myreport.marketname
set myhistory = marketdata.gethistorydata(code,market,0)
if myhistory.count>0 then
set file = fso.createtextfile(futuremin&code&"_min.csv",true)
for n=0 to myhistory.count - 1
file.writeline myhistory.date(n)&","&myhistory.open(n)&","&myhistory.high(n)&","&myhistory.low(n)&","&myhistory.close(n)&","&myhistory.volume(n)&","&myhistory.openint(n)
next
file.close
end if
set myhistory = marketdata.gethistorydata(code,market,5)
if myhistory.count>0 then
set file = fso.createtextfile(futureday&code&"_day.csv",true)
for n=0 to myhistory.count - 1
file.writeline myhistory.date(n)&","&myhistory.open(n)&","&myhistory.high(n)&","&myhistory.low(n)&","&myhistory.close(n)&","&myhistory.volume(n)&","&myhistory.openint(n)
next
file.close
end if
set minutedata = marketdata.getminutedata(code,market)
if minutedata.count>0 then
mydate=convertdate(minutedata.date(n))
set file = fso.createtextfile(futuretick&code&"_tick_"&mydate&".csv",true)
for n=0 to minutedata.count - 1
file.writeline minutedata.date(n)&","&minutedata.newprice(n)&","&minutedata.bidprice(n)&","&minutedata.askprice(n)&","&minutedata.volume(n)&","&minutedata.bidvol(n)&","&minutedata.askvol(n)&","&minutedata.openint(n)
next
file.close
end if
next
next
print("导出数据")
end sub