我正在尝试使用 TA-Lib 获取股票交易量的移动平均线,但出现上述错误。对于如何解决这个问题,有任何的建议吗?谢谢!
请参见下面的代码:
import pandas_datareader as pdr
import datetime
import pandas as pd
import numpy as np
import talib as ta
#Download Data
aapl = pdr.get_data_yahoo('AAPL', start=datetime.datetime(2006, 10, 1), end=datetime.datetime(2012, 1, 1))
#Saves Data as CSV on desktop
aapl.to_csv('C:\\Users\\JDOG\\Desktop\\aapl_ohlc.csv', encoding='utf-8')
#Save to dataframe
df = pd.read_csv('C:\\Users\JDOG\\Desktop\\aapl_ohlc.csv', header=0, index_col='Date', parse_dates=True)
twenty_ma = 20
signals = pd.DataFrame(index=aapl.index)
signals['signal'] = 0.0
signals['20 MA'] = ta.SMA(aapl.Volume.values,twenty_ma)