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
Best Answer
-
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, ...)
1
Answers
-
Pierre, thanks a lot! For what it's worth, gave you my one and only point.
0
Categories
- All Categories
- 6 AHS
- 39 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 370 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 60 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛