question

Upvotes
Accepted
1 0 0 2

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.

rdp-api#content
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
7.1k 18 2 8

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


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
7.1k 18 2 8

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


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
1 0 0 2

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()

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.