使用从 yahoo finance 下载的 python pandas dataframe (d),其格式为:
日期、开盘价、最高价、最低价、收盘价、成交量、调整收盘价 2015-01-13,1.290,1.290,1.200,1.225,421600,1.225
我可以像这样成功地使用 talib 函数:
talib.abstract.EMA(d, timeperiod=8, price='Close')
talib.abstract.SMA(d, timeperiod=13, price='Close')
talib.abstract.RSI(d, timeperiod=25, price='Close')
根据文档 (http://mrjbq7.github.io/ta-lib/func_groups/momentum_indicators.html),它们采用以下形式:
real = XYZ(close, timeperiod=14)
然而,当尝试使用具有以下形式的 talib 函数时:
real = XYZ(high, low, close, timeperiod=14) such as the ADX I cant figure out the correct syntax needed.
我已经试过了:
talib.abstract.ADX(d,high='High',low='Low',close='Close',Timeperiod=10)
异常:input_arrays 参数缺少必需的数据键:high、low、close
还有这个:
talib.abstract.ADX(high=d.High,low=d.Low,close=d.Close,Timeperiod=10)
TypeError: only length-1 arrays can be converted to Python scalars
关于这个和其他具有多个输入参数的 talib python 包装器所需参数的正确格式的任何想法?
任何关于正确格式的帮助将不胜感激!!! 提前致谢
请您参考如下方法:
在某些情况下取决于数组的形状。如果您确实紧急需要该功能,只需从库中调用它即可:
import talib
import numpy as np
h = np.array(high)
l = np.array(low)
c = np.array(close)
output_atr = np.array(talib.ATR(h,l,c,14))
这很好用。
