Schedules functions

Contains utility functions to generate rebalancing schedules:

azapy.Util.schedule.schedule_offset(sdate='2010-01-01', edate='today', freq='Q', noffset=-3, fixoffset=-1, calendar=None, hlength=1.25)

Creates a simple schedule (‘Droll’, ‘Dfix’) with an offset start.

Parameters:
sdatestr, optional

Start date (reference) to which the offset is added. The default is ‘2010-01-01’.

edatestr, optional

End date (reference) of the schedule. The default is ‘today’.

freqstr, optional

Rolling period. It can take 2 values: ‘Q’ for quarterly and ‘M’ for monthly rolling periods. The default is ‘Q’.

noffsetint, optional

Offset in number of business days for Droll relative to the end of calendar period (quarter or month). The default is -3.

fixoffsetint, optional

Offset in number of business days for Dfix relative to Droll. It can be zero or negative. The default is -1.

calendarnumpy.busdaycalendar, optional

Business days calendar. If is it None then the calendar will be set to NYSE business calendar. The default is None.

hlengthfloat, optional

Offset, in number of years, for first ‘Droll’ relative to ‘sdate’. A fractional value will be rounded to an integer number of months via round(hlength * 12, 0). hlength must be non-negative. The default is 1.25 years.

Returns:
`pandas.DataFrame`Table containing 2 datetime columns
  • ‘Droll’ the rolling date,

  • ‘Dfix’ the fixing date.

azapy.Util.schedule.schedule_roll(sdate='2010-01-01', edate='today', freq='Q', noffset=-3, fixoffset=-1, calendar=None, hlength=1.25)

Creates a schedule with rolling history: ‘Droll’, ‘Dfix’ and ‘Dhist’.

Parameters:
sdatestr, optional

Start date (reference) of the schedule. The default is ‘2010-01-01’.

edatestr, optional

End date (reference) of the schedule. The default is ‘today’.

freqstr, optional

Rolling period. It can take 2 values: ‘Q’ for quarterly and ‘M’ for monthly rolling periods. The default is ‘Q’.

noffsetint, optional

Offset in number of business days for Droll relative to the end of calendar period (quarter or month). The default is -3.

fixoffsetint, optional

Offset in number of business days for Dfix relative to Droll. It can be zero or negative. The default is -1.

calendarnumpy.busdaycalendar, optional

Business days calendar. If is it None then the calendar will be set to NYSE business calendar. The default is None.

hlengthfloat, optional

Offset in number of years for ‘Dhist’ relative to ‘Dfix’. A fractional value will be rounded to an integer number of months via round(hlength * 12, 0). hlength must be non-negative. The default is 1.25 years.

Returns:
`pandas.DataFrame`Table containing 3 datetime columns,
  • ‘Droll’ the rolling date,

  • ‘Dfix’ the fixing date,

  • ‘Dhist’ start date for calibration period.

azapy.Util.schedule.schedule_simple(sdate='2010-01-01', edate='today', freq='Q', noffset=-3, fixoffset=-1, calendar=None)

Creates a simple schedule: ‘Droll’, ‘Dfix’.

Parameters:
sdatestr, optional

Start date (reference) of the schedule. The default is ‘2010-01-01’.

edatestr, optional

End date (reference) of the schedule. The default is ‘today’.

freqstr, optional

Rolling period. It can take 2 values: ‘Q’ for quarterly and ‘M’ for monthly rolling periods. The default is ‘Q’.

noffsetint, optional

Offset in number of business days for Droll relative to the end of calendar period (quarter or month). The default is -3.

fixoffsetint, optional

Offset in number of business days for Dfix relative to Droll. It must be <=0. The default is -1.

calendarnumpy.busdaycalendar, optional

Business days calendar. If is it None then the calendar will be set to NYSE business calendar. The default is None.

Returns:
`pandas.DataFrame`Table containing 2 datetime columns,
  • ‘Droll’ the rolling date,

  • ‘Dfix’ the fixing date.

TOP

Example schedule functions call

# Example of how to call schedule functions
import azapy as az

sdate = '2015-01-01'
edate = '2020-12-31'

sims = az.schedule_simple(sdate=sdate, edate=edate)
print(f"simple schedule\n{sims}")

srol = az.schedule_roll(sdate=sdate, edate=edate)
print(f"rolling history schedule\n{srol}")

soff = az.schedule_offset(sdate=sdate, edate=edate)
print(f"simple schedule with offset start\n{soff}")

TOP