RDP API Connect Timeout

I am getting connect timeout from rdp api calls. This is more frequent since 2 weeks now.

ERROR!!! An error occurred while requesting URL('https://api.refinitiv.com/data/historical-pricing/v1/views/interday-summaries/CADZAR%3D?interval=P1D&start=2022-08-07&end=2023-08-08').

ConnectTimeout('')

TimeoutError

The above exception was the direct cause of the following exception:

File "C:\Users\U6082634\AppData\Local\Programs\Python\Python311\Lib\site-packages\httpx\_transports\default.py", line 83, in map_httpcore_exceptions

raise mapped_exc(message) from exc

httpx.ConnectTimeout

Best Answer

  • wasin.w
    wasin.w admin
    Answer ✓

    Hello @navtej.riyait

    Sorry for the late reply.

    Firstly, I am noticed that you are using the legacy Data Platform library. I highly recommend you upgrade the library to the strategic Data Library for Python (https://pypi.org/project/refinitiv-data/) aka RD Library - Python.

    The RD Library is the newer version of Data Platform library. It contains all bug fixes, logging, configuration and more features than the Platform library with similar API interfaces. You can find more information from the following resources:

    The equivalent code for you Platform library is as follows:

    import refinitiv.data as rd
    from refinitiv.data.content import historical_pricing
    response = historical_pricing.summaries.Definition(
        universe = 'JPY=', 
        interval=Intervals.ONE_MINUTE,
        fields = ['BID','ASK'],
        start = '2023-08-01 01:00:00',
        end = '2023-08-02 01:00:00    '
    ).get_data()
    response.data.df
    • Please be noticed that the start and end arguments are in ISO8601 string with UTC only

    Result:

    result.png

    Secondly, you mentioned that you need to call the function multiple times. You may need to delay call (like put sleep for 1-2 seconds) between each call to not overload the requests.

    Thirdly, You can try to increase the timeout value in the RD library configuration file (refinitiv-data.config.json), as shown below. The sample refinitiv-data.config.json is available on GitHub.

    {
        "http": {       
            "request-timeout": 60
        },
        "logs": {
    ...
        }
    ...
    }

    Otherwise, you can change the timeout value by using the following code.

    import refinitiv.data as rd
    rd.get_config()["http.request-timeout"] = 60
    rd.open_session()

Answers

  • Hello @navtej.riyait

    Can you share the code that call the RDP historical-pricing endpoint? Are you using the Data Library (Python or C# or TypeScript) or the Python requests library?

  • import refinitiv.dataplatform as rdp

    --------------------------
    def get_historical_prices(ccy_pair, start_date, end_date):
    #--------------------------------------------------------


    print ('ccy pair: ' + ccy_pair)
    file = pm.credentials_filename

    with open(file) as f:
    cr = js.load(f)


    rdp.open_platform_session(
    cr["app_key"],
    rdp.GrantPassword(
    cr["username"],
    cr["password"]
    )
    )
    #format = '%Y-%m-%d'
    #start_date= start_date.strftime('%Y%m%d %H:%M:%S.%f')
    #end_date = end_date.strftime('%Y%m%d %H:%M:%S.%f')

    #print(start_date)
    #print(end_date)
    #sys.exit()

    start_date_ts = start_date + timedelta(hours=1)
    end_date_ts = end_date + timedelta(hours=1)

    #start_date_ts = '20230801 01:00:00'
    #end_date_ts = '20230802 01:00:00'

    start_date_ts = start_date_ts.strftime('%Y%m%d %H:%M:%S.%f')
    end_date_ts = end_date_ts.strftime('%Y%m%d %H:%M:%S.%f')
    print(start_date_ts)
    print(end_date_ts)
    #sys.exit()

    #ccy_pair ='HRK='
    response = rdp.get_historical_price_summaries(
    universe= ccy_pair,
    interval=rdp.Intervals.ONE_MINUTE,
    # Supported intervals: ONE_MINUTE, FIVE_MINUTES, TEN_MINUTES, THIRTY_MINUTES, ONE_HOUR
    fields = ['BID','ASK'],
    start=start_date_ts,
    end=end_date_ts
    )

    The only thing is that I am calling this function over a 100 times, once for each ccy pair. Really I need to call it once with the list of ccy pair to get market prices.

  • Hi

    I am sourcing daily historical prices for a universe of RICs via RD API. In the response I am getting weekend dates and obviously blank prices. How can I onlt get dates/prices for business days.