Struct hull_white::HullWhite
source · pub struct HullWhite<'a, T, U>{ /* private fields */ }
Implementations§
source§impl<T, U> HullWhite<'_, T, U>
impl<T, U> HullWhite<'_, T, U>
pub fn init<'a>( a: f64, sigma: f64, yield_curve: &'a T, forward_curve: &'a U ) -> HullWhite<'a, T, U>
sourcepub fn t_forward_bond_vol(&self, t: f64, t_m: f64, t_f: f64) -> f64
pub fn t_forward_bond_vol(&self, t: f64, t_m: f64, t_f: f64) -> f64
Returns volality of bond under the t-forward measure.
§Examples
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0;
let t_m = 2.0;
let t_f = 3.0;
let yield_curve = |t:f64|0.05*t;
let forward_curve = |t:f64|t.ln();
let hull_white= hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let bond_vol = hull_white.t_forward_bond_vol(
t, t_m, t_f
);
sourcepub fn mu_r(&self, r_t: f64, t: f64, t_m: f64) -> f64
pub fn mu_r(&self, r_t: f64, t: f64, t_m: f64) -> f64
Returns volality of bond under the t-forward measure.
§Examples
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start taking the expectation
let t_m = 2.0; //horizon of the expectation
let r_t = 0.04; //rate at t
let yield_curve = |t:f64|0.05*t;
let forward_curve = |t:f64|t.ln();
let hull_white= hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let bond_vol = hull_white.mu_r(r_t, t, t_m);
sourcepub fn variance_r(&self, t: f64, t_m: f64) -> f64
pub fn variance_r(&self, t: f64, t_m: f64) -> f64
Returns variance of the interest rate process
§Examples
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start taking the variance
let t_m = 2.0; //horizon of the variance
let yield_curve = |t:f64|0.05*t;
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let variance = hull_white.variance_r(t, t_m);
sourcepub fn bond_price_t(&self, r_t: f64, t: f64, bond_maturity: f64) -> f64
pub fn bond_price_t(&self, r_t: f64, t: f64, bond_maturity: f64) -> f64
Returns price of a zero coupon bond at some future date given the interest rate at that future date
§Examples
let r_t = 0.04; //instantaneous rate at date t
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let bond_maturity = 2.0;
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let bond_price = hull_white.bond_price_t(r_t, t, bond_maturity);
sourcepub fn bond_price_now(&self, bond_maturity: f64) -> f64
pub fn bond_price_now(&self, bond_maturity: f64) -> f64
Returns price of a zero coupon bond at current date
§Examples
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let bond_maturity = 2.0;
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let bond_price = hull_white.bond_price_now(bond_maturity);
sourcepub fn coupon_bond_price_t(
&self,
r_t: f64,
t: f64,
coupon_times: &[f64],
coupon_rate: f64
) -> f64
pub fn coupon_bond_price_t( &self, r_t: f64, t: f64, coupon_times: &[f64], coupon_rate: f64 ) -> f64
Returns price of a coupon bond at some future date
§Examples
let r_t = 0.04; //instantaneous rate at date t
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let coupon_times = vec![1.25, 1.5, 1.75, 2.0]; //measure time from now (0), all should be greater than t. Final coupon is the bond maturity
let coupon_rate = 0.05;
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let bond_price = hull_white.coupon_bond_price_t(r_t, t, &coupon_times, coupon_rate);
sourcepub fn coupon_bond_price_now(
&self,
coupon_times: &[f64],
coupon_rate: f64
) -> f64
pub fn coupon_bond_price_now( &self, coupon_times: &[f64], coupon_rate: f64 ) -> f64
Returns price of a coupon bond at current date
§Examples
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let coupon_times = vec![1.25, 1.5, 1.75, 2.0]; //measure time from now (0), all should be greater than t. Final coupon is the bond maturity
let coupon_rate = 0.05;
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let bond_price = hull_white.coupon_bond_price_now(&coupon_times, coupon_rate);
sourcepub fn bond_call_t(
&self,
r_t: f64,
t: f64,
option_maturity: f64,
bond_maturity: f64,
strike: f64
) -> f64
pub fn bond_call_t( &self, r_t: f64, t: f64, option_maturity: f64, bond_maturity: f64, strike: f64 ) -> f64
Returns price of a call option on zero coupon bond at some future time
§Examples
let r_t = 0.04; //rate at time t
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let option_maturity = 1.5;
let bond_maturity = 2.0;
let strike = 0.98;
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let bond_call = hull_white.bond_call_t(r_t, t, option_maturity, bond_maturity, strike);
sourcepub fn bond_call_now(
&self,
option_maturity: f64,
bond_maturity: f64,
strike: f64
) -> f64
pub fn bond_call_now( &self, option_maturity: f64, bond_maturity: f64, strike: f64 ) -> f64
Returns price of a call option on zero coupon bond at current time
§Examples
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let option_maturity = 1.5;
let bond_maturity = 2.0;
let strike = 0.98;
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let bond_call = hull_white.bond_call_now(option_maturity, bond_maturity, strike);
sourcepub fn coupon_bond_call_t(
&self,
r_t: f64,
t: f64,
option_maturity: f64,
coupon_times: &[f64],
coupon_rate: f64,
strike: f64
) -> Result<f64, f64>
pub fn coupon_bond_call_t( &self, r_t: f64, t: f64, option_maturity: f64, coupon_times: &[f64], coupon_rate: f64, strike: f64 ) -> Result<f64, f64>
Returns price of a call option on a coupon bond at some future time
§Examples
let r_t = 0.04; //rate at time t
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let option_maturity = 1.5;
let coupon_times = vec![1.25, 1.5, 1.75, 2.0, 2.5, 3.0];
let coupon_rate = 0.05;
let strike = 1.0;
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let bond_call = hull_white.coupon_bond_call_t(r_t, t, option_maturity, &coupon_times, coupon_rate, strike);
sourcepub fn bond_put_t(
&self,
r_t: f64,
t: f64,
option_maturity: f64,
bond_maturity: f64,
strike: f64
) -> f64
pub fn bond_put_t( &self, r_t: f64, t: f64, option_maturity: f64, bond_maturity: f64, strike: f64 ) -> f64
Returns price of a put option on zero coupon bond at some future time
§Examples
let r_t = 0.04; //rate at time t
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let option_maturity = 1.5;
let bond_maturity = 2.0;
let strike = 0.98;
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let bond_put = hull_white.bond_put_t(r_t, t, option_maturity, bond_maturity, strike);
sourcepub fn bond_put_now(
&self,
option_maturity: f64,
bond_maturity: f64,
strike: f64
) -> f64
pub fn bond_put_now( &self, option_maturity: f64, bond_maturity: f64, strike: f64 ) -> f64
Returns price of a put option on zero coupon bond at current time
§Examples
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let option_maturity = 1.5;
let bond_maturity = 2.0;
let strike = 0.98;
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let bond_put = hull_white.bond_put_now(option_maturity, bond_maturity, strike);
sourcepub fn coupon_bond_put_t(
&self,
r_t: f64,
t: f64,
option_maturity: f64,
coupon_times: &[f64],
coupon_rate: f64,
strike: f64
) -> Result<f64, f64>
pub fn coupon_bond_put_t( &self, r_t: f64, t: f64, option_maturity: f64, coupon_times: &[f64], coupon_rate: f64, strike: f64 ) -> Result<f64, f64>
Returns price of a put option on a coupon bond at some future time
§Examples
let r_t = 0.04; //rate at time t
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let option_maturity = 1.5;
let coupon_times = vec![1.25, 1.5, 1.75, 2.0, 2.5, 3.0];
let coupon_rate = 0.05;
let strike = 1.0;
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let bond_put = hull_white.coupon_bond_put_t(r_t, t, option_maturity, &coupon_times, coupon_rate, strike);
sourcepub fn caplet_now(&self, option_maturity: f64, delta: f64, strike: f64) -> f64
pub fn caplet_now(&self, option_maturity: f64, delta: f64, strike: f64) -> f64
Returns price of a caplet at current time
§Examples
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let option_maturity = 1.5;
let delta = 0.25; //delta is the tenor of the Libor rate
let strike = 0.04;
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let caplet = hull_white.caplet_now(option_maturity, delta, strike);
sourcepub fn caplet_t(
&self,
r_t: f64,
t: f64,
option_maturity: f64,
delta: f64,
strike: f64
) -> f64
pub fn caplet_t( &self, r_t: f64, t: f64, option_maturity: f64, delta: f64, strike: f64 ) -> f64
Returns price of a caplet at some future time
§Examples
let r_t = 0.04; //rate at time t
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let option_maturity = 1.5;
let delta = 0.25; //delta is the tenor of the Libor rate
let strike = 0.04;
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let caplet = hull_white.caplet_t(r_t, t, option_maturity, delta, strike);
sourcepub fn euro_dollar_future_t(
&self,
r_t: f64,
t: f64,
option_maturity: f64,
delta: f64
) -> f64
pub fn euro_dollar_future_t( &self, r_t: f64, t: f64, option_maturity: f64, delta: f64 ) -> f64
Returns price of a Euro Dollar Future at some future time
§Examples
let r_t = 0.04; // rate at time t
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let option_maturity = 1.5;
let delta = 0.25; //delta is the tenor of the Libor rate
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let edf = hull_white.euro_dollar_future_t(r_t, t, option_maturity, delta);
sourcepub fn euro_dollar_future_now(&self, option_maturity: f64, delta: f64) -> f64
pub fn euro_dollar_future_now(&self, option_maturity: f64, delta: f64) -> f64
Returns price of a Euro Dollar Future at some future time
§Examples
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let option_maturity = 1.5;
let delta = 0.25; //delta is the tenor of the Libor rate
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let edf = hull_white.euro_dollar_future_now(option_maturity, delta);
sourcepub fn forward_libor_rate_t(
&self,
r_t: f64,
t: f64,
maturity: f64,
delta: f64
) -> f64
pub fn forward_libor_rate_t( &self, r_t: f64, t: f64, maturity: f64, delta: f64 ) -> f64
Returns forward Libor rate at some future time
§Examples
let r_t = 0.04; //current rate
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let maturity = 1.5;
let delta = 0.25; //delta is the tenor of the Libor rate
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let forward_libor = hull_white.forward_libor_rate_t(r_t, t, maturity, delta);
sourcepub fn forward_libor_rate_now(&self, maturity: f64, delta: f64) -> f64
pub fn forward_libor_rate_now(&self, maturity: f64, delta: f64) -> f64
Returns forward Libor rate at current time
§Examples
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let maturity = 1.5;
let delta = 0.25; //delta is the tenor of the Libor rate
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let forward_libor = hull_white.forward_libor_rate_now(maturity, delta);
sourcepub fn libor_rate_t(&self, r_t: f64, t: f64, delta: f64) -> f64
pub fn libor_rate_t(&self, r_t: f64, t: f64, delta: f64) -> f64
Returns Libor rate at some future time
§Examples
let r_t = 0.04; //current rate
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let delta = 0.25; //delta is the tenor of the Libor rate
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let libor = hull_white.libor_rate_t(r_t, t, delta);
sourcepub fn forward_swap_rate_t(
&self,
r_t: f64,
t: f64,
swap_initiation: f64,
num_swap_payments: usize,
delta: f64
) -> f64
pub fn forward_swap_rate_t( &self, r_t: f64, t: f64, swap_initiation: f64, num_swap_payments: usize, delta: f64 ) -> f64
Returns forward swap rate at some future time
§Examples
let r_t = 0.04; //rate at t
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let swap_initiation = 1.5;
let num_swap_payments = 14;
let delta = 0.25; //delta is the tenor of the Libor rate
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let forward_swap = hull_white.forward_swap_rate_t(r_t, t, swap_initiation, num_swap_payments, delta);
sourcepub fn swap_rate_t(
&self,
r_t: f64,
t: f64,
num_swap_payments: usize,
delta: f64
) -> f64
pub fn swap_rate_t( &self, r_t: f64, t: f64, num_swap_payments: usize, delta: f64 ) -> f64
Returns swap rate at some future time
§Examples
let r_t = 0.04; //rate at t
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let num_swap_payments = 16;
let delta = 0.25; //delta is the tenor of the Libor rate
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let swap_rate = hull_white.swap_rate_t(r_t, t, num_swap_payments, delta);
sourcepub fn swap_price_t(
&self,
r_t: f64,
t: f64,
swap_maturity: f64,
delta: f64,
swap_rate: f64
) -> f64
pub fn swap_price_t( &self, r_t: f64, t: f64, swap_maturity: f64, delta: f64, swap_rate: f64 ) -> f64
Returns price of a swap at some future time, not necessarily at initiation of the swap
§Examples
let r_t = 0.04; //current rate
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let swap_maturity = 5.0;
let delta = 0.25; //delta is the tenor of the Libor rate
let swap_rate = 0.04; //at initiation, the swap rate is such that the swap has zero value
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let swap = hull_white.swap_price_t(r_t, t, swap_maturity, delta, swap_rate);
sourcepub fn swap_price_t_init(
&self,
r_t: f64,
t: f64,
swap_start: f64,
num_swap_payments: usize,
delta: f64,
swap_rate: f64
) -> f64
pub fn swap_price_t_init( &self, r_t: f64, t: f64, swap_start: f64, num_swap_payments: usize, delta: f64, swap_rate: f64 ) -> f64
Returns price of a swap at the start of the swap
§Examples
let r_t = 0.04; //current rate
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let num_swap_payments = 16;
let delta = 0.25; //delta is the tenor of the Libor rate
let swap_rate = 0.04;
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let swap = hull_white.swap_price_t_init(r_t, t, t, num_swap_payments, delta, swap_rate);
sourcepub fn european_payer_swaption_t(
&self,
r_t: f64,
t: f64,
option_maturity: f64,
num_swap_payments: usize,
delta: f64,
swap_rate: f64
) -> Result<f64, f64>
pub fn european_payer_swaption_t( &self, r_t: f64, t: f64, option_maturity: f64, num_swap_payments: usize, delta: f64, swap_rate: f64 ) -> Result<f64, f64>
Returns price of a payer swaption at some future time t
§Examples
let r_t = 0.04; //current rate
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let option_maturity = 2.0;
let num_swap_payments = 16;
let delta = 0.25; //delta is the tenor of the Libor rate
let swap_rate = 0.04; //the swap rate is what the payer agrees to pay if option is exercised
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let swaption = hull_white.european_payer_swaption_t(r_t, t, option_maturity, num_swap_payments, delta, swap_rate).unwrap();
sourcepub fn european_receiver_swaption_t(
&self,
r_t: f64,
t: f64,
option_maturity: f64,
num_swap_payments: usize,
delta: f64,
swap_rate: f64
) -> Result<f64, f64>
pub fn european_receiver_swaption_t( &self, r_t: f64, t: f64, option_maturity: f64, num_swap_payments: usize, delta: f64, swap_rate: f64 ) -> Result<f64, f64>
Returns price of a payer swaption at some future time t
§Examples
let r_t = 0.04; //current rate
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let option_maturity = 2.0;
let num_swap_payments = 16;
let delta = 0.25; //delta is the tenor of the Libor rate
let swap_rate = 0.04; //the swap rate is what the payer agrees to pay if option is exercised
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let swaption = hull_white.european_receiver_swaption_t(r_t, t, option_maturity, num_swap_payments, delta, swap_rate).unwrap();
sourcepub fn american_payer_swaption_t(
&self,
r_t: f64,
t: f64,
option_maturity: f64,
num_swap_payments: usize,
delta: f64,
swap_rate: f64,
num_steps: usize
) -> f64
pub fn american_payer_swaption_t( &self, r_t: f64, t: f64, option_maturity: f64, num_swap_payments: usize, delta: f64, swap_rate: f64, num_steps: usize ) -> f64
Returns price of an American payer swaption at some future time t
§Comments
This function uses a tree to solve and will take longer to compute than other pricing functions.
§Examples
let r_t = 0.04; //current rate
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let option_maturity = 2.0;
let num_swap_payments = 16;
let delta = 0.25; //delta is the tenor of the Libor rate
let swap_rate = 0.04; //the swap rate is what the payer agrees to pay if option is exercised
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let num_tree_steps = 100;
let swaption = hull_white.american_payer_swaption_t(
r_t, t, option_maturity, num_swap_payments, delta, swap_rate, num_tree_steps
);
sourcepub fn american_receiver_swaption_t(
&self,
r_t: f64,
t: f64,
option_maturity: f64,
num_swap_payments: usize,
delta: f64,
swap_rate: f64,
num_steps: usize
) -> f64
pub fn american_receiver_swaption_t( &self, r_t: f64, t: f64, option_maturity: f64, num_swap_payments: usize, delta: f64, swap_rate: f64, num_steps: usize ) -> f64
Returns price of an American payer swaption at some future time t
§Comments
This function uses a tree to solve and will take longer to compute than other pricing functions.
§Examples
let r_t = 0.04; //current rate
let a = 0.2; //speed of mean reversion for underlying Hull White process
let sigma = 0.3; //volatility of underlying Hull White process
let t = 1.0; //time from "now" (0) to start valuing the bond
let option_maturity = 2.0;
let num_swap_payments = 16;
let delta = 0.25; //delta is the tenor of the Libor rate
let swap_rate = 0.04; //the swap rate is what the payer agrees to pay if option is exercised
let yield_curve = |t:f64|0.05*t; //yield curve returns the "raw" yield (not divided by maturity)
let forward_curve = |t:f64|t.ln();
let hull_white = hull_white::HullWhite::init(a, sigma, &yield_curve, &forward_curve);
let num_tree_steps = 100;
let swaption = hull_white.american_receiver_swaption_t(
r_t, t, option_maturity, num_swap_payments, delta, swap_rate, num_tree_steps
);