import os, sys
from pyecharts import Kline
if len(sys.argv) ==2:
fcode = sys.argv[1]
else:
print('usage: kline1.py fcode ')
sys.exit(1)
if len(fcode) !=6:
print(' fcode is char(6)')
sys.exit(2)
file1 = 'M'+fcode +'.csv'
file2 = 'M'+fcode +'.html'
if not os.path.exists(file1):
print(file1 +' is not exists.')
sys.exit(3)
# 数据项: [open, close, lowest, highest] (即:[开盘值, 收盘值, 最低值, 最高值])
alist = []
vlist = []
fp = open(file1,'r')
fp.readline() # 跳过第1行表头: ym,open,close,low,high
for line in fp:
ym,open,close,low,high = line.strip().split(',')
alist.append(ym)
vlist.append([open,close,low,high])
print(str(len(alist)))
kline = Kline(fcode+" 月K线图")
kline.add(fcode, alist, vlist)
kline.render(path=file2)
参考 https://blog.csdn.net/qtlyx/article/details/85221503
分享到:
2019-02-10 18:51
浏览 936
评论