question

Upvotes
Accepted
1 0 0 0

How can I find all the trading day dates between a given start and end date.

Hi!
I want to find the list of all trading dates between 2 given dates, say between 1 and 18 Feb 2021, should return me

['2021-02-01', '2021-02-02', '2021-02-03', '2021-02-04', '2021-02-05', '2021-02-08', '2021-02-09', '2021-02-10', '2021-02-11', '2021-02-12', '2021-02-15', '2021-02-16', '2021-02-17', '2021-02-18']
eikoneikon-com-api
icon clock
10 |1500

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

1 Answer

Upvotes
Accepted
39.2k 75 11 27

You can use Refinitiv Data Platform Libraries. Here's a quick example

import refinitiv.dataplatform as rdp
rdp_session = rdp.open_desktop_session('MY_APP_KEY')
url = "https://api.refinitiv.com/data/quantitative-analytics-dates-and-calendars/beta1/date-schedule"
endpoint = rdp.Endpoint(session = rdp_session, 
                        url = url)
method = rdp.Endpoint.RequestMethod.POST
body_parameters = {"start": "2021-02-01",
                   "end": "2021-02-20",
                   "frequency": "Daily",
                   "dateAdjustment": {"calendars":["IND"]}}
resp = endpoint.send_request(method = method, 
                             body_parameters = body_parameters)
                             
if resp.is_success:
    print(resp.data.raw['dates'])

The above example returns the list of trading days taking into account public (aka bank) holidays in India.

Another possibility is pandas-market-calendars library. This library can access calendars for numerous exchanges including Bombay Stock Exchange.

icon clock
10 |1500

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

Click below to post an Idea Post Idea