Rate¶
-
class
tmval.rate.
Rate
(rate: float = None, pattern: str = None, freq: float = None, interval: float = None, i: float = None, d: float = None, delta: float = None, s: float = None, sd: float = None)[source]¶ The Rate class is TmVal’s core class for representing interest rates. The magnitude of the rate is specified via the rate argument.
The type of interest rate is indicated by providing a value to the pattern argument. Valid patterns are:
Effective Interest
Effective Discount
Nominal Interest
Nominal Discount
Force of Interest
Simple Interest
Simple Discount
For Effective Interest, Effective Discount, Simple Interest, and Simple Discount, an additional argument called interval is used to denote the effective interval. These rates can be created via shortcut arguments i, d, s, and sd. When a shortcut argument is used, the interval defaults to 1 and is not strictly necessary, unless the interval happens to be different.
If you just want to initialize an annual Effective Interest rate, you do not need to use the argument i, simply pass a float object to the Rate class, as in gr=Rate(.05) to define a 5% annually compounded effective interest rate.
For the force of interest, use the shortcut argument delta.
For Nominal Interest and Nominal Discount, you need to provide the compounding frequency via the freq argument.
The compound patterns - Effective Interest, Effective Discount, Nominal Interest, Nominal Discount, and Force of Interest can be converted to each other.
Simple Interest can be converted to another Simple Interest with a different interval. Simple Discount can be converted to another Simple Discount with a different interval. Simple Interest and Simple Discount cannot be converted to each other because they do not correspond to the same accumulation function.
Compound patterns cannot be converted to simple patterns.
The Rate class mimics arithmetic types, so you may perform arithmetic operations on rate objects with other arithmetic types.
- Parameters
rate (float) – The magnitude of the rate.
pattern (str) – The interest rate pattern.
freq (float) – The compounding frequency, in times per year.
interval (float) – The effective interval of the interest rate, in years.
i (float) – Shortcut argument for Effective Interest.
d (float) – Shortcut argument for Effective Discount.
delta (float) – Shortcut argument for Force of Interest.
s (float) – Shortcut argument for Simple Interest.
sd (float) – Shortcut argument for Simple Discount.