Is there a way to pass a proxy as a parameter in refinitiv.data library (Python)?

Hi,


Similar to this question from 2 years ago, I want to connect to the refinitiv.data library via a proxy server. This is because I need to run rd.get_data requests from an internal private server with, let's just say, highly strict network configurations. Right now, running rd.get_data() the regular way will return an empty dataframe and sometimes this error:

"An error occurred while requesting URL('http://localhost:9060/api/udf').
ReadError('[WinError 10053] An established connection was aborted by the software in your host machine')". 


My question is - is it now possible to configure my session to use a proxy server? If yes, how? If no, any alternatives?


Edit: Correction in title


Thanks and regards,

RC

Best Answer

Answers

  • Hi @Jirapongse,


    This seems to work for platform sessions but not desktop sessions. (For others' reference, please see code snippet below). Not sure if this is just specific to me but I was hoping both options to work. Regardless, I'll accept this as the answer. Thank you very much!


    Desktop Session

    import refinitiv.data as rd
    import os

    os.environ["HTTP_PROXY"] = "YOUR_PROXY"
    os.environ["HTTPS_PROXY"] = "YOUR_PROXY"

    appKey = "YOUR_APPKEY"
    rd.open_session(app_key=appKey)

    df = rd.get_data("MSFT.O", ["TR.ClosePrice"])

    print(df)
    rd.close_session()

    Returns:

    Empty DataFrame
    Columns: []
    Index: []


    Platform Session

    import refinitiv.data as rd
    import os

    os.environ["HTTP_PROXY"] = "YOUR_PROXY"
    os.environ["HTTPS_PROXY"] = "YOUR_PROXY"

    session = rd.session.platform.Definition(
    app_key = "YOUR_APPKEY",
    grant = rd.session.platform.GrantPassword(
    username = "YOUR_USERNAME",
    password = "YOUR_PASSWORD"
    )
    ).get_session()

    rd.session.set_default(session)

    session.open()

    df = rd.get_data("MSFT.O", ["TR.ClosePrice"])
    print(df)

    session.close()

    Returns:

      Instrument  Close Price
    0 MSFT.O 308.65
  • @RC Da Cola

    The desktop session gets the data from the localhost (127.0.0.1). I am not sure if the proxy can connect to the localhost that runs a desktop application.

    If I set a proxy on my local machine and use it with the desktop session, it works fine.

    1683597735540.png