finpricing.utils.date_generator#

Module Contents#

Classes#

DateGenerator

class finpricing.utils.date_generator.DateGenerator[source]#
static generate_extended(start_date: datetime.date | finpricing.utils.date.Date, maturity_date: datetime.date | finpricing.utils.date.Date, time_interval: finpricing.utils.date.TimeInterval | str, stub_at_end: bool)[source]#

generate a list of dates from start_date to maturity_date with given time_interval

Note

if stub_at_end is True, the dates will be generated from start_date and roll forward until and after maturity_date if stub_at_end is False, the dates will be generated from maturity_date and roll backward until and before start_date

Parameters:
  • start_date (Union[datetime.date, Date]) – start date

  • maturity_date (Union[datetime.date, Date]) – maturity date

  • time_interval (Union[TimeInterval, str]) – time interval

  • stub_at_end (bool) – whether the stub is at the end of the period

static generate_cds(start_date, maturity_date, cds_style: finpricing.utils.cds_style.CDSStyle, stub_at_end: bool = False)[source]#

generate a list of dates from start_date to maturity_date with given cds_style

Note

Most likely, the stub is at the end of the period. In a NO_STUB case, the first date will be removed. So the first date will be after start_date.

static generate_cds_adjust(start_date, maturity_date, cds_style: finpricing.utils.cds_style.CDSStyle, stub_at_end: bool = False)[source]#

generate accrual start dates, accrual end dates, and calendar adjusted payment dates for a cds contract

NOTE only the payment dates are adjusted!

static generate_cds_maturity_date(market_date: finpricing.utils.date.Date | datetime.date, maturity_date: finpricing.utils.date.Date | datetime.date, term_style: str = None)[source]#

return the adjusted maturity date for a cds contract by its term style

FIXME This is not effectively implemented yet. It seems IMM CORPORATE returns the same maturity date as the input.

static generate_cds_effective_date(market_date: finpricing.utils.date.Date | datetime.date, maturity_date: finpricing.utils.date.Date | datetime.date, cds_style: finpricing.utils.cds_style.CDSStyle | str)[source]#

generate the effective date for a cds contract when market date is in between coupon dates