2

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

idjaw
  • 25,487
  • 7
  • 64
  • 83
user1859252
  • 21
  • 1
  • 2

1 Answers1

1

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.

ajsp
  • 2,512
  • 22
  • 34
  • 1
    Thanks for the help. FYI talib.abstract works with other functions but failed like this: talib.abstract.ADX(d.High.values,d.Low.values,d.Close.values,10) But this works: talib.ADX(d.High.values,d.Low.values,d.Close.values,10).... so thanks ajsp for the pointing me in the correct direction. – user1859252 Oct 17 '15 at 16:01