How to Exclude Weekend Dates for Historical Prices via RD API Calls

I am sourcing daily historical prices for a universe of RICs (bulk RICs API call) via RD API. In the response I am getting weekend dates and obviously blank prices. How can I exclude the weekend dates in the response and only get dates/prices for business days.

Tagged:

Best Answer

  • aramyan.h
    Answer ✓

    Hi @navtej.riyait ,


    This is the response I received and there doesn't seem to be weekends. Please note the dates should be in string format.

    import refinitiv.data as rd
    from refinitiv.data.content import historical_pricing

    rics_list = ['GBP=', 'MXN=']
    start_date_ts = '2024-08-01'
    end_date_ts = '2024-08-06'


    try:
    response = historical_pricing.summaries.Definition(
    rics_list,
    start=start_date_ts,
    end=end_date_ts,
    #fields = fields_list,
    interval= historical_pricing.Intervals.DAILY).get_data() #historical_pricing.Intervals.ONE_MINUTE).get_data()
    resp = response.data.df

    except rd.errors.RDError as e:
    print("Error code :", e.code)
    print("Error message:", e.message)

    resp

    screenshot-2024-08-07-at-123433.png


    Best regards,

    Haykaz

Answers

  • Hi @navtej.riyait ,

    would you mind posting the example code you are using? As you see from the code below the library doesn't return the days of holidays:

    rd.get_history('AAPL.O')


    screenshot-2024-08-07-at-104154.png

    The reason you might see NAs can be because there is data for another RIC for that day. In that case for other RICs you may see NAs.


    So if you can post the code you are using, including the RICs, I will have a look.


    Best regards,

    Haykaz

  • import refinitiv.data as rd

    from refinitiv.data.content import historical_pricing

    rics_list = ['GBP=', 'MXN=']

    start_date_ts = 20240801

    end_date_ts = 20240806


    try:

    response = historical_pricing.summaries.Definition(

    rics_list,

    start=start_date_ts,

    end=end_date_ts,

    #fields = fields_list,

    interval= historical_pricing.Intervals.DAILY).get_data() #historical_pricing.Intervals.ONE_MINUTE).get_data()

    resp = response.data.df

    except rd.errors.RDError as e:

    print("Error code :", e.code)

    print("Error message:", e.message)

    resp = pd.DataFrame()