通过akshare获取ETF历史行情数据 采用plotly展示图形
代码:
import akshare as ak
import plotly.express as px
import plotly.graph_objects as go
jsj_etf = ak.fund_etf_hist_sina(symbol="sz159998")
fig = px.line(jsj_etf, x="date", y="close", title='计算机ETF')
fig.add_trace(go.Scatter(x=[jsj_etf['date'].iloc[-1]],
y=[jsj_etf['close'].iloc[-1]],
text=[jsj_etf['date'].iloc[-1]],
mode='markers+text',
marker=dict(color='red', size=10),
textfont=dict(color='green', size=10),
textposition='top left',
showlegend=False))
fig.add_trace(go.Scatter(x=[jsj_etf['date'].iloc[-1]],
y=[jsj_etf['close'].iloc[-1]],
text=[jsj_etf['close'].iloc[-1]],
mode='markers+text',
marker=dict(color='red', size=10),
textfont=dict(color='green', size=10),
textposition='bottom center',
showlegend=False))
fig.show()
输出:
标签:并用,text,jsj,color,etf,iloc,close,ETF,图形 From: https://blog.csdn.net/lildkdkdkjf/article/details/136845400