levymodel

exponentialoflevymodel

Exponential of a Lévy process, that is the underlying is S modelled as: S_t = S_0 exp(L_t) and L_t is a Lévy model

class MomentsDecorator[source]

Bases: object

Class decorator that specifies the first standardised moments of the distribution

ExponentialOfLevyModel[source]

alias of ClsWithMoments

levymodel

Description of a generic Lévy model: this involves the definition of the Lévy measure (and truncated Lévy measure) as well as Lévy triplet. Cumulants are also defined for those models which have some.

class LevyRepresentation(value)[source]

Bases: Enum

An enumeration.

ZERO = 1
CENTER = 2
ONEONE = 3
TILDE = 4
class LevyMeasure[source]

Bases: object

Definition of a Lévy measure and its integration against power of x. The main characteristics of the Lévy measure are given directly by the value of its Blumenthal-Getoor index.

support()[source]
Returns

the support of the Lévy measure

Note

in theory, this is really \(\mathbb{R}^*\)

abstract jump_of_finite_activity() bool[source]
Returns

true if the integral of \(\nu(dx)\) over \(\mathbb{R}\) is finite

abstract jump_of_finite_variation() bool[source]
Returns

true if the integral of \(|x| \nu(dx)\) on \(|x| <= 1\) is finite

finite_first_moment()[source]
Returns

true if the integral of \(|x| \nu(dx)\) on \(|x| > 1\) is finite

abstract blumenthal_getoor_index() float[source]
Returns

the Blumenthal-Getoor index

x_nu(x: float) float[source]
Returns

the multiplication of x times the Lévy measure

note:: there are a lot of cases where this expression can be simplified

integrate(a: float, b: float) float[source]

Integrate the levy measure \(\nu(dx)\) between x=a and x=b

integrate_against_x(a: float, b: float) float[source]

Integrate \(x \nu(dx)\) between x=a and x=b

integrate_against_xx(a: float, b: float) float[source]

Integrate \(x^2 \nu(dx)\) between x=a and x=b

integrate_against_xn(a: float, b: float, n: int)[source]

Integrate \(x^n nu(dx)\) between x=a and x=b

class TruncatedLevyMeasure(levy_measure: LevyMeasure, truncations: tuple[float, float])[source]

Bases: LevyMeasure

The truncated Lévy measure is the restriction of a Lévy measure to an interval [a, b]

__init__(levy_measure: LevyMeasure, truncations: tuple[float, float])[source]
Parameters
  • levy_measure – considered Lévy measure

  • truncations – truncation parameters a, b with a < b such as the new measure is the restriction to [a, b]

support()[source]
Returns

the support of the Lévy measure

Note

in theory, this is really \(\mathbb{R}^*\)

jump_of_finite_activity() bool[source]
Returns

true if the integral of \(\nu(dx)\) over \(\mathbb{R}\) is finite

jump_of_finite_variation() bool[source]
Returns

true if the integral of \(|x| \nu(dx)\) on \(|x| <= 1\) is finite

finite_first_moment()[source]
Returns

true if the integral of \(|x| \nu(dx)\) on \(|x| > 1\) is finite

blumenthal_getoor_index() float[source]
Returns

the Blumenthal-Getoor index

integrate(a: float, b: float) float[source]

Integrate the levy measure \(\nu(dx)\) between x=a and x=b

integrate_against_x(a: float, b: float) float[source]

Integrate \(x \nu(dx)\) between x=a and x=b

integrate_against_xx(a: float, b: float) float[source]

Integrate \(x^2 \nu(dx)\) between x=a and x=b

integrate_against_xn(a: float, b: float, n: int)[source]

Integrate \(x^n nu(dx)\) between x=a and x=b

class LevyTriplet(sigma: float, nu: LevyMeasure, a: float = 0, representation: LevyRepresentation = LevyRepresentation.ONEONE)[source]

Bases: object

The Lévy triplet is defined as (a, sigma, nu) where: - a is the drift of the given representation - sigma is the diffusion coefficient - nu is the Lévy measure

__init__(sigma: float, nu: LevyMeasure, a: float = 0, representation: LevyRepresentation = LevyRepresentation.ONEONE)[source]
Parameters
  • sigma – Brownian coefficient

  • nu – Lévy measure

  • a – drift term

  • representation – Lévy-Khintchine representation

property sigma
canonical_drift() float[source]
Returns

the canonical drift, that is the drift corresponding to the cut-off function \(c(x) = 1\) if \(|x| < 1\)

zero_drift() float[source]
Returns

the drift in the zero representation

center_drift() float[source]
Returns

centre drift corresponding to the cut-off function :math: c(x) = 1

tilde_drift() float[source]
Returns

the drift in the tilde representation

set_representation(representation: LevyRepresentation) None[source]
Parameters

representation – Lévy-Khintchine representation

class Cumulant(drift: float, parameters: Parameters)[source]

Bases: ABC

Expression of the first 6 cumulants functions of the Lévy model if they exist.

abstract __init__(drift: float, parameters: Parameters)[source]
cumulant1(t: float) float[source]
cumulant2(t: float) float[source]
cumulant3(t: float) float[source]
cumulant4(t: float) float[source]
cumulant5(t: float) float[source]
cumulant6(t: float) float[source]
class LevyModel(model_type: ModelType, levy_triplet: LevyTriplet, cumulant: Cumulant)[source]

Bases: Model

This class represents a time-homogeneous Lévy model

Note

the simulated process has the same representation as the model, more explicitly the Lévy model L is simulated via the process L (contrary to the ExponentialOfLévyModel S = exp(L) which is simulated via the log-process L)

process_representation = 1
__init__(model_type: ModelType, levy_triplet: LevyTriplet, cumulant: Cumulant)[source]
Parameters
  • model_type – name of the model

  • levy_triplet – Lévy triplet

  • cumulant – cumulant expressions

truncate_levy_measure(truncations) None[source]

Truncate the Lévy measure: the Lévy measure will return 0 outside the truncations interval

dimension() int[source]

number of modelled underlyings

x0_value()[source]
drift(t: float = 0, x: array = 0) array[source]

zero drift, by default, as the process is directly modelled by the Lévy model

process_drift() array[source]

Drift mu(t, x) of the underlying stochastic process

df(t: float) float[source]

Discount factor function :param t: time t :return: the discount factor at time t

diffusion_coefficient() float[source]
Returns

the diffusion coefficient of the stochastic process

jump_of_finite_activity() bool[source]
jump_of_finite_variation() bool[source]
finite_first_moment()[source]
jump_increment(n) array[source]

Direct simulation of jump increments

Parameters

n – numbers of jumps to simulate

Returns

array of the jump values

abstract levy_exponent_pure_jump(x: complex) complex[source]

The Lévy exponent phi is such that E[exp(x L_t)] = exp(t*phi(x)) where L is the Lévy model with triplet (0, 0, nu).

Returns

phi(z) where z = ix, that is phi(x) = levy_exponent_pure_jump(ix)

levy_exponent(x: complex) complex[source]
Returns

the Lévy exponent phi such that \(\mathbb{E}[exp(u L_t)] = exp(\phi(u)*t)\) where L is the Lévy model with triplet (a, sigma, nu)

characteristic_function(t: float, x: complex) complex[source]
Returns

the characteristic function of the process L_t, i.e. E[exp(i u L_t)]

blumenthal_getoor_index() float[source]
mass(a, b, indices: Optional[list[int]] = None)[source]
intensity() float[source]
density(t) Callable[[float], Callable[[array], array]][source]
Returns

the density function implied by the COS formula of the exponential of the Lévy model

plot_density(t: float, show: bool = False) None[source]
Returns

plot the density of the Lévy model

cdf(t: float, x: array)[source]

Cumulative distribution function of the exponential of the Lévy process

plot_cdf(t: float, data: array, log_normalisation: bool = True, show: bool = False, title='') None[source]
Returns

plot the cumulative distribution function of the Lévy model