我正在尝试在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)
#Initialize the `signals` DataFrame with the `signal` column
signals = pd.DataFrame(index=aapl.index)
signals['signal'] = 0.0
#Create slow stochastics //**Broken**
signals['Slow Stochastics'] = ta.STOCH(aapl.High.values,aapl.Low.values,aapl.Close.values,fastk_period=5,slowk_period=3,slowk_matype=0,slowd_period=3,slowd_matype=0)