Using python pandas dataframe (d) downloaded from yahoo finance which has the format:
Date,Open,High,Low,Close,Volume,Adj Close 2015-01-13,1.290,1.290,1.200,1.225,421600,1.225
I can successfully use talib functions like this:
talib.abstract.EMA(d, timeperiod=8, price='Close')
talib.abstract.SMA(d, timeperiod=13, price='Close')
talib.abstract.RSI(d, timeperiod=25, price='Close')
From the documentation ( http://mrjbq7.github.io/ta-lib/func_groups/momentum_indicators.html ) they take the form:
real = XYZ(close, timeperiod=14)
However when trying to use the talib functions with the form:
real = XYZ(high, low, close, timeperiod=14) such as the ADX I cant figure out the correct syntax needed.
I've tried this:
talib.abstract.ADX(d,high='High',low='Low',close='Close',Timeperiod=10)
Exception: input_arrays parameter missing required data keys: high, low, close
and this:
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
Any ideas on the correct format for the parameters needed for this and the other talib python wrappers that have more than one input parameter ?
Any help on the correct format would be greatly appreciated !!! Thanks in advance
Depends on the shape of your arrays in some cases. If you really need the function as a matter of urgency, just call it from the library:
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))
This works fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.