LSEG Data Library for Python

holidays

The holidays function gets the holidays between defined start and end dates using one or more specified calendars.

Module

lseg.data

Syntax

holidays(start_date, end_date, calendars, currencies)

Parameters

Value Description Data type Optional Default value
start_date Calculation start date. str, date, datetime, timedelta Yes None
end_date Calculation end date. str, date, datetime, timedelta Yes None
calendars Calendars to determine the working days and national holidays for particular countries. List[str] Yes None
currencies Currencies to use for calculation of the date for the working day or weekend. List[str] Yes None

Returned value

The HolidaysResponse object with the following structure:

Name Date type Description
df pandas DataFrame Response dataframe that contains holidays for particular calendars
calendars Dict[str, HolidayCalendar] Calendars from which the holidays were retrieved
offset pandas offsets.CustomBusinessDay Offset that representing custom business days excluding holidays

Usage

The following example demonstrates how to retrieve holidays between a particular start and end date from two calendars:

import datetime

import lseg.data as ld


# open session
ld.open_session()

holidays_response = ld.dates_and_calendars.holidays(
    start_date=datetime.datetime(2019, 11, 20),
    end_date=datetime.datetime(2020, 2, 20),
    calendars=["EMU", "GER"],
)

print(holidays_response.df.to_string())

# close session
ld.close_session()

This example produces the following output:

                      name   calendars countries   tag       date
0            Christmas Day  [EMU, GER]   [, DEU]  None 2019-12-25
1  Day After Christmas Day       [EMU]        []  None 2019-12-26
2               Boxing Day       [GER]     [DEU]  None 2019-12-26
3           New Year's Day  [EMU, GER]   [, DEU]  None 2020-01-01
4            Christmas Eve       [GER]     [DEU]  None 2019-12-24
5           New Year's Eve       [GER]     [DEU]  None 2019-12-31

offsets.CustomBusinessDay

150 words (0:47 mins)