ta-lib-python icon indicating copy to clipboard operation
ta-lib-python copied to clipboard

expected numpy.ndarray, got numpy.float64

Open alizain5693 opened this issue 4 years ago • 1 comments

I keep getting this error when using the candle stick patterns in talib. I'm passing in just float values and they should work fine. i tried typecasting them to nd arrays before passing but that didn't help. also I don't understand why the candle stick functions need nd arrays if they are asking for 4 o,h,l,c values. please help.

//Traceback Traceback (most recent call last): File "C:\Users\aliza\AppData\Local\Programs\Python\Python39\lib\site-packages\backtesting\backtesting.py", line 125, in I
value = func(*args, **kwargs) File "C:\Users\aliza\Documents\CexTrading\bybit-heikin-ashi\testingback.py", line 63, in bullish return talib.CDLHAMMER(o,h,l,c) .py", line 152, in stats = bt.run() File "C:\Users\aliza\AppData\Local\Programs\Python\Python39\lib\site-packages\backtesting\backtesting.py", line 1134, in run
strategy.init() File "C:\Users\aliza\Documents\CexTrading\bybit-heikin-ashi\testingback.py", line 117, in init self.bullish = self.I(bullish, self.data.Open[-1],self.data.High[-1],self.data.Low[-1],self.data.Close[-1]) File "C:\Users\aliza\AppData\Local\Programs\Python\Python39\lib\site-packages\backtesting\backtesting.py", line 127, in I raise RuntimeError(f'Indicator "{name}" errored with exception: {e}') RuntimeError: Indicator "bullish(2318.08008,2326.63989,2318.08008,2324.70996)" errored with exception: Argument 'open' has incorrect type (expected numpy.ndarray, got numpy.float64)

I'm using very simple version

//example

def bearish(o,h,l,c):
    return talib.CDLHANGINGMAN(o,h,l,c)

alizain5693 avatar Jul 12 '21 19:07 alizain5693

It looks like you are calling it with a scalar value not an array of values.

On Mon, Jul 12, 2021 at 12:40 PM alizain5693 @.***> wrote:

I keep getting this error when using the candle stick patterns in talib. I'm passing in just float values and they should work fine. i tried typecasting them to nd arrays before passing but that didn't help. also I don't understand why the candle stick functions need nd arrays if they are asking for 4 o,h,l,c values. please help.

//Traceback Traceback (most recent call last): File "C:\Users\aliza\AppData\Local\Programs\Python\Python39\lib\site-packages\backtesting\backtesting.py", line 125, in I value = func(*args, **kwargs) File "C:\Users\aliza\Documents\CexTrading\bybit-heikin-ashi\testingback.py", line 63, in bullish return talib.CDLHAMMER(o,h,l,c) .py", line 152, in stats = bt.run() File "C:\Users\aliza\AppData\Local\Programs\Python\Python39\lib\site-packages\backtesting\backtesting.py", line 1134, in run strategy.init() File "C:\Users\aliza\Documents\CexTrading\bybit-heikin-ashi\testingback.py", line 117, in init self.bullish = self.I(bullish, self.data.Open[-1],self.data.High[-1],self.data.Low[-1],self.data.Close[-1]) File "C:\Users\aliza\AppData\Local\Programs\Python\Python39\lib\site-packages\backtesting\backtesting.py", line 127, in I raise RuntimeError(f'Indicator "{name}" errored with exception: {e}') RuntimeError: Indicator "bullish(2318.08008,2326.63989,2318.08008,2324.70996)" errored with exception: Argument 'open' has incorrect type (expected numpy.ndarray, got numpy.float64)

I'm using very simple version

//example def bearish(o,h,l,c): return talib.CDLHANGINGMAN(o,h,l,c)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mrjbq7/ta-lib/issues/439, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF5A4MFHG6DDIR7CFG6XDTXNALLANCNFSM5AHPUGVA .

mrjbq7 avatar Jul 12 '21 19:07 mrjbq7