Finance - Maple Programming Help

Home : Support : Online Help : Mathematics : Finance : Cash Flow Analysis : Finance/Duration

Finance

 Duration
 calculate the duration of a set of cash flows or bonds

 Calling Sequence Duration(cashflows, rate, opts) Duration(bond, rate, opts)

Parameters

 cashflows - cash flow data structure or a list of cash flow 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 evaluation, compounding, or daycounter; specify options for the Duration 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 = Actual360, Actual365Fixed, AFB, Bond, Euro, Historical, ISDA, ISMA, OneDay, Simple, Thirty360BondBasis, Thirty360EuroBondBasis, Thirty360European, Thirty360Italian, Thirty360USA, or a day counter data structure created using the DayCounter constructor -- This option provides a day counter that will be used to represent the period between two dates as a fraction of the year. The default day count convention can be set using the Settings command.
 • evaluationdate =  a string containing a date specification in a format recognized by ParseDate or a date data structure -- This option specifies the evaluation date. This is set to the global evaluation date by default (see EvaluationDate).

Description

 • The Duration command calculates the duration of a set of cash flows or a portfolio of bonds.
 • For a set of cash flows $C\left(t\right)$ the simple duration is defined as

$\frac{{\sum }_{t}\phantom{\rule[-0.0ex]{5.0px}{0.0ex}}tC\left(t\right){P}_{t}}{{\sum }_{t}\phantom{\rule[-0.0ex]{5.0px}{0.0ex}}C\left(t\right){P}_{t}}$

where ${P}_{t}$ is the discount at time $t$ implied by the given interest rate. There are at least two ways to calculate ${P}_{t}$. One can either use a yield term structure or an internal rate of return of the set of cash flows. In the latter case one would obtain the Macaulay duration.

 • A bond's duration is defined in a similar way. It can also be interpreted as the weighted first derivative of the price:

$\frac{\frac{ⅆ}{ⅆr}B\left(r\right)}{B\left(r\right)}$

 • Duration is useful as a measure of sensitivity of a bond's or cash flows' price to interest rate movements.
 • The parameter cashflows is a cash flow data structure or a list of cash flow data structures.
 • The parameter bond must be a fixed- or floating-rate bond data structure.

Examples

 > $\mathrm{with}\left(\mathrm{Finance}\right):$
 > $\mathrm{SetEvaluationDate}\left("January 1, 2005"\right):$
 > $\mathrm{paymentdate}≔"January 1, 2007"$
 ${\mathrm{paymentdate}}{≔}{"January 1, 2007"}$ (1)
 > $\mathrm{cashflow1}≔\left[\mathrm{seq}\left(\mathrm{SimpleCashFlow}\left(100,\mathrm{AdvanceDate}\left(\mathrm{paymentdate},i,\mathrm{Years}\right)\right),i=1..10\right)\right]$
 ${\mathrm{cashflow1}}{≔}\left[{\mathrm{100. on January 1, 2008}}{,}{\mathrm{100. on January 1, 2009}}{,}{\mathrm{100. on January 1, 2010}}{,}{\mathrm{100. on January 1, 2011}}{,}{\mathrm{100. on January 1, 2012}}{,}{\mathrm{100. on January 1, 2013}}{,}{\mathrm{100. on January 1, 2014}}{,}{\mathrm{100. on January 1, 2015}}{,}{\mathrm{100. on January 1, 2016}}{,}{\mathrm{100. on January 1, 2017}}\right]$ (2)
 > $\mathrm{Duration}\left(\mathrm{cashflow1},0.03,\mathrm{evaluationdate}="January 1, 2005"\right)$
 ${7.252874161}$ (3)
 > $\mathrm{Duration}\left(\mathrm{cashflow1},0.03,\mathrm{evaluationdate}="January 1, 2004"\right)$
 ${8.252874161}$ (4)

Here is another example.

 > $\mathrm{nominalamt}≔100$
 ${\mathrm{nominalamt}}{≔}{100}$ (5)
 > $\mathrm{rate}≔0.05$
 ${\mathrm{rate}}{≔}{0.05}$ (6)
 > $\mathrm{startdate}≔"January 1, 2006"$
 ${\mathrm{startdate}}{≔}{"January 1, 2006"}$ (7)
 > $\mathrm{cashflow2}≔\left[\mathrm{seq}\left(\mathrm{FixedRateCoupon}\left(\mathrm{nominalamt},\mathrm{rate},\mathrm{startdate},\mathrm{AdvanceDate}\left(\mathrm{startdate},i,\mathrm{Years}\right)\right),i=1..10\right)\right]$
 ${\mathrm{cashflow2}}{≔}\left[{\mathrm{5. on January 1, 2007}}{,}{\mathrm{10. on January 1, 2008}}{,}{\mathrm{15. on January 1, 2009}}{,}{\mathrm{20. on January 1, 2010}}{,}{\mathrm{25. on January 1, 2011}}{,}{\mathrm{30. on January 1, 2012}}{,}{\mathrm{35. on January 1, 2013}}{,}{\mathrm{40. on January 1, 2014}}{,}{\mathrm{45. on January 1, 2015}}{,}{\mathrm{50. on January 1, 2016}}\right]$ (8)

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

 > $\mathrm{Duration}\left(\mathrm{cashflow2},0.03,\mathrm{evaluationdate}="January 1, 2005"\right)$
 ${7.816330091}$ (9)

Compute the Macaulay duration for the previous cash flow.

 > $\mathrm{irr}≔\mathrm{InternalRateOfReturn}\left(\mathrm{cashflow2},15\right)$
 ${\mathrm{irr}}{≔}{0.4458188048}$ (10)
 > $\mathrm{Duration}\left(\mathrm{cashflow2},\mathrm{irr}\right)$
 ${5.076090247}$ (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{Duration}\left(\mathrm{bond},0.03,\mathrm{evaluationdate}="January 5, 2000"\right)$
 ${9.556636250}$ (14)
 > $\mathrm{Duration}\left(\mathrm{cflows},0.03,\mathrm{evaluationdate}="January 5, 2000"\right)$
 ${9.556636250}$ (15)

Compatibility

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