Hello all! I am new to the community and developing my first python program to help me analyze stocks.
I am seeking to use TA-Lab and the very first thing I am using I am getting a strange error. Here's some background:
The dataframe (df) has the High, Low, Close, Open price data. I convert each pandas.series to a numpy.ndarray and store the data in the variables h, l, c, o as shown below:
h = df['HIGH'].to_numpy()
l = df['LOW'].to_numpy()
c = df['CLOSE'].to_numpy()
o = df['OPEN'].to_numpy()
I calculate the RANGE (which works great):
df['RANGE'] = df['HIGH'] - df['LOW']
And I attempt to use the TA Lib TRANGE function:
from talib.abstract import *
df['TRUE_RANGE'] = TRANGE(high=h, low=l, close=c)
The output error says:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-8-8cab3f3750b9> in <module>
--> 126 df['TRUE_RANGE'] = TRANGE(high=h, low=l, close=c)
talib/_abstract.pxi in talib._ta_lib.Function.__call__()
talib/_abstract.pxi in talib._ta_lib.Function.__call_function()
TypeError: Argument 'high' has incorrect type (expected numpy.ndarray, got NoneType)
I do verify that h is a numpy.ndarray:
type(h)
numpy.ndarray
So what am I doing wrong? Please help!