HullWhite

The main Space in the BasicHullWhite model.

Mathematical notations are defined consistent with those in Brigo and Mercurio (2001, 2nd Ed. 2006)

See also

  • Damiano Brigo, Fabio Mercurio (2001, 2nd Ed. 2006). Interest Rate Models — Theory and Practice with Smile, Inflation and Credit

scen_size

Number of scenarios. 1000 by default.

np

numpy module.

step_size

Number of time steps. 360 by default.

time_len

Simulation length in years. 30 by default.

a

Parameter a in the Hull-White stochastic differential equation. 0.1 by default.

sigma

Parameter σ in the Hull-White stochastic differential equation. 0.1 by default.

seed1

Seed number to generate random numbers. 1234 by default. See std_norm_rand().

seed2

Seed for the second random numbers used for accum_short_rate2().

Cells

A_t_T(i, j)

A(ti,tj) in P(ti,tj)

B_t_T(i, j)

B(ti,tj) in P(ti,tj)

E_rt()

The expected values of r(ti) at time 0 for all ti.

E_rt_s(i, j)

Conditional expected values of r(tj)

P_t_T(i, j)

The price at ti of a zero-coupon bond paying off 1 at tj

V_t_T(i, j)

The variance of tjtir(u)du|Fti

Var_rt()

The variance of r(ti) at time 0 for all ti.

Var_rt_s(i, j)

The variance of r(tj) conditional on Fti

accum_short_rate(i)

Accumulated short rates.

accum_short_rate2(i)

Alternative implementation of accumulated short rates.

alpha(i)

α(ti)

disc_factor(i)

Discount factors

disc_factor_paths()

Discount factor scenarios.

mean_disc_factor()

Discount factor means

mean_short_rate()

The means of generated short rates

mkt_fwd(i)

The initial instantaneous forward rate for t_(i).

mkt_zcb(i)

The initial price of zero coupon bond

short_rate(i)

Stochastic short rates at t_(i)

short_rate_paths()

Short rate paths.

std_norm_rand([seed])

Random numbers from the standard normal distribution.

t_(i)

time index ti

var_short_rate()

Variance of generated short rates

A_t_T(i, j)[source]

A(ti,tj) in P(ti,tj)

See P_t_T().

B_t_T(i, j)[source]

B(ti,tj) in P(ti,tj)

See P_t_T().

E_rt()[source]

The expected values of r(ti) at time 0 for all ti.

Returns, in a numpy array, the expected values of r(ti) for all ti. Calculated as E{r(ti)|F0}.

See also

E_rt_s(i, j)[source]

Conditional expected values of r(tj)

Returns, in a numpy array, E{r(tj)|Fi}, the expected values of r(tj) conditional on Fi for all scenarios. E{r(t)|Fs} is calculated as:

r(s)ea(ts)+α(t)α(s)ea(ts)

where α(t) is calculated by alpha().

P_t_T(i, j)[source]

The price at ti of a zero-coupon bond paying off 1 at tj

This formula corresponds to P(t,T) in Brigo and Mercurio, which is defined as:

P(t,T)=A(t,T)eB(t,T)r(t)

where ti and tj substitute for t and T.

See also

  • A_t_T() for A(t,T)

  • B_t_T() for B(t,T)

  • short_rate() for r(t)

  • Brigo and Mercurio (2001, 2nd Ed. 2006). Interest Rate Models — Theory and Practice with Smile, Inflation and Credit

V_t_T(i, j)[source]

The variance of tjtir(u)du|Fti

This formula corresponds to V(t,T) in Brigo and Mercurio, which is defined as:

V(t,T)=σ2a2[Tt+2aea(Tt)12ae2a(Tt)32a]

where ti and tj substitute for t and T.

See also

  • sigma for σ

  • a for a

  • Brigo and Mercurio (2001, 2nd Ed. 2006). Interest Rate Models — Theory and Practice with Smile, Inflation and Credit

Var_rt()[source]

The variance of r(ti) at time 0 for all ti.

Returns, in a numpy array, the variance of r(ti) for all ti. Calculated as Var{r(ti)|F0}.

See also

Var_rt_s(i, j)[source]

The variance of r(tj) conditional on Fti

Var{r(tj)|Fti}, the variance of r(tj) conditional on Fti, calculated as:

Var{r(t)|Fs}=σ22a(1e2a(ts))

See also

accum_short_rate(i)[source]

Accumulated short rates.

a descrete approximation to the integral 0tir(t)dt, calculated as j=1ir(tj1)(tjtj1)

See also

accum_short_rate2(i)[source]

Alternative implementation of accumulated short rates.

An alternative approach to simulate Y(ti)=0tir(t)dt by using the fact that Y(ti) follows a normal distribution, and by simulating the joint distribution of (r(ti),Y(ti)), as suggested in Glasserman (2003).

See also

alpha(i)[source]

α(ti)

Returns, in a numpy array, α(ti) for all scenarios. α appears in the expression of E{r(t)|Fs} and is defined as:

α(t)=fM(0,t)+σ22a2(1eat)2

See also

disc_factor(i)[source]

Discount factors

Returns, in a numpy array, the discount factors for cashflows at ti for all scenarios. Defined as:

np.exp(-accum_short_rate(i))

See also

  • accum_short_rate

disc_factor_paths()[source]

Discount factor scenarios.

Returns, as a 2D numpy array, the simulated discount factors for all scenarios.

See also

mean_disc_factor()[source]

Discount factor means

Returns, as a numpy array, the mean of discount factors of all scenarios for each ti.

See also

mean_short_rate()[source]

The means of generated short rates

Returns, as a numpy array, the means of short rates of all scenarios for all ti. This should converge to the theoretical variances calculated by E_rt().

See also

mkt_fwd(i)[source]

The initial instantaneous forward rate for t_(i).

By default, returns 0.05 for all i.

mkt_zcb(i)[source]

The initial price of zero coupon bond

The initial price of the unit zero coupon bond maturing at t_(i).

If i=0 returns 1. Otherwise, defined as:

mkt_zcb(i-1) * np.exp(-mkt_fwd(i-1)*dt)

where dt = t_(i) - t_(i-1).

See also

short_rate(i)[source]

Stochastic short rates at t_(i)

Returns, in a numpy array, simulated stochastic short rates at t_(i) for all scenarios.

For i=0, defined as mkt_fwd(0).

For i>0, defined as r(ti)=E{r(ti)|Fi1}+Var{r(ti)|Fi1}Z,

where E{r(ti)|Fi1}, the expected value of r(ti) conditional on Fi1 is calculated by E_rt_s(i-1, i), Var{r(ti)|Fi1} the variance of r(ti) conditional on Fi1 is calculated by Var_rt_s(i-1, i), and Z, a random number drawn from N(0,1) a standard normal distribution calculated by std_norm_rand().

short_rate_paths()[source]

Short rate paths.

Returns, as a 2D numpy array, the simulated short rate paths for all scenarios.

See also

std_norm_rand(seed=1234)[source]

Random numbers from the standard normal distribution.

Returns a numpy array shaped scen_size x step_size. The elements are random numbers drawn from the standard normal distribution.

t_(i)

time index ti

var_short_rate()[source]

Variance of generated short rates

Returns, as a vector in a numpy array, the variances of the generated short rates for all ti. This should converge to the theoretical variances calculated by Var_rt().