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:未提供身份验证凭据。
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万个或更多的烛台。祝你好运!