Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
talib - RSI error
#1
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,)]
Reply
#2
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)
Reply
#3
Wall
Reply
#4
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Although this is a talib related Q it's mostly related to python module installing.. Evalias123 4 5,585 Jan-10-2021, 11:39 PM
Last Post: Evalias123

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020