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}
§Links
- Wikipedia: N/A
- Original Source: https://dx.doi.org/10.2139/ssrn.242367
§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
impl KouJumpDiffusionProcess
Sourcepub 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>
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 jumpseta_1: Rate parameter of the positive jumpseta_2: Rate parameter of the negative jumpsp: Probability of a jump upn_paths: Number of paths to generaten_steps: Number of stepst_f: Final time steps_0: Initial value of the stochastic process
§Errors
- Returns an error if the argument
pis not in the range [0,1].
Trait Implementations§
Source§impl Debug for KouJumpDiffusionProcess
impl Debug for KouJumpDiffusionProcess
Source§impl ErrorTitle for KouJumpDiffusionProcess
impl ErrorTitle for KouJumpDiffusionProcess
Source§fn error_title() -> String
fn error_title() -> String
Returns the error title.
Source§impl StochasticProcess for KouJumpDiffusionProcess
impl StochasticProcess for KouJumpDiffusionProcess
Source§fn get_paths(&self) -> Result<Vec<Array1<f64>>, DigiFiError>
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)
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
fn get_n_steps(&self) -> usize
Returns the number of time steps in the stochastic process.
Source§fn simulate(&self) -> Result<StochasticProcessResult, DigiFiError>
fn simulate(&self) -> Result<StochasticProcessResult, DigiFiError>
Runs stochastic process simulation: Read more
Auto Trait Implementations§
impl Freeze for KouJumpDiffusionProcess
impl RefUnwindSafe for KouJumpDiffusionProcess
impl Send for KouJumpDiffusionProcess
impl Sync for KouJumpDiffusionProcess
impl Unpin for KouJumpDiffusionProcess
impl UnsafeUnpin for KouJumpDiffusionProcess
impl UnwindSafe for KouJumpDiffusionProcess
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.