Python 绘制K线图
Python 的财经图表库比较少,毕竟Python 很少用于数据显示。我找来找去,发现只有plotly 绘制K线图相对比较简单。但是plotly的效果也比较简陋,不过够我用了。
import tdx
import plotly.offline as pyo
import plotly.graph_objects as go
df = tdx.读取日线数据(r'C:\zd_gszq\vipdoc\sh\lday\sh600025.day')
fig = go.Figure(data=[go.Candlestick(x=df.index,
open=df['Open'],
high=df['High'],
low=df['Low'],
close=df['Close'])])
pyo.plot(fig,show_link=True)
# fig.show()
关于Python如何读取通达信数据,请参考https://www.cwyyprog.com/2020/03/14/python%e8%af%bb%e5%8f%96%e5%b9%b6%e8%a7%a3%e6%9e%90%e9%80%9a%e8%be%be%e4%bf%a1%e6%95%b0%e6%8d%ae%e6%96%87%e4%bb%b6/
生成的K线图效果如下: