talib - RSI error - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: talib - RSI error (/thread-32313.html) |
talib - RSI error - sambanerjee - Feb-02-2021 I've been struggling trying to troubleshoot this - please let me know if you need more code / info - thanks Error Message: Quote:TypeError: Argument 'real' has incorrect type (expected numpy.ndarray, got list) c.execute('SELECT Close from StockDetails where Symbol = ?', row) Close =c.fetchall() rsi = pd.Series(talib.RSI(Close, timeperiod=14)).replace(np.nan,0)print(Close) gives the following Quote:[(108.68000030517578,), (110.88999938964844,), (112.20999908447266,), (114.68000030517578,), (114.3499984741211,), (114.08999633789062,), (116.9000015258789,), (115.36000061035156,), (114.56999969482422,), (113.58000183105469,), (115.1500015258789,), (114.4000015258789,), (117.01000213623047,), (116.4000015258789,), (118.80999755859375,), (118.4800033569336,), (116.73999786376953,), (117.38999938964844,), (117.23999786376953,), (118.97000122070312,), (119.30000305175781,), (117.77999877929688,), (117.37000274658203,), (117.30000305175781,), (117.30999755859375,), (117.83000183105469,), (117.2300033569336,), (117.38999938964844,), (118.48999786376953,), (118.63999938964844,), (119.61000061035156,), (122.88999938964844,), (126.16000366210938,), (127.05999755859375,), (128.14999389648438,), (126.97000122070312,), (126.9800033569336,), (126.02999877929688,), (126.20999908447266,), (127.3499984741211,), (128.11000061035156,), (127,), (126.33000183105469,), (125.4800033569336,), (123.91999816894531,), (118.80000305175781,), (121.55999755859375,), (120.16999816894531,)] RE: talib - RSI error - sambanerjee - Feb-03-2021 this is the entire code with the imports import pandas as pd import sqlite3 import talib import numpy as np import yfinance as yf from datetime import datetime import os import csv from csvsort import csvsort conn = sqlite3.connect('Strategy_RSI_MACD_Data.db') c = conn.cursor() c.execute("select distinct Symbol from StockDetails LIMIT 5") tickers = c.fetchall() for row in tickers: c.execute('SELECT Close from StockDetails where Symbol = ?', row) Close =c.fetchall() rsi = pd.Series(talib.RSI(Close, timeperiod=14)).replace(np.nan,0) RE: talib - RSI error - sambanerjee - Feb-03-2021 RE: talib - RSI error - nilamo - Feb-04-2021 What's the rest of the error? What specifically is expecting a numpy array? What's a talib? Do you have a link to the docs we can look at? |