convexity

Evaluates the convexity for a security.

Synopsis

convexity (settlement, maturity, couponRate, t_yield, frequency, basis)

Required Arguments

date settlement (Input)
The date on which payment is made to settle a trade. For a more detailed discussion on dates see the Usage Notes section of this chapter.
date maturity (Input)
The date on which the bond comes due, and principal and accrued interest are paid. For a more detailed discussion on dates see the Usage Notes section of this chapter.
float couponRate (Input)
Annual interest rate set forth on the face of the security; the coupon rate.
float t_yield (Input)
Annual yield of the security.
int frequency (Input)
Frequency of the interest payments. It should be one of ANNUAL, SEMIANNUAL or QUARTERLY. For a more detailed discussion on frequency see the Usage Notes section of this chapter.
int basis (Input)
The method for computing the number of days between two dates. It should be one of DAY_CNT_BASIS_ACTUALACTUAL, DAY_CNT_BASIS_NASD, DAY_CNT_BASIS_ACTUAL360, DAY_CNT_BASIS_ACTUAL365, or DAY_CNT_BASIS_30E360. For a more detailed discussion see the Usage Notes section of this chapter.

Return Value

The convexity for a security. If no result can be computed, NaN is returned.

Description

Function convexity computes the convexity for a security. Convexity is the sensitivity of the duration of a security to changes in yield.

It is computed using the following:

\[\frac {\displaystyle\frac{1}{(q * \mathit{frequency})^2} \left\{ \displaystyle\sum_{t=1}^{n}t(t+1) \left(\frac{\mathit{rate}}{\mathit{frequency}}\right)q^{-t} + n(n+1)q^{-n} \right\}} {\displaystyle\sum_{t=1}^{n}\left(\frac{\mathit{rate}}{\mathit{frequency}}\right)q^{-t} + q^{-n}}\]

where n is calculated from couponNumber, and \(q=1+\tfrac{\mathit{yield}}{\mathit{frequency}}\).

Example

In this example, convexity computes the convexity for a security with the settlement date of July 1, 1990, and maturity date of July 1, 2000, using the Actual/365 day count method.

from __future__ import print_function
from numpy import *
from datetime import date
from pyimsl.math.convexity import convexity, DAY_CNT_BASIS_ACTUAL365, SEMIANNUAL

coupon = .075
yield_val = .09
frequency = SEMIANNUAL
basis = DAY_CNT_BASIS_ACTUAL365

settlement = date(1990, 7, 1)
maturity = date(2000, 7, 1)

convexity_value = convexity(settlement, maturity,
                            coupon, yield_val, frequency, basis)
print("The convexity of the bond with", end=' ')
print("semiannual interest payments is %.4f." % (convexity_value))

Output

The convexity of the bond with semiannual interest payments is 59.4050.