收盘价对时间t的线性回归预测值
df['linearreg']=ta.LINEARREG(df.close, timeperiod=14)
# 收盘价对时间t的线性回归预测值
df['linearreg'] = ta.LINEARREG(df.close, timeperiod=14)
# 时间序列预测值
df['tsf'] = ta.TSF(df.close, timeperiod=14)
df['stdev'] = ta.STDDEV(df.close, timeperiod=5, nbdev=1)
# 画图
# df.loc['2020-01-01':, ['close', 'linearreg', 'tsf']].plot(figsize=(20, 10))
df.loc['2020-01-01':, ['close', 'linearreg', 'tsf', 'stdev']].plot(figsize=(18, 8),
subplots=True, layout=(2, 2))
plt.subplots_adjust(wspace=0, hspace=0.2)