无法使用plotly进行绘制。 (Python财务食谱)

问题描述 投票:0回答:2
import pandas as pd
import yfinance as yf
import cufflinks as cf
from plotly.offline import iplot, init_notebook_mode

df = yf.download('SPY',start='2019-01-01', end = '2020-04-20')

init_notebook_mode()
qf = cf.QuantFig(df, title='SPY Price', legend='top', name='SPY')
qf.add_volume()
qf.add_sma(periods=20, column='Close', color='red')
qf.add_ema(periods=20, color='green')

qf.iplot()

我收到的错误:PlotlyRequestError:未提供身份验证凭据。

python pandas plotly finance
2个回答
0
投票
我已经写了一个财务绘图库,可以完成您想要的工作:

import yfinance as yf import finplot as fplt df = yf.download('SPY',start='2019-01-01', end = '2020-04-20') fplt.create_plot('SPY Price') fplt.candlestick_ochl(df[['Open','Close','High','Low']]) fplt.plot(df.Close.rolling(20).mean(), color='#f00') fplt.plot(df.Close.ewm(span=20).mean(), color='#0f0') fplt.show()

经过优化,我经常用它来绘制500万个或更多的烛台。祝你好运!
© www.soinside.com 2019 - 2024. All rights reserved.