Interest-Discount Rate Conversions

In addition to the concept of nominal interest, there’s also nominal discount. In interest theory, various relationships between interest rates, discount rates, and their nominal counterparts can be derived:

d = 1 - \left(1 - \frac{d^{(m)}}{m}\right)^m \\

d^{(m)} = m[1-(1-d)^{\frac{1}{m}}] \\

1 = \left(1 - \frac{d^{(m)}}{m} \right) \left(1 + \frac{i^{(m)}}{m} \right) \\

0 = \frac{i^{(m)}}{m} - \frac{d^{(m)}}{m} - \frac{i^{(m)}}{m}\frac{d^{(m)}}{m} \\

\frac{i^{(m)}}{m} = \frac{\frac{d^{(m)}}{m}}{1 - \frac{d^{(m)}}{m}} \\

\frac{d^{(m)}}{m} = \frac{\frac{i^{(m)}}{m}}{1 + i^{(m)}{m}} \\

\left(1 + \frac{i^{n}}{n}\right)^n = 1 + i = (1-d)^{-1} = \left(1 - \frac{d^{(p)}}{p}\right)^{-p}

It would cumbersome to have to use over a dozen different functions to convert one rate to another. Fortunately, the method convert_rate() of the Rate class allows us to convert between any of these rates. Now, you can see why it’s useful to have interest rates represent by a custom data type, rather than a float object.

To a convert a rate from one pattern to another, take the following steps:

  1. Supply a desired pattern to convert to (‘Effective Interest’, ‘Effective Discount, ‘Nominal Interest’, ‘Nominal Discount’)

  2. If the desired pattern is nominal, supply a compounding frequency

  3. If the desired pattern is an effective interest or discount rate, supply a desired interval

Examples

Suppose we have a nominal discount rate of d^{(12)} = .06 compounded monthly. What is the equivalent nominal interest rate compounded quarterly?

In [1]: from tmval import Rate

In [2]: nom_d = Rate(
   ...:     rate=.06,
   ...:     pattern="Nominal Discount",
   ...:     freq=12
   ...: )
   ...: 

In [3]: print(nom_d)
Pattern: Nominal Discount
Rate: 0.06
Compounding Frequency: 12 times per year

In [4]: nom_i = nom_d.convert_rate(
   ...:     pattern="Nominal Interest",
   ...:     freq=4
   ...: )
   ...: 

In [5]: print(nom_i)
Pattern: Nominal Interest
Rate: 0.06060503776426174
Compounding Frequency: 4 times per year

Now, let’s convert it to an annual effective interest rate:

In [6]: i = nom_i.convert_rate(
   ...:     pattern="Effective Interest",
   ...:     interval=1
   ...: )
   ...: 

In [7]: print(i)
Pattern: Effective Interest
Rate: 0.061996366970891614
Unit of time: 1 year

Now, let’s convert it back to a nominal discount rate compounded monthly:

In [8]: nom_d2 = i.convert_rate(
   ...:     pattern="Nominal Discount",
   ...:     freq=12
   ...: )
   ...: 

In [9]: print(nom_d2)
Pattern: Nominal Discount
Rate: 0.06000000000000005
Compounding Frequency: 12 times per year