Compute the net present value, Macaulay Duration, Convexity and Monetary
duration of a given cash flow pattern according to a given discount curve
and day count convention etc.
Pre-requirements:
- installed octave financial package
- custom functions timefactor, discount_factor, interpolate_curve,
and convert_curve_rates
Input and output variables:
- valuation_date: valuation date (preferred as datenum)
- cashflow_dates: cashflow_dates is a 1xN vector with all
timesteps of the cash flow pattern
- cashflow_values: cashflow_values is a MxN matrix with cash flow
pattern.
- spread_constant: a constant spread added to the total yield
extracted from discount curve and spread curve (can be used to spread over yield)
- discount_nodes: discount_nodes is a 1xN vector with all timesteps of
the given curve
- discount_rates: discount_rates is a MxN matrix with discount curve
rates defined in columns. Each row contains a specific scenario with different
curve structure
- basis: OPTIONAL: day-count convention of instrument (either
basis number between 1 and 11, or specified as string (act/365 etc.)
- comp_type: OPTIONAL: compounding type of instrument
(disc, cont, simple)
- comp_freq: OPTIONAL: compounding frequency of instrument
(1,2,3,4,6,12 payments per year)
- comp_type_curve: OPTIONAL: compounding type of curve
- basis_curve: OPTIONAL: day-count convention of curve
- comp_freq_curve: OPTIONAL: compounding frequency of curve
- interp_discount: OPTIONAL: interpolation method of discount curve
- sensi_flag: OPTIONAL: boolean variable (calculate sensitivities)
(default: linear)
- npv: returns a Mx1 vector with all net present values per scenario
- MacDur: returns a Mx1 vector with all Macaulay durations
- Convexity: returns a Mx1 vector with all convexities
- MonDur: returns a Mx1 vector with all Monetary durations
- Convexity_alt: returns a Mx1 vector with Convexity (alternative
method)
See also: timefactor, discount_factor, interpolate_curve, convert_curve_rates.