Skip to main content

Heston

Struct Heston 

Source
pub struct Heston {
Show 13 fields pub gamma: f64, pub kappa_m: f64, pub a: f64, pub v_kappa: f64, pub v_theta: f64, pub v_xi: f64, pub rho: f64, pub price_scale: f64, pub dv: f64, pub dq: f64, pub q_min: f64, pub q_max: f64, pub terminal_condition: TerminalCondition,
}
Expand description

Heston Stochastic Volatility Model for Market Making

Extends the Avellaneda-Stoikov model by adding stochastic volatility to the mid-price. The value function depends on both inventory and current variance.

§Dynamics

  • $dS_t = S_0 \sqrt{v_t} dW^S_t$
  • $dv_t = \kappa_v (\theta - v_t) dt + \xi \sqrt{v_t} dW^v_t$

This reduced HJB model has state [q, v] only (no spot state). To align with a multiplicative market process where price diffusion scales with S_t, we freeze spot at a reference level price_scale (typically initial price).

Fields§

§gamma: f64

Risk aversion for inventory holding.

§kappa_m: f64

Order filling intensity decay ($\kappa$).

§a: f64

Base order arrival intensity ($A$).

§v_kappa: f64

Mean reversion speed for variance ($\kappa_v$).

§v_theta: f64

Long-run mean variance ($\theta$).

§v_xi: f64

Volatility of variance (vol-of-vol, $\xi$).

§rho: f64

Correlation between price and variance Brownian motions ($\rho$).

§price_scale: f64

Reference spot level used to map relative variance into absolute price-risk scale.

§dv: f64

Grid step size for the variance dimension.

§dq: f64

Grid step for inventory dimension (defaults to 1.0 for integer grid).

§q_min: f64

Minimum inventory (lower hard boundary). Defaults to -infinity (no constraint).

§q_max: f64

Maximum inventory (upper hard boundary). Defaults to +infinity (no constraint).

§terminal_condition: TerminalCondition

Terminal condition for the value function at T. Defaults to Zero.

Implementations§

Source§

impl Heston

Source

pub fn new(gamma: f64, kappa_m: f64, a: f64) -> Self

Source

pub fn with_terminal_condition( self, terminal_condition: TerminalCondition, ) -> Self

Source

pub fn with_inventory_bounds(self, q_min: f64, q_max: f64) -> Self

Source

pub fn with_variance_params(self, v_kappa: f64, v_theta: f64, v_xi: f64) -> Self

Source

pub fn with_rho(self, rho: f64) -> Self

Source

pub fn with_price_scale(self, price_scale: f64) -> Self

Source

pub fn with_dv(self, dv: f64) -> Self

Source

pub fn with_dq(self, dq: f64) -> Self

Source

pub fn with_grid_steps(self, dx: &[f64; 2]) -> Self

Sets grid step sizes from a Grid<2>. Dimension 0 = inventory (dq), Dimension 1 = variance (dv).

Source

pub fn build_process(&self) -> HestonProcess

Constructs a HestonProcess matching this model’s variance parameters and correlation. Uses price_scale as the initial spot and v_theta as the initial variance so that the process starts in its stationary regime.

Source

pub fn get_spreads(&self, _q: f64, _v: f64, grads: &Gradients<2>) -> (f64, f64)

Trait Implementations§

Source§

impl Clone for Heston

Source§

fn clone(&self) -> Heston

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Heston

Source§

impl Debug for Heston

Source§

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

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

impl Model<2> for Heston

Source§

type Process = HestonProcess

The underlying stochastic process driving the continuous state dimensions. Set to () for models without a corresponding market_model process.
Source§

fn process(&self) -> HestonProcess

Returns the underlying stochastic process, if any.
Source§

fn optimize(&self, state: &[f64; 2], grads: &Gradients<2>) -> ControlOutput<2>

Given the current state and value function gradients ($\nabla V$), computations the optimal controls. Read more
Source§

fn terminal(&self, state: &[f64; 2]) -> f64

Computes the terminal value function $V(T, x)$ (Final Condition). Usually represents liquidation cost or final utility of wealth.
Source§

fn constant_discount_rate(&self) -> Option<f64>

Optimization hint: Returns Some(r) if the discount rate is constant across all states. Returns None if it depends on state. Default implementation returns None (safe fallback).
Source§

fn next_step( &self, current_state: &[f64; 2], dt: f64, noise: &[f64; 2], ) -> [f64; 2]

Simulates the next state for BSDE exploration. Default implementation is a simple random walk: x’ = x + sqrt(dt) * noise
Source§

fn is_diffusion_dimension(&self, dim: usize) -> bool

Indicates if a dimension is driven by Brownian diffusion. If true, the BSDE backward step will skip the lambda_plus/minus drift term for this dimension (it is already handled by the forward simulation noise).
Source§

fn is_integer_dimension(&self, dim: usize) -> bool

Indicates if a dimension takes only integer values (e.g. inventory q). Controls BSDE initialization: integer dimensions are sampled discretely while continuous dimensions (even if non-diffusion) are sampled with uniform noise. Default: false (continuous).
Source§

fn gradient_step(&self, dim: usize) -> f64

Physical finite-difference step for each state dimension used by BSDE gradient stencils. Read more
Source§

fn fill_rate_base(&self, _state: &[f64; 2]) -> f64

Base order arrival rate $A$ used for intensity-to-spread conversion. May depend on the current state (e.g. Hawkes lambda). Defaults to 1.0.
Source§

fn fill_rate_decay(&self) -> f64

Order fill decay parameter $\kappa$ used for intensity-to-spread conversion. Defaults to 1.0 for non-market-making models. Override in market-making models.
Source§

fn discount_rate(&self, _state: &[f64; N]) -> f64

Optional discount rate at the given state. Default implementation returns 0.0.
Source§

fn apply_constraint(&self, _state: &[f64; N], value: f64) -> f64

Optional constraint application (e.g. for American options) Default implementation does nothing.
Source§

fn next_step_controlled( &self, current_state: &[f64; N], _control: &ControlOutput<N>, dt: f64, noise: &[f64; N], ) -> [f64; N]

Simulates the next state for Coupled FBSDE exploration where dynamics depend on control. Default implementation falls back to next_step (Decoupled).
Source§

fn transform_noise(&self, _state: &[f64; N], noise: &[f64; N]) -> [f64; N]

Optional transform for standard normal samples before forward stepping. 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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V