i'm trying to make a method that would return me a df: while doing it i am using twelvedata. i am getting a type error but a few days before i was able to run it without errors ! here are syntax and semantics:

def retrive(key = 0 , symbol = 'AAPL', interval = '5min', size = 100, cred =0, with_heading = True):
    td = TDClient(apikey = apikeys[key])
    ts = td.time_series(symbol = symbol , interval = interval , outputsize = size)
    print(type(ts))
    add(cred)
    **df = ts.as_pandas()**
    add(cred)
    if with_heading:
        print(' - - - - - - - - - - ' , symbol , ' - - - - - - - - - - \n',)
    df = df.rename(columns={'open':'Open','close':'Close','high':'High','low':'Low', 'volume':'Volume'})
    return df

trace back results:

<class 'twelvedata.time_series.TimeSeries'>
Traceback (most recent call last):
  File "c:\Users\Aman\AppData\Local\Programs\Python\Python38-32\Scripts\mounth 6 (march)\Algo_Trding_v7\Algo_v8\main_engine_v7.py", line 55, in <module>
    engine()
  File "c:\Users\Aman\AppData\Local\Programs\Python\Python38-32\Scripts\mounth 6 (march)\Algo_Trding_v7\Algo_v8\main_engine_v7.py", line 14, in engine
    df = indi.retrive(symbol = symbols[i], cred = cred, key = key)
  File "c:\Users\Aman\AppData\Local\Programs\Python\Python38-32\Scripts\mounth 6 (march)\Algo_Trding_v7\Algo_v8\indi.py", line 83, in retrive
    df = ts.as_pandas()
  File "C:\Users\Aman\AppData\Local\Programs\Python\Python38-32\lib\site-packages\twelvedata\time_series.py", line 114, in as_pandas
    df = self.price_endpoint.as_pandas()
  File "C:\Users\Aman\AppData\Local\Programs\Python\Python38-32\lib\site-packages\twelvedata\mixins.py", line 44, in as_pandas
    data = self.as_json()
  File "C:\Users\Aman\AppData\Local\Programs\Python\Python38-32\lib\site-packages\twelvedata\mixins.py", line 12, in as_json
    resp = self.execute(format="JSON")
  File "C:\Users\Aman\AppData\Local\Programs\Python\Python38-32\lib\site-packages\twelvedata\endpoints.py", line 265, in execute
    params["symbol"], self.is_batch = get_symbol(self.symbol)
TypeError: cannot unpack non-iterable NoneType object

is there any mistake in the method i made or anywhere else because i have not touched this files yet. i am just using this method 'indi.retrive()'. plz tell me whats worng! i hope you will figure it out :( yours, Rushidev Jain

i was trying to make a method that would be used for returning a df of OHLCV data from twelvedata's API. but i am getting a 'TypeError: cannot unpack non-iterable NoneType object' while converting the time series object of twelvedata in a pandas_df by 'as_pandas()' of twelve data as mentioned above.

0

There are 0 best solutions below