Skip to main content

KouJumpDiffusionProcess

Struct KouJumpDiffusionProcess 

Source
pub struct KouJumpDiffusionProcess { /* private fields */ }
Expand description

Model describes stock price with continuous movement that have rare large jumps, with the jump sizes following a double exponential distribution.

§LaTeX Formula

  • dS_{t} = \mudt + \sigmadW_{t} + d(sum_{i=1}^{N(t)}(V_{i}-1))\n where V_{i} is i.i.d. non-negative random variables such that Y = log(V) is the assymetric double exponential distribution with density:\n
  • f_{Y}(y) = p*\eta_{1}e^{-\eta_{1}y}\mathbb{1}_{0\leq y} + (1-p)\eta_{2}*e^{\eta_{2}y}\mathbb{1}_{y<0}

§Examples

use ndarray::Array1;
use digifi::utilities::TEST_ACCURACY;
use digifi::stochastic_processes::{StochasticProcessResult, StochasticProcess, KouJumpDiffusionProcess};

let n_paths: usize = 1_000;
let n_steps: usize = 200;

let kjd: KouJumpDiffusionProcess = KouJumpDiffusionProcess::build(0.2, 0.3, 0.5, 9.0, 5.0, 0.5, n_paths, n_steps, 1.0, 100.0).unwrap();
let sp_result: StochasticProcessResult = kjd.simulate().unwrap();

assert_eq!(sp_result.paths.len(), n_paths);
assert_eq!(sp_result.paths[0].len(), n_steps + 1);
assert_eq!(sp_result.expectations_path.clone().unwrap().len(), n_steps + 1);
assert_eq!(sp_result.variances_path.unwrap().len(), n_steps + 1);
assert!((sp_result.mean - sp_result.expectations_path.unwrap()[n_steps]).abs() < 20_000_000.0 * TEST_ACCURACY);

Implementations§

Source§

impl KouJumpDiffusionProcess

Source

pub fn build( mu: f64, sigma: f64, lambda_n: f64, eta_1: f64, eta_2: f64, p: f64, n_paths: usize, n_steps: usize, t_f: f64, s_0: f64, ) -> Result<Self, DigiFiError>

Creates a new KouJumpDiffusionProcess instance.

§Input
  • mu: Mean of base stochastic process (i.e., process without jumps)
  • sigma: Standard deviation of base process (i.e., process without jumps)
  • lambda_n: Rate of jumps
  • eta_1: Rate parameter of the positive jumps
  • eta_2: Rate parameter of the negative jumps
  • p: Probability of a jump up
  • n_paths: Number of paths to generate
  • n_steps: Number of steps
  • t_f: Final time step
  • s_0: Initial value of the stochastic process
§Errors
  • Returns an error if the argument p is not in the range [0,1].

Trait Implementations§

Source§

impl Debug for KouJumpDiffusionProcess

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ErrorTitle for KouJumpDiffusionProcess

Source§

fn error_title() -> String

Returns the error title.
Source§

impl StochasticProcess for KouJumpDiffusionProcess

Source§

fn get_expectations(&self) -> Option<Array1<f64>>

Calculates the expected path of the Kou Jump-Diffusion process

§Output
  • An array of expected values of the stock price at each time step
§LaTeX Formula
  • E[S_t] = S_{0} + t(\mu + \lambda_{n}(\frac{p}{\eta_{1}} - \frac{1-p}{\eta_{2}}))
Source§

fn get_variances(&self) -> Option<Array1<f64>>

Calculates the variance of the Kou Jump-Diffusion process.

§Output
  • An array of variances of the process at each time step
§LaTeX Formula
  • Var[S_{t}] = t(\sigma^{2} + 2\lambda_{n}(\frac{p}{\eta^{2}{1}} + \frac{1-p}{\eta^{2}{2}}))
Source§

fn get_paths(&self) -> Result<Vec<Array1<f64>>, DigiFiError>

Generates simulation paths for the Kou Jump-Diffusion process.

§Output
  • Array of simulated paths following the Kou Jump-Diffusion process
§LaTeX Formula
  • dS_{t} = \mudt + \sigmadW_{t} + d(sum_{i=1}^{N(t)}(V_{i}-1))\n where V_{i} is i.i.d. non-negative random variables such that Y = log(V) is the assymetric double exponential distribution with density:\n
  • f_{Y}(y) = p*\eta_{1}e^{-\eta_{1}y}\mathbb{1}_{0\leq y} + (1-p)\eta_{2}*e^{\eta_{2}y}\mathbb{1}_{y<0}
Source§

fn update_n_paths(&mut self, n_paths: usize)

Updates the number of paths that the stochastic process will generate. Read more
Source§

fn get_n_steps(&self) -> usize

Returns the number of time steps in the stochastic process.
Source§

fn get_t_f(&self) -> f64

Returns the final time step.
Source§

fn simulate(&self) -> Result<StochasticProcessResult, DigiFiError>

Runs stochastic process simulation: Read more

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.