Hi,
I'm trying to use RDP in Python, as I cannot access the info I want via Eikon.
I've copied the basic example from your site (https://developers.refinitiv.com/article/rdp-library-python-log-returns-correlation-matrix-and-ols-regression-models ), but when I run the below code (I've deleted my APP_KEY):
import getpass
import refinitiv.dataplatform as rdp # the RDP library for Python
import pandas as pd
import numpy as np
rdp.open_desktop_session("XXXXXXXXXXXXXXXXXXXXXXXX")
RICs = [".SPX",".VIX","IBM.N","GE"] # the list of RICs
s_date = "2018-01-02" # start date
e_date = "2018-12-30" # end date
#TBD - remove later pd.set_option('display.max_columns', None)
lastPriceField = "TRDPRC_1" # the last price field of these RICs
data = pd.DataFrame() # define data is a DataFrame
for aRIC in RICs: # request daily last price for each RIC
df= rdp.get_historical_price_summaries(aRIC,start=s_date,end=e_date,interval = rdp.Intervals.DAILY,fields=[lastPriceField])
if df is None: # check if there is any error
print("Error for RIC " + aRIC + ":" + str(rdp.get_last_status()['error'])) # print the error
else:
df[lastPriceField] = df[lastPriceField].astype(float) # convert string type to float
data[aRIC] = df[lastPriceField] # create the RIC's last price column
data # display daily last price of the RICs
I get the below python error for the rdp call. Can somebody please help.
Thanks
TypeError Traceback (most recent call last) <ipython-input-14-bbed23114e72> in <module> 14 data = pd.DataFrame() # define data is a DataFrame 15 for aRIC in RICs: # request daily last price for each RIC ---> 16 df= rdp.get_historical_price_summaries(aRIC,start=s_date,end=e_date,interval = rdp.Intervals.DAILY,fields=[lastPriceField]) 17 if df is None: # check if there is any error 18 print("Error for RIC " + aRIC + ":" + str(rdp.get_last_status()['error'])) # print the error C:\ProgramData\Miniconda3_64\envs\myenv\lib\site-packages\refinitiv\dataplatform\factory\content_factory.py in get_historical_price_summaries(universe, interval, start, end, adjustments, sessions, count, fields, on_response, closure) 401 fields=fields, 402 on_response=on_response, --> 403 closure=closure) 404 405 C:\ProgramData\Miniconda3_64\envs\myenv\lib\site-packages\refinitiv\dataplatform\factory\content_factory.py in _get_historical_price_summaries(cls, universe, interval, start, end, adjustments, sessions, count, fields, on_response, closure) 194 count=count, 195 fields=fields, --> 196 closure=closure) 197 cls.__last_result = historic_summaries 198 if historic_summaries.is_success and historic_summaries.data and historic_summaries.data.df is not None: C:\ProgramData\Miniconda3_64\envs\myenv\lib\site-packages\refinitiv\dataplatform\content\data\historical_pricing.py in get_summaries(universe, session, interval, start, end, adjustments, sessions, count, fields, on_response, closure) 275 count=count, 276 fields=fields, --> 277 closure=closure) 278 return result 279 C:\ProgramData\Miniconda3_64\envs\myenv\lib\site-packages\refinitiv\dataplatform\content\data\historical_pricing.py in _get_summaries(self, universe, interval, start, end, adjustments, sessions, count, fields, closure) 296 count=count, 297 fields=fields, --> 298 closure=closure)) 299 300 ############################################################# C:\ProgramData\Miniconda3_64\envs\myenv\lib\site-packages\nest_asyncio.py in run_until_complete(self, future) 59 while not f.done(): 60 run_once(self) ---> 61 return f.result() 62 else: 63 return self._run_until_complete_orig(future) C:\ProgramData\Miniconda3_64\envs\myenv\lib\asyncio\tasks.py in _step(***failed resolving arguments***) 178 # We use the `send` method directly, because coroutines 179 # don't have `__iter__` and `__next__` methods. --> 180 result = coro.send(None) 181 else: 182 result = coro.throw(exc) C:\ProgramData\Miniconda3_64\envs\myenv\lib\site-packages\refinitiv\dataplatform\content\data\historical_pricing.py in _get_summaries_async(self, universe, interval, start, end, adjustments, sessions, count, fields, closure) 446 count=count, 447 fields=fields, --> 448 closure=closure) 449 450 _historical_result = HistoricalPricing.HistoricalPricingResponse(_result._response, C:\ProgramData\Miniconda3_64\envs\myenv\lib\site-packages\refinitiv\dataplatform\content\data\historical_pricing.py in _get_historicalpricing(self, url, path_parameters, query_parameters, start, end, fn_format_datetime, adjustments, market_sessions, count, fields, closure) 542 path_parameters=path_parameters, 543 query_parameters=_query_parameters, --> 544 closure=closure) 545 if _result and not _result.is_success: 546 self._endpoint.session.log(1, f'Historical Pricing request failed: {_result.status}') C:\ProgramData\Miniconda3_64\envs\myenv\lib\site-packages\refinitiv\dataplatform\delivery\data\endpoint.py in send_request_async(self, method, header_parameters, path_parameters, query_parameters, body_parameters, closure) 441 json=_body, 442 closure=closure) --> 443 _result = Endpoint.EndpointResponse(_response) 444 445 self.on_response(_result) C:\ProgramData\Miniconda3_64\envs\myenv\lib\site-packages\refinitiv\dataplatform\delivery\data\endpoint.py in __init__(self, response) 203 else: 204 try: --> 205 _raw = response.json() 206 if _raw and _raw.get("error"): 207 self.status["error"] = _raw["error"] C:\ProgramData\Miniconda3_64\envs\myenv\lib\site-packages\requests\models.py in json(self, **kwargs) 883 # decoding fails, fall back to `self.text` (using chardet to make 884 # a best guess). --> 885 encoding = guess_json_utf(self.content) 886 if encoding is not None: 887 try: C:\ProgramData\Miniconda3_64\envs\myenv\lib\site-packages\requests\utils.py in guess_json_utf(data) 869 if sample[:2] in (codecs.BOM_UTF16_LE, codecs.BOM_UTF16_BE): 870 return 'utf-16' # BOM included --> 871 nullcount = sample.count(_null) 872 if nullcount == 0: 873 return 'utf-8' TypeError: must be str, not bytes