Client is using Jupyter API

Options
RALPHPAOLO.NAVARRO
edited July 23 in Eikon Data APIs

I'm not able to download date using this code. This was possible a couple of months ago.

importrefinitiv.data as rd

rd.open_session()

st="JPUSTOSR21M=TTKL"

dt1="2025-07-06"

dt2="2025-07-09"

start_dt = dt1 +"T00:00:00" end_dt = dt2 +"T20:59:59" df =rd.get_history(st, fields=['BID','ASK'], interval="tick", start =start_dt, end = end_dt)

Client encountered an error:

---------------------------------------------------------------------------

RDError Traceback (most recent call last)

Cell In[3], line 3

1 import refinitiv.data as rd

2 rd.open_session()---->

3 rd.get_history(

4 universe='JPUSTOSR21M=TTKL',

5 fields=["BID", "ASK",],

6 interval="tick",

7 start="2025-07-06" +'T00:00:00',

8 end="2025-07-09" +'T20:59:59',

9 )

File ~\AppData\Local\anaconda3\Lib\site-packages\refinitiv\data\_access_layer\get_history_func.py:206, in

get_history(universe, fields, interval, start, end, adjustments, count,

use_field_names_in_headers, parameters)

204 if exceptions and all(exceptions):

205 except_msg = "\n\n".join(exceptions)

--> 206 raise RDError(-1, except_msg)

208 if not any({adc_data, hp_data, cust_inst_data}):

209 return DataFrame()

RDError: Error code -1 | 'dict' object has no attribute 'url'

Please help. Thank you

Answers

  • Hello @RALPHPAOLO.NAVARRO

    The instrument JPUSTOSR21M=TTKL seems to be invalid. I can't find it or get any data for it. Please reach out to content specialist at LSEG MyAccount, to get the correct symbol.

  • @Gurpreet can you try using EUR1YOIS=FMD please. thank you so much

  • Hi @RALPHPAOLO.NAVARRO ,

    I can retrieve data properly with the RIC you provided

    image.png
  • hello team. @Gurpreet @raksina.samasiri

    Client followed up, I tried to execute this code:

     # Start session with your App Key

    from IPython.display import HTML

    import pandas as pd

    import refinitiv.data as rd

    session= rd.open_session(app_key=xxxxxxxxx)

    print(session)

     

     

    I got this message:

     

    DesktopSession

                                    name = 'workspace'

                                    connection = DesktopConnection

                                    stream_auto_reconnection = True

                                    handshake_url = http://localhost:9000/api/handshake

                                    state = OpenState.Pending

                                    session_id = 0

                                    logger_name = sessions.desktop.workspace.0

     

    As you can see, the state is Pending.

     Can you please assist to fix this?

    Thank you

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @RALPHPAOLO.NAVARRO

    The error (Error code -1 | 'dict' object has no attribute url') is similar to this discussion.

    The client should migrate the application to use the LSEG Data Library for Python instead. The examples are available on GitHub.

    To migrate the application, please refer to this Essential Guide to the Data Libraries - Generations of Python library (EDAPI, RDP, RD, LD) article.

  • RALPHPAOLO.NAVARRO
    edited July 30

    Hi Sir @Jirapongse @Gurpreet

    As per client,

    I’m able to fetch market data if I use CODEBK. However, I use Jupyter or Visual Studio Code. Lseg librairy is no longer accessible.

     This is the code I used, but it doesn’t work. Can you please assist?

     import lseg.data as ld

    ld.open_session(config={"app_key": "REMOVED"})ld.get_history("LSEG.L")

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @RALPHPAOLO.NAVARRO

    Please share the error.

  • RALPHPAOLO.NAVARRO
    edited July 31

    Hello good morning @Jirapongse @Gurpreet

    This is error client got when executing this code:

      Cell In[61], line 2

        ld.open_session(config={"app_key": "<app_key>"})ld.get_history("LSEG.L")

                                                                                       ^

    SyntaxError: invalid syntax

    REMOVED

     

    Thank you for your assistance.

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    edited July 31

    The code should be like this:

    import lseg.data as ld
    
    ld.open_session(app_key = "<APP KEY>")
    
    ld.get_history("LSEG.L")
    
  • @RALPHPAOLO.NAVARRO These are public forums. Please refrain from posting client identifying information in the posts.

  • RALPHPAOLO.NAVARRO
    edited July 31

    @Gurpreet @Jirapongse

    Please find below the error I got when using your code:

     

    ---------------------------------------------------------------------------

    AttributeError                            Traceback (most recent call last)

    Cell In[62], line 3

          1 import lseg.data as ld

    ----> 3 ld.open_session(app_key = "***DELETED***")

          5 ld.get_history("LSEG.L")

     

    File ~\AppData\Local\anaconda3\Lib\site-packages\lseg\data\_access_layer\session.py:92, in open_session(name, app_key, config_name)

         89     set_default(new_session)

         90     default_session = new_session

    ---> 92 default_session.open()

         94 return default_session

     

    File ~\AppData\Local\anaconda3\Lib\site-packages\lseg\data\_core\session\_session.py:374, in Session.open(self)

        372 self._call_on_state("Session opening in progress")

        373 self._config.on(configure.ConfigEvent.UPDATE, self._on_config_updated)

    --> 374 self._http_service.open()

        375 is_opened = self._connection.open()

        377 if is_opened:

     

    File ~\AppData\Local\anaconda3\Lib\site-packages\lseg\data\_core\session\http_service.py:334, in HTTPService.open(self)

        333 def open(self):

    --> 334     self._client.open()

     

    File ~\AppData\Local\anaconda3\Lib\site-packages\lseg\data\_core\session\http_service.py:187, in HTTPClient.open(self)

        183 proxies = self._session._proxies.get_proxy_for_httpx()

        185 # httpx has its default Accept header and

        186 # server wants application/json or nothing

    --> 187 self._client = get_httpx_client(

        188     headers={"Accept": APPLICATION_JSON},

        189     limits=limits,

        190     proxies=proxies,

        191 )

        193 key = configure.keys.http_auto_retry_config

        194 auto_retry_config = config.get(key, None)

     

    File ~\AppData\Local\anaconda3\Lib\site-packages\lseg\data\_core\session\http_service.py:160, in get_httpx_client(proxies, **kwargs)

        158 def get_httpx_client(proxies, **kwargs):

        159     if httpx.__version__ >= "0.26.0":

    --> 160         client = httpx.Client(proxy=proxies, **kwargs)

        161     else:

        162         client = httpx.Client(proxies=proxies, **kwargs)

     

    File ~\AppData\Local\anaconda3\Lib\site-packages\httpx\_client.py:697, in Client.__init__(self, auth, params, headers, cookies, verify, cert, trust_env, http1, http2, proxy, mounts, timeout, follow_redirects, limits, max_redirects, event_hooks, base_url, transport, default_encoding)

        686 proxy_map = self._get_proxy_map(proxy, allow_env_proxies)

        688 self._transport = self._init_transport(

        689     verify=verify,

        690     cert=cert,

       (...)

        695     transport=transport,

        696 )

    --> 697 self._mounts: dict[URLPattern, BaseTransport | None] = {

        698     URLPattern(key): None

        699     if proxy is None

        700     else self._init_proxy_transport(

        701         proxy,

        702         verify=verify,

        703         cert=cert,

        704         trust_env=trust_env,

        705         http1=http1,

        706         http2=http2,

        707         limits=limits,

        708     )

        709     for key, proxy in proxy_map.items()

        710 }

        711 if mounts is not None:

        712     self._mounts.update(

        713         {URLPattern(key): transport for key, transport in mounts.items()}

        714     )

     

    File ~\AppData\Local\anaconda3\Lib\site-packages\httpx\_client.py:700, in <dictcomp>(.0)

        686 proxy_map = self._get_proxy_map(proxy, allow_env_proxies)

        688 self._transport = self._init_transport(

        689     verify=verify,

        690     cert=cert,

       (...)

        695     transport=transport,

        696 )

        697 self._mounts: dict[URLPattern, BaseTransport | None] = {

        698     URLPattern(key): None

        699     if proxy is None

    --> 700     else self._init_proxy_transport(

        701         proxy,

        702         verify=verify,

        703         cert=cert,

        704         trust_env=trust_env,

        705         http1=http1,

        706         http2=http2,

        707         limits=limits,

        708     )

        709     for key, proxy in proxy_map.items()

        710 }

        711 if mounts is not None:

        712     self._mounts.update(

        713         {URLPattern(key): transport for key, transport in mounts.items()}

        714     )

     

    File ~\AppData\Local\anaconda3\Lib\site-packages\httpx\_client.py:750, in Client._init_proxy_transport(self, proxy, verify, cert, trust_env, http1, http2, limits)

        740 def _init_proxy_transport(

        741     self,

        742     proxy: Proxy,

       (...)

        748     limits: Limits = DEFAULT_LIMITS,

        749 ) -> BaseTransport:

    --> 750     return HTTPTransport(

        751         verify=verify,

        752         cert=cert,

        753         trust_env=trust_env,

        754         http1=http1,

        755         http2=http2,

        756         limits=limits,

        757         proxy=proxy,

        758     )

     

    File ~\AppData\Local\anaconda3\Lib\site-packages\httpx\_transports\default.py:168, in HTTPTransport.__init__(self, verify, cert, trust_env, http1, http2, limits, proxy, uds, local_address, retries, socket_options)

        155 if proxy is None:

        156     self._pool = httpcore.ConnectionPool(

        157         ssl_context=ssl_context,

        158         max_connections=limits.max_connections,

       (...)

        166         socket_options=socket_options,

        167     )

    --> 168 elif proxy.url.scheme in ("http", "https"):

        169     self._pool = httpcore.HTTPProxy(

        170         proxy_url=httpcore.URL(

        171             scheme=proxy.url.raw_scheme,

       (...)

        185         socket_options=socket_options,

        186     )

        187 elif proxy.url.scheme in ("socks5", "socks5h"):

     

    AttributeError: 'dict' object has no attribute 'url'

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    Please check the answer on this discussion.

    You may try to downgrade the httpx to 0.24.1.