Risk-Neutral Discounting
Obviously, risk-neutral discounting is central to the risk-neutral valuation approach. We
therefore start by developing a Python class for risk-neutral discounting. However, it pays
to first have a closer look at the modeling and handling of relevant dates for a valuation.
Modeling and Handling Dates
A necessary prerequisite for discounting is the modeling of dates (see also Appendix C).
For valuation purposes, one typically divides the time interval between today and the final
date of the general market model T into discrete time intervals. These time intervals can be
homogenous (i.e., of equal length), or they can be heterogenous (i.e., of varying length). A
valuation library should be able to handle the more general case of heterogeneous time
intervals, since the simpler case is then automatically included. Therefore, we work with
lists of dates, assuming that the smallest relevant time interval is one day. This implies that
we do not care about intraday events, for which we would have to model time (in addition
to dates).
[ 65 ]
To compile a list of relevant dates, one can basically take one of two approaches:
constructing a list of concrete dates (e.g., as datetime.datetime objects in Python) or of
year fractions (as decimal numbers, as is often done in theoretical works).
For example, the following two definitions of dates and fractions are (roughly)
equivalent:
In [ 1 ]: import datetime as dt
In [ 2 ]: dates = [dt.datetime( 2015 , 1 , 1 ), dt.datetime( 2015 , 7 , 1 ),
dt.datetime( 2016 , 1 , 1 )]
In [ 3 ]: (dates[ 1 ] - dates[ 0 ]).days / 365.
Out[ 3 ]: 0.4958904109589041
In [ 4 ]: (dates[ 2 ] - dates[ 1 ]).days / 365.
Out[ 4 ]: 0.5041095890410959
In [ 5 ]: fractions = [0.0, 0.5, 1.0]
They are only roughly equivalent since year fractions seldom lie on the beginning (0 a.m.)
of a certain day. Just consider the result of dividing a year by 50.
Sometimes it is necessary to get year fractions out of a list of dates. The function
get_year_deltas presented in Example 15-1 does the job.
Example 15-1. Function to get year fractions from a list or array of datetime objects
DX Library Frame
get_year_deltas.py
import numpy as np
def get_year_deltas(date_list, day_count=365.):
”’ Return vector of floats with day deltas in years.
Initial value normalized to zero.
Parameters
==========
date_list : list or array
collection of datetime objects
day_count : float
number of days for a year