如何绘制图形以显示股票价格的移动平均值

时间:2019-06-12 06:13:43

标签: python-3.x analysis datareader python-ggplot

我正在尝试绘制matplotlib图以绘制股票的移动平均线 价格,但不起作用。

我已经编写了代码,但是我一直收到错误消息。

%matplotlib inline

import matplotlib.pyplot as plt

from matplotlib import style

# Adjusting the size of matplotlib

import matplotlib as mpl

mpl.rc('figure', figsize=(8, 7))

mpl.__version__

# Adjusting the style of matplotlib

style.use('ggplot')

close_px.plot(label='T')

mavg.plot(label='mavg')

plt.legend()

我希望看到移动平均线围绕实际股票摆动的图形

在x轴上显示日期,在y轴上显示频率的价格。

谢谢。

但是我收到以下错误消息:

ImportError                               Traceback (most recent call last)
<ipython-input-77-2fc08460da4d> in <module>

     10 # Adjusting the style of matplotlib

     11 style.use('ggplot')

---> 12 close_px.plot(label='T')

     13 mavg.plot(label='mavg')

     14 plt.legend()



----> 8 from pandas._libs.tslibs.frequencies import (

      9     FreqGroup, get_base_alias, get_freq, is_subperiod, is_superperiod)

     10 from pandas._libs.tslibs.period import Period

ImportError: cannot import name 'FreqGroup'

0 个答案:

没有答案