tensorquant.timehandles package

Submodules

tensorquant.timehandles.daycounter module

class tensorquant.timehandles.daycounter.DayCounter(day_counter_convention: DayCounterConvention, include_last_day: bool = False)[source]

Bases: object

day_count(d1: date, d2: date)[source]
year_days(year: int)[source]
year_fraction(d1: date, d2: date)[source]

tensorquant.timehandles.grid module

class tensorquant.timehandles.grid.DateGrid(dates: list[date], daycounter_convention: DayCounterConvention)[source]

Bases: object

property dates
property daycounter
property daycounter_convention
property times

tensorquant.timehandles.schedule module

class tensorquant.timehandles.schedule.ScheduleGenerator(calendar: Calendar, business_day_convention: BusinessDayConvention)[source]

Bases: object

generate(start: date, end: date, tenor: int, time_unit: TimeUnit)[source]

tensorquant.timehandles.targetcalendar module

class tensorquant.timehandles.targetcalendar.TARGET[source]

Bases: Calendar

A class to represent TARGET calendar

is_business_day(d: date) bool[source]

Determine if a given date is a business day.

Parameters:

ddate

The date to check.

Returns:

bool:

True if the given date is a business day, False otherwise.

tensorquant.timehandles.tqcalendar module

class tensorquant.timehandles.tqcalendar.Calendar[source]

Bases: ABC

The abstract class for calendar implementations.

adjust(d: date, c: BusinessDayConvention)[source]

Adjust date based on the business day convention.

Parameters:

d (date): The date to adjust. c (BusinessDayConvention): The business day convention.

Returns:

date: The adjusted date.

advance(start_date: date, period: int, time_unit: TimeUnit, convention: BusinessDayConvention, end_of_month: bool = False)[source]

Advance a given start date by a specified period using the given time unit and business day convention.

Parameters:

start_date (date): The starting date. period (int): The number of time units to advance the start date by. time_unit (TimeUnit): The unit of time to use for advancing the start date. convention (BusinessDayConvention): The business day convention to use for adjusting the dates. end_of_month (bool, optional): Whether to adjust to the end of the month if the original start date is at the end of the month. Defaults to False.

Returns:

date: The advanced date.

end_of_month(d: date) int[source]

Get the last day of the month for a given date.

Parameters:

d (date): The date for which to find the last day of the month.

Returns:

int: The last day of the month.

abstract is_business_day(d: date)[source]

Check if a given date is a business day.

Parameters:

d (date): The date to check.

Returns:

bool: True if the given date is a business day, False otherwise.

is_end_of_month(d: date) bool[source]

Check if a given date is the end of the month.

Parameters:

d (date): The date to check.

Returns:

bool: True if the given date is the end of the month, False otherwise.

is_holiday(d: date) bool[source]

Check if a given date is a holiday.

Parameters:

d (date): The date to check.

Returns:

bool: True if the given date is a holiday, False otherwise.

is_weekend(d: date) bool[source]

Check if a given date is a weekend.

Parameters:

d (date): The date to check.

Returns:

bool: True if the given date is a weekend, False otherwise.

tensorquant.timehandles.utils module

class tensorquant.timehandles.utils.BusinessDayConvention(value)[source]

Bases: Enum

Enumeration of business-day conventions.

Following = 'Following'
HalfMonthModifiedFollowing = 'Half-Month Modified Following'
ModifiedFollowing = 'Modified Following'
ModifiedPreceding = 'Modified Preceding'
Nearest = 'Nearest'
Preceding = 'Preceding'
Unadjusted = 'Unadjusted'
class tensorquant.timehandles.utils.CompoundingType(value)[source]

Bases: Enum

An enumeration.

Compounded = 'compounded'
Continuous = 'continuous'
Simple = 'simple'
class tensorquant.timehandles.utils.DayCounterConvention(value)[source]

Bases: Enum

An enumeration.

Actual360 = 'Actual360'
Actual365 = 'Actual365'
ActualActual = 'ActualActual'
Thirty360 = 'Thirty360'
Thirty360E = 'Thirty360E'
class tensorquant.timehandles.utils.Frequency(value)[source]

Bases: Enum

An enumeration.

Annual = 1
Bimonthly = 6
Biweekly = 26
Daily = 365
EveryFourthMonth = 3
EveryFourthWeek = 13
Monthly = 12
NoFrequency = -1
Once = 0
OtherFrequency = 999
Quarterly = 4
Semiannual = 2
Weekly = 52
class tensorquant.timehandles.utils.Settings[source]

Bases: object

A class to represent general settings

evaluation_date = datetime.date(2026, 5, 26)
class tensorquant.timehandles.utils.TimeUnit(value)[source]

Bases: Enum

Enumeration of time-units.

Days = 'Days'
Months = 'Months'
Weeks = 'Weeks'
Years = 'Years'
tensorquant.timehandles.utils.decode_term(term: str)[source]

Module contents