Skip to main content

HestonModel

Struct HestonModel 

Source
pub struct HestonModel {
    pub mu: f64,
    pub kappa: f64,
    pub theta: f64,
    pub xi: f64,
    pub rho: f64,
}
Expand description

The Heston stochastic volatility model: dS = μ S dt + √V S dW₁ dV = κ(θ - V) dt + ξ √V dW₂ with correlation corr(dW₁, dW₂) = ρ.

Uses Euler-Maruyama discretization.

Fields§

§mu: f64

Drift μ of the asset.

§kappa: f64

Mean reversion speed κ > 0.

§theta: f64

Long-run variance θ > 0.

§xi: f64

Vol-of-vol ξ > 0.

§rho: f64

Correlation ρ ∈ (-1, 1).

Implementations§

Source§

impl HestonModel

Source

pub fn new(mu: f64, kappa: f64, theta: f64, xi: f64, rho: f64) -> Self

Create a new Heston model.

Source

pub fn simulate( &self, s0: f64, v0: f64, t_end: f64, n_steps: u32, seed: u64, ) -> Vec<(f64, f64, f64)>

Simulate (S_t, V_t) paths using Euler-Maruyama.

Returns Vec<(time, S_t, V_t)>.

Source

pub fn feller_condition_satisfied(&self) -> bool

Feller condition check: 2κθ > ξ² ensures V never hits 0.

Source

pub fn variance_long_run_mean(&self) -> f64

Long-run mean of the variance: θ.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.