LSEG Data Library for Python

add_period

The add_period function retrieves the updated date, based on the provided start date and particular time period or calendar values.

Module

lseg.data

Syntax

add_period(start_date, period, calendars, currencies, date_moving_convention, end_of_month_convention)

Parameters

Value Description Data type Optional Default value
start_date Start date of the calculation. str, date, datetime, timedelta Yes None
period Calculation time period. str 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
date_moving_convention Convention for adjusting the dates. str, DateMovingConvention Yes None
end_of_month_convention Possible values for the end of month. str, EndOfMonthConvention Yes None

Returned value

Date in NumPy datetime format.

Usage

The following example demonstrates how to retrieve data using the one-year time period and particular date moving and end of month conventions:

import datetime

import retinitiv.data as rd
from lseg.data import dates_and_calendars

# open session
ld.open_session()

added_period = ld.dates_and_calendars.add_periods(
    start_date=datetime.date(2014, 1, 1),
    period="1Y",
    calendars=["BAR", "KOR"],
    date_moving_convention=dates_and_calendars.DateMovingConvention.NEXT_BUSINESS_DAY,
    end_of_month_convention=dates_and_calendars.EndOfMonthConvention.LAST28
)

print(added_period)

# close session

ld.close_session()

This example produces the following output:

2015-01-02

DateMovingConvention

EndOfMonthConvention

NumPy datetime

141 words (0:45 mins)