Tenor
financepy.utils.tenor
Classes
Tenor
Tenor(tenor_string: str = None)
A class to represent a Tenor such as '1D' or '10Y'. There is a unit
(such as a day or a month) and a number representing how many units are in
the tenor. For example 10Y means 10 years while 120m also means 10 years
We support limited conversion from bigger units to smaller units, which
also uses pretty basic rules such as
1Y = 12M = 12*4 W = 12*4*7 D
so use conversion at your own risk. Specifically Y->M is ok and W->D is
ok but Y->D is clearly not that great
We also support limited arithmetic operations that make Tenors a linear
space over integers (ie you can add tenors
and multiply them by integers )
Methods
units
Returns the units of the tenor.
num_periods
Returns the number of periods in the tenor.
set_units
set_units(self, units: financepy.utils.tenor.TenorUnit)
Set the units for the tenor.
set_num_periods
set_num_periods(self, num)
Set the number of periods for the tenor.
set
set(self, num, units: financepy.utils.tenor.TenorUnit)
Convenience method to set both number and units at once.
as_tenor
as_tenor(cls, str_or_tenor)
Convert a string or Tenor object to a Tenor object.
is_valid
is_valid(self)
Check if the tenor is valid.
convert_to_unit
convert_to_unit(self, new_units: financepy.utils.tenor.TenorUnit)
Convert a tenor to an equivalent tenor in new units. Only
"downcasting" is allowed ie W->D ok, D->W not ok. This can obviously
be improved. Very nominal conversations used, see the code for details
Args:
new_unit (TenorUnit): New unit for the tenor
Raises:
FinError: If units cannot be converted
Returns:
The same tenor in new units
convert_to_same_units
convert_to_same_units(cls, t1_in, t2_in)
No description available.
TenorUnit
TenorUnit(*values)
Inherits from: Enum
Represents the different units of time in months for a tenor.
Generated automatically from the FinancePy source code.
Do not edit this file manually.