 Convexity - Maple Help

Finance

 Convexity
 calculate the convexity of a set of cash flows or a bond Calling Sequence Convexity(cashflows, rate, opts) Convexity(bond, rate, opts) Parameters

 cashflows - data structure created using the SimpleCashFlow constructor or a list of such data structures; cash flows bond - fixed or floating rate bond data structure; bond rate - non-negative real number; interest rate opts - equations of the form option = value where option is one of evaluationdate, compounding or daycounter; specify options for the Convexity command Options

 • compounding = Simple, Continuous, Annual, Semiannual, EveryFourthMonth, Quarterly, Bimonthly, Monthly, SimpleThenAnnual, SimpleThenSemiannual, SimpleThenEveryFourthMonth, SimpleThenQuarterly, SimpleThenBimonthly, or SimpleThenMonthly -- This option specifies the compounding type for the given interest rate.
 • daycounter = a name representing a supported day counter (e.g. ISDA, Simple) or a day counter data structure created using the DayCounter constructor -- This option provides a day counter which will be used to convert the period between two dates as a fraction of the year.
 • evaluationdate =  a string containing a date specification in a format recognized by ParseDate or a Date data structure -- This option specifies the evaluation date. By default this is set to the global evaluation date (see EvaluationDate). Description

 • The Convexity command calculates the convexity of a set of cash flows or a bond.
 • For a set of cash flows ${C}_{i}\left(t\right)$ the convexity is defined as

$\frac{{\sum }_{i}{t}^{2}{C}_{i}\left(t\right){P}_{t}}{{\sum }_{i}{C}_{i}\left(t\right){P}_{t}}$

 where ${P}_{t}$ is the discount factor at time $t$ implied by the given interest rate.
 • A bond's convexity is defined as the weighted second derivative of the price function with respect to the interest rate:

$\frac{\frac{{ⅆ}^{2}}{ⅆ{r}^{2}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}B\left(r\right)}{B\left(r\right)}$

 • The parameter cashflows is a cash flow or a list of cash flows (see FixedRateCoupon, InArrearIndexedCoupon, ParCoupon, SimpleCashFlow, or UpFrontIndexedCoupon).
 • The parameter bond must be a fixed- or floating-rate bond data structure (see FixedCouponBond, FloatingRateBond, ZeroCouponBond). Examples

 > $\mathrm{with}\left(\mathrm{Finance}\right):$
 > $\mathrm{SetEvaluationDate}\left("Jan-01-2005"\right):$
 > $\mathrm{paymentdate}≔"Jan-02-2007"$
 ${\mathrm{paymentdate}}{≔}{"Jan-02-2007"}$ (1)
 > $\mathrm{cashflow1}≔\mathrm{SimpleCashFlow}\left(100,\mathrm{paymentdate}\right)$
 ${\mathrm{cashflow1}}{≔}{\mathrm{100. on January 2, 2007}}$ (2)
 > $\mathrm{Convexity}\left(\mathrm{cashflow1},0.03,\mathrm{evaluationdate}="Jan-01-2005"\right)$
 ${4.010966410}$ (3)
 > $\mathrm{Convexity}\left(\mathrm{cashflow1},0.03,\mathrm{evaluationdate}="Jan-01-2004"\right)$
 ${9.016445862}$ (4)

Here is another example.

 > $\mathrm{nominalamt}≔100$
 ${\mathrm{nominalamt}}{≔}{100}$ (5)
 > $\mathrm{rate}≔0.05$
 ${\mathrm{rate}}{≔}{0.05}$ (6)
 > $\mathrm{paymentdate}≔"Jan-01-2015"$
 ${\mathrm{paymentdate}}{≔}{"Jan-01-2015"}$ (7)
 > $\mathrm{startdate}≔"Jan-01-2006"$
 ${\mathrm{startdate}}{≔}{"Jan-01-2006"}$ (8)
 > $\mathrm{enddate}≔"Jan-01-2010"$
 ${\mathrm{enddate}}{≔}{"Jan-01-2010"}$ (9)
 > $\mathrm{coupon}≔\mathrm{FixedRateCoupon}\left(\mathrm{nominalamt},\mathrm{rate},\mathrm{startdate},\mathrm{enddate},\mathrm{paymentdate}\right)$
 ${\mathrm{coupon}}{≔}{\mathrm{20. on January 1, 2015}}$ (10)

Compute the value of this cash flow on January 01, 2005.

 > $\mathrm{Convexity}\left(\mathrm{coupon},0.03,\mathrm{evaluationdate}="Jan-01-2005"\right)$
 ${100.}$ (11)

Here is an example using bonds.

 > $\mathrm{bond}≔\mathrm{FixedCouponBond}\left(100,5,\mathrm{Years},0.05\right)$
 ${\mathrm{bond}}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (12)
 > $\mathrm{cflows}≔\mathrm{CashFlows}\left(\mathrm{bond}\right)$
 ${\mathrm{cflows}}{≔}\left[{\mathrm{5. on \text{'}January 1, 2006\text{'}}}{,}{\mathrm{5. on \text{'}January 1, 2007\text{'}}}{,}{\mathrm{5. on \text{'}January 1, 2008\text{'}}}{,}{\mathrm{5. on \text{'}January 1, 2009\text{'}}}{,}{\mathrm{5. on \text{'}January 1, 2010\text{'}}}{,}{\mathrm{100. on \text{'}January 1, 2010\text{'}}}\right]$ (13)
 > $\mathrm{Convexity}\left(\mathrm{bond},0.03,\mathrm{evaluationdate}="Jan-05-2000"\right)$
 ${92.45245571}$ (14)
 > $\mathrm{Convexity}\left(\mathrm{cflows},0.03,\mathrm{evaluationdate}="Jan-05-2000"\right)$
 ${92.45245571}$ (15) Compatibility

 • The Finance[Convexity] command was introduced in Maple 15.