Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • Refinitiv Data Platform /
avatar image
Question by thomas.goodman · Jun 10, 2020 at 11:28 AM · apipythonrdperror

RDP Python Type Error

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

People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

2 Replies

  • Sort: 
avatar image
Best Answer
Answer by thomas.goodman · Jun 10, 2020 at 04:31 PM

Hi,

It looks like it might have been a versioning issue with Python. We are encouraged to use 3.6.9 at work, as it is considered the most stable for our virtual desktop environment.

I created another environment, using 3.8.1 and the code seems to run fine now.

Thanks


Comment

People who like this

0 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
REFINITIV
nick.zincone.1 ♦♦ · Jun 10, 2020 at 04:39 PM 0
Share

Great - thanks for the feedback and confirmation.

avatar image
REFINITIV
Answer by nick.zincone.1 · Jun 10, 2020 at 03:07 PM

Hi @thomas.goodman,

I just tried the same example with success so the issue is likely related to your environment. Can you confirm a few things:

Can you provide some version information such as the Eikon version, the DESKTOPSXSSVC and PROXY versions in the Eikon \ Help \ About Thomson Reuters window ?

Also, I would like you to try the following commands within your notebook which provides some logging information:

Execute the above commands right after the command:

rdp.open_desktop_session(APP_KEY)

There may be a permission issue or an issue with your RDP Python version.


ahs.png (56.7 KiB)
ahs.png (75.0 KiB)
Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
9 People are following this question.

Related Questions

How do i read a Quote page having dynamic RIC's?

Error message "Access Denied: User req to PE(6319)"

Download historical data from LoanConnector

Can I confirm Eikon real time feeds using RDP

Refinitiv Data Platform APIs - error when requesting data

  • Feedback
  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Careers
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Calais
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Electronic Trading
    • Generic FIX
    • Local Bank Node API
    • Trading API
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRIT
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • World-Check Data File
  • Explore
  • Tags
  • Questions
  • Badges