model

levycopulamodel

Multidimensional Lévy process modelled via a Lévy copula

For definitions and properties, the best place to start is the seminal paper: ‘Characterization of dependence of multidimensional Lévy processes using Lévy copulas’ by Jan Kallsen and Peter Tankov

volume(f, a, b) float[source]

Volume of the function f over the rectangle [a1, b1]x[a2, b2]x…x[an, bn]

Parameters
  • f – function to integrate

  • a – vector [a1, a2, a3,…, an]

  • b – vector [b1, b2, b3,…, bn]

where a <= b, i.e. a1 <= b1, a2 <= b2,…

Returns

the integral over the rectangle \(a x b\)

margin(f, indices: list[int], dimension: int)[source]

I-margin of the f function

Parameters
  • f – function f

  • indices – indices of I

  • dimension – dimension of the function

Returns

I-margin of f

class LevyCopulaModel(models: [<class 'rpylib.model.levymodel.levymodel.LevyModel'>], copula: ~rpylib.distribution.levycopula.LevyCopula)[source]

Bases: Model

Multidimensional Lévy process modelled via a Lévy copula

__init__(models: [<class 'rpylib.model.levymodel.levymodel.LevyModel'>], copula: ~rpylib.distribution.levycopula.LevyCopula)[source]
Parameters
  • models – processes characterising the margins of the copula

  • copula – copula function characterising the dependence of the margins

dimension() int[source]

number of modelled underlyings

truncate_levy_measure(truncations) None[source]

Truncate all marginal measures

x0_value()[source]

Initial value

df(t: float) float[source]

Discount factor function

jump_of_finite_activity() bool[source]
jump_of_finite_variation() bool[source]
finite_first_moment()[source]
levy_exponent(x: Union[complex, list[complex]]) complex[source]
blumenthal_getoor_index() float[source]
Returns

Blumenthal-Getoor index of the Lévy copula

characteristic_function(t: float, x: complex) complex[source]
cdf(t: float, x: array)[source]
drift(t: float = 0, x: array = 0) array[source]

Drift mu(t, x) of the stochastic process. Most of the time it is a constant drift in time and in the underlying variable x. :param t: time t :param x: value at time t of the underlyings

diffusion_coefficient() float[source]
Returns

the diffusion coefficient

plot_density(t: float, show: bool = False) None[source]
plot_cdf(t: float, data: array, log_normalisation: bool = True, show: bool = False, title='') None[source]
marginal_tail_integral(i: int, x: float) float[source]

Tail integral of the i-th marginal

margin_tail_integral(indices: list[int], x: Iterator[int])[source]
tail_integrals(x) float[source]

Calculate the tail integral of the I-margin of the Lévy copula

Parameters

x – vector of values

Returns

\(F(P^i_1(x_1), P^i_2(x_2),...P^i_n(x_n))\) for \(i \in indices\) where \(P^i_j(x) = sgn(x)*\nu^j(I(x))\) with:

  • \(I(x) = (x, \inf)\) if \(x\geq 0\)

  • and \(I(x) = (-\inf, x]\) if \(x<0\)

inverse_tail_integral(i, x)[source]
Returns

the inverse of the i-th marginal tail integral at x

model

Generic class for a pricing model

class ModelType(value)[source]

Bases: Enum

An enumeration.

BLACKSCHOLES = 1
MERTON = 2
HEM = 3
VG = 4
CGMY = 5
class Parameters[source]

Bases: ABC

Wrapper defining parameters class, the only function here is initialisation() which is needed for the calibration process.

initialisation()[source]

When parameters are calibrated, this function updates dependent members of the Parameter class

class Model[source]

Bases: object

Abstract class of a pricing model, subclasses need to implement a few functions:: dimension() drift() process_drift() if the model can be directly simulated df()

__init__()[source]
abstract dimension() int[source]

number of modelled underlyings

dimension_model() int[source]

dimension of the model, that is the number of factors or drivers in the model

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

Drift mu(t, x) of the stochastic process. Most of the time it is a constant drift in time and in the underlying variable x. :param t: time t :param x: value at time t of the underlyings

process_drift() array[source]

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

abstract df(t: float) float[source]

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

utils

Bunch of helper functions to create Lévy models

class ModelClasses(parameters, levy_model, exponential_of_levy_model)

Bases: tuple

exponential_of_levy_model

Alias for field number 2

levy_model

Alias for field number 1

parameters

Alias for field number 0

helper_model(model_type: ModelType, exponential_of_levy_model: bool = True) ClsWithMoments]][source]

Builder to create a Lévy model

Parameters
  • model_type – Lévy model type

  • exponential_of_levy_model – if true return the helper for the exponential of the Lévy model

Returns

the builder function for the Lévy model or the exponential of the Lévy model if exponential_of_levy_model=True

class ModelCreators(LevyModel, ExponentialOfLevyModel)

Bases: tuple

ExponentialOfLevyModel

Alias for field number 1

LevyModel

Alias for field number 0

create_levy_model(model_type: ModelType) Callable[[...], LevyModel][source]

Create a Lévy model from the predefined helper function (with default parameter values) :param model_type: Lévy model type

create_exponential_of_levy_model(model_type: ModelType) ClsWithMoments][source]

Create an exponential of a Lévy model from the predefined helper function (with default parameter values) :param model_type: underlying Lévy model type

atm_strike(model: LevyModel) float[source]

Get the ATM strike (=spot) :param model: Lévy model :return: the ATM strike

calibrate_model_parameter(model: ~rpylib.model.levymodel.exponentialoflevymodel.MomentsDecorator.__call__.<locals>.ClsWithMoments, parameter: str, parameter_interval: tuple, product: ~rpylib.product.product.Product, market_price: float) float[source]

Calibrate one parameter of an exponential of a Lévy model to a given product and its corresponding market price

Parameters
  • model – exponential of a Lévy model

  • parameter – parameter to calibrate

  • parameter_interval – admissible interval for the calibration of the parameter

  • product – calibration product

  • market_price – market price of the calibration product

Returns

the value of the calibrated parameter

Note

one assumes in this function that the product can be priced with the COS method for this model

calibrate_model_parameter_to_atm_call(model: ~rpylib.model.levymodel.exponentialoflevymodel.MomentsDecorator.__call__.<locals>.ClsWithMoments, parameter: str, parameter_interval: tuple, maturity: float, bs_sigma: float = 0.1) float[source]

Calibration of a model parameter to a Call option which market price is given by the Black-Scholes with a given Black-Scholes volatility and maturity

Parameters
  • model – exponential of a Lévy model

  • parameter – parameter to calibrate

  • parameter_interval – admissible interval for the calibration of the parameter

  • maturity – maturity of the call option

  • bs_sigma – Black-Scholes volatility of the call option

Returns

the value of the calibrated parameter

class DefaultCalibrationConfiguration(parameter, parameter_interval)

Bases: tuple

parameter

Alias for field number 0

parameter_interval

Alias for field number 1

run_default_calibration(model: ~rpylib.model.levymodel.exponentialoflevymodel.MomentsDecorator.__call__.<locals>.ClsWithMoments, maturity: float, bs_sigma: float = 0.1)[source]

The calibration is done on a predefined parameter and applying the function calibrate_model_parameter_to_atm_call()

Parameters
  • model – exponential of a Lévy model

  • maturity – maturity of the call option used in the calibration

  • bs_sigma – Black-Scholes volatility of the call option

create_clayton_copula(theta: float = 0.7, eta: float = 0.3) LevyCopula[source]

Helper to build the Clayton copula function

create_independent_copula() LevyCopula[source]

Helper to build the independent copula function

create_dependent_copula() LevyCopula[source]

Helper to build the dependent copula function

create_levy_copula_model(models: [<class 'rpylib.model.levymodel.levymodel.LevyModel'>], copula: ~rpylib.distribution.levycopula.LevyCopula) LevyCopulaModel[source]

Create a Lévy copula model

Parameters
  • models – margins

  • copula – copula function

create_levy_forward_market_model(driver: LevyModel) LevyForwardModel[source]

Create a Lévy Forward Market Model with default parameter values

create_levy_forward_market_model_copula(driver: [<class 'rpylib.model.levymodel.levymodel.LevyModel'>]) LevyForwardModel[source]

Create a Lévy Forward Market Model with default parameter values The Lévy copula is built by taking the drivers input as margins and choosing the Clayton copula with default parameters. Other parameters (initial OIS term rates, tenors and sigma volatility matrix) are also hardcoded.

Parameters

driver – list of Lévy models