For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
4 0 0 1

How to pass a list of RICs through get_timeseries?

Hi dev community!

I am absolutely new to this but would like to use a list from eiko PORT app with the get_timeseries function.

This works well with the get_data function


However, when I try to pass the list through get_timeseries function I get an error.


import eikon as ek
import pandas as pd


[2]:

ek.set_app_key('##########################')


[3]:

rics=(['Portfolio(500867312/*Total Asset List*/)'])


[4]:

print(rics)

['Portfolio(500867312/*Total Asset List*/)']


[5]:

dataset = ek.get_timeseries(rics,
                         fields='CLOSE',
                   start_date='2020.01.01',
                         end_date='2021.01.02',
                   normalize='True'
)



WARNING:pyeikon:Error with Portfolio(500867312/*Total Asset List*/): Invalid RIC ERROR:pyeikon:Portfolio(500867312/*Total Asset List*/): Invalid RIC | 


---------------------------------------------------------------------------
EikonError                                Traceback (most recent call last)
<ipython-input-5-af7c7776ca2a> in <module>
      7                    start_date='2020.01.01',
      8                          end_date='2021.01.02',
----> 9                    normalize='True'
     10 ) 
/opt/conda/lib/python3.7/site-packages/eikon/time_series.py in get_timeseries(rics, fields, start_date, end_date, interval, count, calendar, corax, normalize, raw_output, debug)
    200     if len(ts_status_errors) == len(ts_timeserie_data):
    201         logger.error(ts_error_messages)
--> 202         raise EikonError(-1, message=ts_error_messages)
    203     204     if raw_output: return ts_result 
EikonError: Error code -1 | Portfolio(500867312/*Total Asset List*/): Invalid RIC | 


I've also tried a workaround by first getting the RIC list with the get_data function and then converting the retrieved RIC list and pasting them through the get_timseries function without success.


import eikon as ek


[2]:

ek.set_app_key('############################')


[3]:

rics=(['Portfolio(500867312/*Total Asset List*/)'])


[4]:

dataset, err=ek.get_data(rics,['tr.PriceClose'])


[5]:

print(dataset)


         Instrument  Price Close 0           OREP.PA     323.4000 1           SAPG.DE     103.0200 2           0941.HK      53.6000 3          0593xq.L    1840.0000 4            SOON.S     248.2000 ..              ...          ... 96          CYBA.AS       5.4062 97     NL0000388619      50.2600 98   912828YM6=RRPS          NaN 99     NL0000009355          NaN 100          BRKb.N     251.5000 
[101 rows x 2 columns]


[6]:

import pandas as pd


[7]:

rics2 = pd.DataFrame(dataset.loc[:0,'Instrument'])


[8]:

print(rics2)

  Instrument 0    OREP.PA


[9]:

rics3 = rics2.astype(str)


[10]:

print (rics3)

  Instrument 0    OREP.PA


[11]:

s_array = rics3['Instrument'].to_numpy()


[12]:

print(s_array)

['OREP.PA']


[13]:

dataset = ek.get_timeseries(s_array,
                         fields='CLOSE',
                   start_date='2020.01.01',
                         end_date='2021.01.02',
                   normalize='True'
)



---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-13-8e9e9cf810cb> in <module>
      7                    start_date='2020.01.01',
      8                          end_date='2021.01.02',
----> 9                    normalize='True'
     10 ) 
/opt/conda/lib/python3.7/site-packages/eikon/time_series.py in get_timeseries(rics, fields, start_date, end_date, interval, count, calendar, corax, normalize, raw_output, debug)
    111     112     # set the ric(s) in the payload
--> 113     check_for_string_or_list_of_strings(rics, 'rics')
    114     if is_string_type(rics):
    115         rics = [rics.strip()]

/opt/conda/lib/python3.7/site-packages/eikon/tools.py in check_for_string_or_list_of_strings(parameter, name)
     53 def check_for_string_or_list_of_strings(parameter, name):
     54     if type(parameter) != list and (not parameter or not is_string_type(parameter)):
---> 55         raise ValueError('The parameter {} should be a string or a list of string, found {}'.format(name,type(parameter)))
     56     if type(parameter) == list and not is_list_of_string(parameter):
     57         raise ValueError('All items in the parameter {} should be of data type string, found {}'.format(name,[type(v) for v in parameter]))

ValueError: The parameter rics should be a string or a list of string, found <class 'numpy.ndarray'>


Any help is much appreciated!


Ludwig

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythonrics
1615996344410.png (39.4 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvote
Accepted
4.3k 2 4 5

Hi @calice.l ,

You provided wrong type (numpy.ndarray) to get_timeseries().

Update your last example as below:

dataset, err=ek.get_data(rics,['tr.PriceClose']) rics2 = dataset["Instruments"] rics3 = rics2.tolist()

Then this request should work:

dataset = ek.get_timeseries(rics3, ...)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea