LSEG Data Library for Python

date_schedule

The date_schedule function gets a list of dates based on the provided values, which can then be used as inputs for other functions.

Module

lseg.data

Syntax

date_schedule(frequency, start_date, end_date, calendar_day_of_month, calendars, currencies, day_of_week, count)

Parameters

Value Description Data type Optional Default value
frequency The frequency of dates in the predetermined period. str, DateScheduleFrequency Yes None
start_date The start date of the predetermined list of dates. str, date, datetime, timedelta Yes None
end_date The end date of the predetermined list of dates. str, date, datetime, timedelta Yes None
calendar_day_of_month The number of the days of the month to which the dates are adjusted. int 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
day_of_week The day of week to which dates are adjusted str, DayOfWeek Yes None
count The number of dates from the start date to retrieve. int Yes None

Returned value

List of dates in NumPy datetime format.

Usage

The following example demonstrates how to get 10 random dates from 30.04.2019 that are Tuesdays, for two different calendars:

import datetime

import lseg.data as ld
from lseg.data import dates_and_calendars


# open session
ld.open_session()

dates = ld.dates_and_calendars.date_schedule(
    start_date=datetime.date(2019, 4, 30),
    count=10,
    frequency=dates_and_calendars.DateScheduleFrequency.WEEKLY,
    calendars=["EMU", "GER"],
    day_of_week=dates_and_calendars.DayOfWeek.TUESDAY,
)

print(dates)

# close session
ld.close_session()

This example produces the following output:

[numpy.datetime64('2019-05-07'), numpy.datetime64('2019-05-14'), numpy.datetime64('2019-05-21'), numpy.datetime64('2019-05-28'), numpy.datetime64('2019-06-04'), numpy.datetime64('2019-06-11'), numpy.datetime64('2019-06-18'), numpy.datetime64('2019-06-25'), numpy.datetime64('2019-07-02'), numpy.datetime64('2019-07-09')]

DayOfWeek

DateScheduleFrequency

NumPy datetime

195 words (1:02 mins)