RtGet() using lseg.data library

Ricky_G
Ricky_G Newcomer
edited April 4 in Refinitiv Data Platform

Hi, how would I do a function like =RtGet("SYD1", [@RIC], "COUPN_RATE") in python using the lseg.data library? Thanks

Tagged:

Welcome!

It looks like you're new here. Sign in or register to get started.

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @Ricky_G

    Thank you for reaching out to us.

    Please check the answer on this discussion.

    The LD example is on GitHub.

    I am not sure what this SYD1 source is. Is it from your local RTDS server?

  • Ricky_G
    Ricky_G Newcomer

    Hi thanks for this response.

    For some reason now, this code works for my computer, but when I run it on someone else computer (who have the same reuters/refinitiv applications open), it just returns N/A values. Do you know why?

    Thanks

    —————————————————

    rd.open_session()

    # Internal Server               
    stream = pricing.Definition(                   
    universe=bonds_rics,     # "INTERNAL_RIC"                   
    fields=["YIELD", "GN_TXT24_1", "GN_TXT24_2"],                    
    service="SYDDS1IR"                       
    ).get_stream()

    stream.open()

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @Ricky_G

    I am not sure what the SYDDS1IR is.

    Typically, our real-time service name is IDN_RDF, or ELEKTRON_DD.

    Therefore, this SYDDS1IR service could be your internal service. That machine may not see that service.

    Can the Workspace app on that machine can access this SYDDS1IR service?

  • Ricky_G
    Ricky_G Newcomer

    @Jirapongse

    Thanks for the quick reply. SYDDS1IR is our internal server, and I am able to get our internal feeds when using the previous code provided. However, when the same code is run on other computers (with the same applications open in the background), it doesn't' work.

    Any idea why?

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    Are you using the desktop.workspace session or the platform.deployed session?

    If you are using the desktop.workspace session, the Workspace application must be configured to see that service.

    You may enable the debug log on both machines by using the following code to compare the behaviors.

    config = rd.get_config()
    config.set_param("logs.transports.file.enabled", True)
    config.set_param("logs.transports.file.name", "lseg-data-lib.log")
    config.set_param("logs.level", "debug")
    rd.open_session()
  • Ricky_G
    Ricky_G Newcomer

    Thanks for this. Is there any way to just have the code work without debugging each computer? I.e. is there a way to open the session universally?

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    edited April 24

    The session can't be opened universally.

    The code needs to run on that machine to open a session.

  • Ricky_G
    Ricky_G Newcomer

    Apologies - I meant, is there a way to structure the code such that I don't have to manually look through the config but rather just use the rd.open_session() etc functions?

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @Ricky_G

    If you mean opening sessions without any config file, please refer to this session example.

  • Ricky_G
    Ricky_G Newcomer

    Hi @Jirapongse,

    So, I've tried opening Refinitiv Workspace on a different computer first, and now the code works on that computer but not my other computer (i.e. the computer which opens Refinitiv Workspace first seems to work with the code, but then the other doesn't and just returns N/A values).

    Any idea why this may be? Thanks

  • Ricky_G
    Ricky_G Newcomer

    This is what it says for the computer that just returns N/A values:

    DesktopSession
    name = 'workspace'

                connection = DesktopConnection
                stream_auto_reconnection = True
                handshake_url = http://localhost:9000/api/handshake
                state = OpenState.Closed
                session_id = 1
                logger_name = sessions.desktop.workspace.1
  • Ricky_G
    Ricky_G Newcomer

    And I think my Data API Proxy for this computer is http://localhost:9003/api/, , so do you know how I may fix my code to dynamically adjust for this?

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @Ricky_G

    The library connects to the API Proxy component which is a part of the LSEG Workspace to retrieve data.

    Therefore, we need to make sure that the API Proxy is running properly on the machine.

    You can refer to the Eikon Data API and Refinitiv Data Library - Troubleshooting article to make sure that the API Proxy is running properly.

  • Ricky_G
    Ricky_G Newcomer

    Hi, sorry I'm still unsure as to why it only works on one computer and not others. Do you have an idea of what the issue may be?

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    First, you need to check if the API Proxy is running properly by referring to the Eikon Data API and Refinitiv Data Library - Troubleshooting article.

    If the API Proxy is running properly, you need to enable the debug log with the following code to verify the problem in the library.



    config = rd.get_config()

    config.set_param("logs.transports.file.enabled", True)

    config.set_param("logs.transports.file.name", "lseg-data-lib.log")

    config.set_param("logs.level", "debug")


    rd.open_session()

    With the code, the lseg-data-lib.log file will be created.

    Please remove any private information from the log file and share it.

  • Ricky_G
    Ricky_G Newcomer

    [2025-04-29T13:57:30.574955+10:00] - [session] - [DEBUG] - [7368 - Dummy-4] - [_session] - [__init__] - Creating session "sessions.desktop.workspace.0" based on session.desktop.Definition("desktop.workspace")

    [2025-04-29T13:57:30.579955+10:00] - [sessions.desktop.workspace.0] - [DEBUG] - [7368 - Dummy-4] - [_desktop_session] - [__init__] - DesktopSession created with following parameters: app_key="DEFAULT_WORKSPACE_APP_KEY", name="workspace" base_url="http://localhost:9000" platform_path_rdp="/api/rdp" platform_path_udf="/api/udf" handshake_url="/api/handshake"

    [2025-04-29T13:57:30.589953+10:00] - [sessions.desktop.workspace.0] - [DEBUG] - [7368 - Dummy-4] - [_session] - [_connection] - Created session connection SessionCxnType.DESKTOP

    [2025-04-29T13:57:30.589953+10:00] - [sessions.desktop.workspace.0] - [DEBUG] - [7368 - Dummy-4] - [_session_provider] - [session_provider] -  + Session created: DesktopSession

            name = 'workspace'

            connection = DesktopConnection

            stream_auto_reconnection = True

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

            state = OpenState.Closed

            session_id = 0

            logger_name = sessions.desktop.workspace.0

     

    [2025-04-29T13:57:30.589953+10:00] - [sessions.desktop.workspace.0] - [DEBUG] - [7368 - Dummy-4] - [_session] - [open] - Open session

    [2025-04-29T13:57:30.738955+10:00] - [sessions.desktop.workspace.0] - [DEBUG] - [7368 - Dummy-4] - [http_service] - [build_request] - HTTP Request id 0

        url = http://localhost:9000/api/status

        method = GET

        headers = {'x-tr-applicationid': 'DEFAULT_WORKSPACE_APP_KEY'}

     

    [2025-04-29T13:57:30.775955+10:00] - [sessions.desktop.workspace.0] - [DEBUG] - [7368 - Dummy-4] - [http_service] - [request] - HTTP Response id 0

        status_code = 200

        text = {"statusCode":"ST_PROXY_READY","version":"3.9.2"}

    [2025-04-29T13:57:30.775955+10:00] - [sessions.desktop.workspace.0] - [DEBUG] - [7368 - Dummy-4] - [connection] - [debug] - Checking proxy url http://localhost:9000/api/status response : 200 - {"statusCode":"ST_PROXY_READY","version":"3.9.2"}

    [2025-04-29T13:57:30.775955+10:00] - [sessions.desktop.workspace.0] - [DEBUG] - [7368 - Dummy-4] - [connection] - [debug] - Port 9000 was retrieved from .portInUse file

    [2025-04-29T13:57:30.775955+10:00] - [sessions.desktop.workspace.0] - [DEBUG] - [7368 - Dummy-4] - [connection] - [debug] - Try to handshake on url http://localhost:9000/api/handshake...

    [2025-04-29T13:57:30.775955+10:00] - [sessions.desktop.workspace.0] - [DEBUG] - [7368 - Dummy-4] - [http_service] - [build_request] - HTTP Request id 1

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

        method = POST

        headers = {'Content-Type': 'application/json', 'x-tr-applicationid': 'DEFAULT_WORKSPACE_APP_KEY'}

        json = {'AppKey': 'DEFAULT_WORKSPACE_APP_KEY', 'AppScope': 'trapi', 'ApiVersion': '1', 'LibraryName': 'RDP Python Library', 'LibraryVersion': '1.6.2'}

    [2025-04-29T13:57:30.780955+10:00] - [sessions.desktop.workspace.0] - [DEBUG] - [7368 - Dummy-4] - [http_service] - [request] - HTTP Response id 1

        status_code = 200

        text = {"access_token":[REDACTED]:"bearer"}

    [2025-04-29T13:57:30.780955+10:00] - [sessions.desktop.workspace.0] - [DEBUG] - [7368 - Dummy-4] - [_session] - [open] - Opened session

    [2025-04-29T13:57:37.928398+10:00] - [sessions.desktop.workspace.0] - [INFO] - [7368 - Dummy-4] - [session] - [close_session] - Closing session

    [2025-04-29T13:57:37.942420+10:00] - [sessions.desktop.workspace.0] - [INFO] - [7368 - Dummy-4] - [session] - [close_session] - Session is closed

    [2025-04-29T13:57:39.325459+10:00] - [sessions.desktop.workspace.0] - [INFO] - [26180 - Dummy-7] - [session] - [close_session] - Closing session

    [2025-04-29T13:57:39.328460+10:00] - [sessions.desktop.workspace.0] - [INFO] - [26180 - Dummy-7] - [session] - [close_session] - Session is closed

  • Ricky_G
    Ricky_G Newcomer

    Same, but for some reason the values extracted are just N/A

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    I didn't see any request messages in the log file.

    Does the problem only happen with the SYDDS1IR service?

  • Ricky_G
    Ricky_G Newcomer

    Yes that's correct. There's only an error with the SYDDS1IR service when I try to run the code on other computers (i.e. any computer that is not the first computer I open Refinitiv with)

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @Ricky_G

    You may need to contact the workspace support team via MyAccount to compare the configurations between the first computer and other computers.

    You may check with the Quote app if the Workspace can see the SYDDS1IR service.

  • Ricky_G
    Ricky_G Newcomer

    Do you think it has something to do with my access token? Or will this automatically change if the session was open on a different computer?

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    With the desktop session, the library retrieves data through the Workspace application.

    The code subscribes data from an internal service (SYDDS1IR). Therefore, I assume that the Workspace must be configured to the connect to a local ADS for a streaming service.

    image.png

    Moreover, the Feed names must be configured properly.

    image.png

    Instead of using the desktop session, LSEG Data Library for Python also supports the platform.deployed session which allows the library directly connects to a ADS server with a websocket connection. However, the ADS server must be configured to support websocket connections.

    image.png

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.