product

payoff

Description of some standard financial derivatives:
  • Vanilla options

  • Digital

  • Barrier options

  • Lookback options

  • CDS

  • Bond

  • Swaption

  • etc

and standard payoffs like:
  • Swap

  • Call

  • Put

  • Payer/Receiver

class PayoffDates(value)[source]

Bases: Enum

Payoff dates can be deterministic as it is the case for most of the financial products, but in the case of credit derivatives for example, cashflows are usually exchange were an underlying defaults and therefore the payoff dates are stochastic and depend on the precise path of the considered underlying.

DETERMINISTIC = 1
STOCHASTIC = 2
class OptionType(value)[source]

Bases: Enum

Option type

FORWARD = 1
VANILLA = 2
DIGITAL = 3
BARRIER = 4
LOOKBACK = 5
class PayoffType(value)[source]

Bases: Enum

Payoff type

CALL = 1
PUT = 2
class BarrierType(value)[source]

Bases: Enum

Barrier type

UP_AND_IN = 1
UP_AND_OUT = 2
DOWN_AND_IN = 3
DOWN_AND_OUT = 4
class SwaptionType(value)[source]

Bases: Enum

Swaption type

RECEIVER = 1
PAYER = 2
class Payoff(payoff_dates_type: PayoffDates = PayoffDates.DETERMINISTIC)[source]

Bases: object

A payoff is simply a function of the underlying which is the evaluate() in this class.

__init__(payoff_dates_type: PayoffDates = PayoffDates.DETERMINISTIC)[source]
Parameters

payoff_dates_type – specify if the payoff dates are fixed (deterministic) or depends on the path of the

underlying

evaluate(underlying) float[source]

Return the valuation of the payoff

process(times, path) None[source]

Process path and retrieve relevant information if needed

Example

in the case of a lookback option, one needs to retrieve the max(min) of the underlying over [0,T]

dimension() int[source]

Payoff dimension. In most cases, the payoff is unidimensional. For a swaption, the dimension is the number of underlying swap rates in consideration.

static create(option_type: OptionType, *args, **kwargs)[source]

Factory method to create the payoff object :param option_type: option type :param args: additional parameters of the payoff :param kwargs: additional keyword parameters of the payoff

class PayoffOnTheFly(function)[source]

Bases: Payoff

This class is useful to create a payoff by passing the payoff function directly.

Note

only non-path-dependent payoff are in the scope as the process() function is not overridden.

__init__(function)[source]
Parameters

function – payoff function

evaluate(underlying) float[source]

Return the valuation of the payoff

class FixedCoupon(coupon: float)[source]

Bases: Payoff

Payoff that pays a fixed coupon

__init__(coupon: float)[source]
Parameters

coupon – value of the fixed coupon

evaluate(underlying: float) float[source]

Return the valuation of the payoff

class Forward(strike: float)[source]

Bases: Payoff

Forward contract: exchange of the underlying against the strike K

__init__(strike: float)[source]
Parameters

payoff_dates_type – specify if the payoff dates are fixed (deterministic) or depends on the path of the

underlying

evaluate(underlying: float) float[source]

Return the valuation of the payoff

class Vanilla(strike: Union[float, list[float]], payoff_type: PayoffType)[source]

Bases: Payoff

Vanilla option, that is for the moment only call and put options.

__init__(strike: Union[float, list[float]], payoff_type: PayoffType)[source]
Parameters
  • strike – option strike

  • payoff_type – payoff type

dimension() int[source]

Payoff dimension. In most cases, the payoff is unidimensional. For a swaption, the dimension is the number of underlying swap rates in consideration.

evaluate(underlying: float) float[source]

Return the valuation of the payoff

class CallSpread(strike1: float, strike2: float)[source]

Bases: Payoff

Call spread: buy one call at strike K1 and one call at strike K2 with K1 < K2

__init__(strike1: float, strike2: float)[source]
Parameters

payoff_dates_type – specify if the payoff dates are fixed (deterministic) or depends on the path of the

underlying

evaluate(underlying: float) float[source]

Return the valuation of the payoff

class Butterfly(strike1: float, strike2: float, strike3: float)[source]

Bases: Payoff

Buy one call at strike1, sell two call at strike2 and buy one call at strike3

__init__(strike1: float, strike2: float, strike3: float)[source]
Parameters

payoff_dates_type – specify if the payoff dates are fixed (deterministic) or depends on the path of the

underlying

evaluate(underlying: float) float[source]

Return the valuation of the payoff

class Digital(strike: float, payoff_type: PayoffType)[source]

Bases: Payoff

Payoff equal to: - call case: 1 if the underlying is greater than the strike, 0 otherwise - put case: 1 if the underlying is less than the strike, 0 otherwise

__init__(strike: float, payoff_type: PayoffType)[source]
Parameters

payoff_dates_type – specify if the payoff dates are fixed (deterministic) or depends on the path of the

underlying

evaluate(underlying) float[source]

Return the valuation of the payoff

class Barrier(strike: float, payoff_type: PayoffType, barrier_type: BarrierType, barrier: float)[source]

Bases: Payoff

Barrier option: a call or put payoff is activated/deactivated (in/out) is the underlying goes above/below (up/down)

__init__(strike: float, payoff_type: PayoffType, barrier_type: BarrierType, barrier: float)[source]
Parameters
  • strike – strike of the option payoff

  • payoff_type – payoff type

  • barrier_type – barrier type: up-and-in, up-and-out, down-and-in or down-and-out

  • barrier – barrier level of the payoff activation/deactivation

evaluate(underlying: float) float[source]

Return the valuation of the payoff

class LookBack(prefixed_maximum: float)[source]

Bases: Payoff

Lookback option, only put case implemented. The option pays (max(S) - prefixed_maximum)_+ where max(S) is the maximum of the underlying spot over the considered period.

__init__(prefixed_maximum: float)[source]
Parameters

prefixed_maximum – prefixed maximum that is “strike” of the option

process(times, path) None[source]

Process path and retrieve relevant information if needed

Example

in the case of a lookback option, one needs to retrieve the max(min) of the underlying over [0,T]

evaluate(underlying: float) float[source]

Return the valuation of the payoff

class Rainbow(weights: array, strike: float, payoff_type: PayoffType)[source]

Bases: Payoff

A rainbow option pays a weighted average of performances, it is similar to an Asian option but with non-equal weight.

__init__(weights: array, strike: float, payoff_type: PayoffType)[source]
Parameters
  • weights – list of weights to be applied to the performances, from the best one to the worst ones

  • strike – option strike

  • payoff_type – payoff type

evaluate(underlying: array) float[source]

Return the valuation of the payoff

class CDS(recovery_rate: float, spread: float, maturity: float, discounting)[source]

Bases: Payoff

Credit default swap: at the time of default, the buyer of the contract receives the notional.

Note

this formulation assumes that the payment of the spread is continuous in time.

__init__(recovery_rate: float, spread: float, maturity: float, discounting)[source]
Parameters
  • recovery_rate – CDS recovery rate

  • spread – CDS spread

  • maturity – CDS maturity

  • discounting – discounting function

process(times, path) None[source]

Process path and retrieve relevant information if needed

Example

in the case of a lookback option, one needs to retrieve the max(min) of the underlying over [0,T]

evaluate(default_time) array[source]

Return the valuation of the payoff

class Bond(underlying_rates: array, deltas: array)[source]

Bases: Payoff

The maturity of the bond is the expiry of the first Libor rate.

Note

By design, the Lévy Libor model and the Lévy Forward model are defined in the terminal measure (with regard to the maturity of the last underlying rate) and, to keep it simple, the payoff is tweaked accordingly.

__init__(underlying_rates: array, deltas: array)[source]
Parameters
  • underlying_rates – underlying rates values as of today

  • deltas – accrual of the underlying rates

evaluate(underlying_rates) float[source]

Return the valuation of the payoff

class Cap(underlying_rates: array, deltas: array, strike: float)[source]

Bases: Payoff

The periods of the cap are defined by the inputs deltas periods

Note

By design, the Lévy Libor model and the Lévy Forward model are defined in the terminal measure (with regard to the maturity of the last underlying rate) and, to keep it simple, the payoff is tweaked accordingly.

__init__(underlying_rates: array, deltas: array, strike: float)[source]
Parameters
  • underlying_rates – underlying rates values as of today

  • deltas – accrual of the underlying rates

  • strike – strike of the cap

evaluate(underlying_rates) float[source]

Return the valuation of the payoff

class Ratchet(deltas: array, funding_gearing: float, funding_margin: float, structured_spread: float, structured_increment: float, first_rate: float)[source]

Bases: Payoff

The periods of the ratchet are defined by the inputs deltas periods.
  • The client pays a coupon \(c_i = min(max(H_i + Y, c_{i-1}), c_{i-1})\) where \(c_{i-1}\) is the previous coupon, \(Y\) is the increment and \(H_i = \tau_i * (L_i + spread)\) with:

    • \(\tau_i\) the accrual period

    • \(L_i\) the rate for the period \([T_{i-1}, T_i]\)

  • The client receives a funding leg with coupon \(r_i = gearing*L_i + margin\).

Note

By design, the Lévy Libor model and the Lévy Forward model are defined in the terminal measure (with regard to the maturity of the last underlying rate) and, to keep it simple, the payoff is tweaked accordingly.

__init__(deltas: array, funding_gearing: float, funding_margin: float, structured_spread: float, structured_increment: float, first_rate: float)[source]
Parameters
  • deltas – accrual of the underlying rates

  • funding_gearing – gearing of the funding leg

  • funding_margin – margin of the funding leg

  • structured_spread – spread of the structured leg

  • structured_increment – increment Y of the structured leg

  • first_rate – value of the first underlying rate

evaluate(underlying_rates) float[source]

Return the valuation of the payoff

class Swaption(underlying_rates: array, deltas: array, strike: array, swaption_type: SwaptionType = SwaptionType.RECEIVER)[source]

Bases: Payoff

The expiry of the swaption is the expiry of the first Libor rate.

Note

By design, the Lévy Libor model and the Lévy Forward model are defined in the terminal measure (with regard to the maturity of the last underlying rate) and, to keep it simple, the payoff is tweaked accordingly.

__init__(underlying_rates: array, deltas: array, strike: array, swaption_type: SwaptionType = SwaptionType.RECEIVER)[source]
Parameters
  • underlying_rates – underlying rates values as of today

  • deltas – accrual of the underlying rates

  • strike – strike of the swaption

  • swaption_type – swaption type, that is receiver or payer (receiver meaning that the swaption is an option

into entering a receiver swap that is receiving the fixed coupon and paying the floating leg)

evaluate(underlying_rates) float[source]

Return the valuation of the payoff

product

This module describes a financial product which is defined as a payoff applied to an underlying

Product are considered mono-underlying for the moment.

class Product(payoff_underlying: Underlying, payoff: Payoff, maturity: float, notional: float = 1.0)[source]

Bases: object

A financial product consists of a payoff function applied at maturity T to an underlying.

Note

American/Bermudan-like products are not in scope for the moment

__init__(payoff_underlying: Underlying, payoff: Payoff, maturity: float, notional: float = 1.0)[source]
Parameters
  • payoff_underlying – underlying

  • payoff – payoff object

  • maturity – product maturity

  • notional – notional

underlying_value(times: TimeGrid, path: array, jump_path: array) float[source]

Compute the value of the payoff underlying from the underlying path.

Parameters
  • times – times of the underlying path

  • path – underlying path values

  • jump_path – only pure jump path of the underlying

Returns

the payoff underlying

update(process_representation: ProcessRepresentation) None[source]

Update of the payoff underlying object given the process representation (identity or log-representation)

Parameters

process_representation – process representation in the modelling framework, that is either directly the underlying or the log-underlying

times_grid() TimeGrid[source]

Compute the times grid of the product.

Returns

the times grid, that is the relevant dates needed to value the payoff

class ControlVariates(products: [<class 'rpylib.product.product.Product'>], prices: [typing.Union[float, <built-in function array>]])[source]

Bases: object

Standard control variates object used to decrease the variance of the Monte-Carlo estimator.

Note

by default, the control variates have the same maturity as the product in scope.

__init__(products: [<class 'rpylib.product.product.Product'>], prices: [typing.Union[float, <built-in function array>]])[source]

Build the control variates from a list of products and their market prices.

Parameters
  • products – products used as control variates

  • prices – market prices of these products

initialisation(payoff_underlying_type) None[source]

If two underlyings are closely related, for example S and log(S), one don’t need to compute each of them as one can be implied from this other. This function aims to implement this logic.

Parameters

payoff_underlying_type

this the type() of the payoff underlying object

process(times, path: array, jump_path: array, payoff_underlying) array[source]

Process the path information: compute the payoff underlyings, then the payoff value.

Parameters
  • times – times of the path

  • path – path of the underlyings

  • jump_path – only the pure jump path of the underlying

  • payoff_underlying – payoff underlying values

Returns

the value of the payoff for these underlyings path

process_mlmc(times, path_fine, path_coarse, jump_path_fine, jump_path_coarse, payoff_underlying_from_FP, payoff_underlying_from_CP) array[source]

Process the path information in the case of the MLMC

Parameters
  • times – times of the path

  • path_fine – path of the fine underlying

  • path_coarse – path of the coarse underlying

  • jump_path_fine – pure jump path of the fine underlying

  • jump_path_coarse – pure jump path of the coarse underlying

  • payoff_underlying_from_FP – payoff underlying values given by the fine underlying

  • payoff_underlying_from_CP – payoff underlying values given by the coarse underlying

Returns

an array of both the fine and coarse payoffs

See also

this is the MLMC version of process()

static helper_compute_coefficients(x: array, y: array, prices: array)[source]

Helper that computes the (optimal) coefficients of the control variates

Parameters
  • x – nd numpy array corresponding to the simulation of the control variates

  • y – flat 1d numpy array corresponding to the simulation of the payoff

  • prices – market prices of the control variates

Returns

flat 1d array of the adjusted payoff simulation with the control variates

compute_coefficients(statistics: MCStatistics) None[source]

Compute the (optimal) coefficients of the control variates.

These formulas can be found in Monte-Carlo Methods in Financial Engineering by Paul Glasserman - 4.1.2 Multiple Controls p196

Parameters

statistics

statistics object which contains all the simulations of the payoff and the control variates

Note

this function updates directly the relevant _payoff_statistics_with_cv member

compute_coefficients_mlmc(statistics: MCStatistics, level: int) None[source]

Compute the (optimal) coefficients of the control variates for the MLMC.

Parameters
  • statistics – statistics object

  • level

    current level in the Multilevel Monte-Carlo

    See also

    function compute_coefficients()

class NoControlVariates(products: [<class 'rpylib.product.product.Product'>], prices: [typing.Union[float, <built-in function array>]])[source]

Bases: ControlVariates

Dummy class when there is no control variate

process(times, path: array, jump_path: array, payoff_underlying) array[source]

Process the path information: compute the payoff underlyings, then the payoff value.

Parameters
  • times – times of the path

  • path – path of the underlyings

  • jump_path – only the pure jump path of the underlying

  • payoff_underlying – payoff underlying values

Returns

the value of the payoff for these underlyings path

process_mlmc(times, path_fine, path_coarse, jump_path_fine, jump_path_coarse, payoff_underlying_from_FP, payoff_underlying_from_CP) array[source]

Process the path information in the case of the MLMC

Parameters
  • times – times of the path

  • path_fine – path of the fine underlying

  • path_coarse – path of the coarse underlying

  • jump_path_fine – pure jump path of the fine underlying

  • jump_path_coarse – pure jump path of the coarse underlying

  • payoff_underlying_from_FP – payoff underlying values given by the fine underlying

  • payoff_underlying_from_CP – payoff underlying values given by the coarse underlying

Returns

an array of both the fine and coarse payoffs

See also

this is the MLMC version of process()

initialisation(payoff_underlying_type) None[source]

If two underlyings are closely related, for example S and log(S), one don’t need to compute each of them as one can be implied from this other. This function aims to implement this logic.

Parameters

payoff_underlying_type

this the type() of the payoff underlying object

compute_coefficients(statistics: MCStatistics)[source]

Compute the (optimal) coefficients of the control variates.

These formulas can be found in Monte-Carlo Methods in Financial Engineering by Paul Glasserman - 4.1.2 Multiple Controls p196

Parameters

statistics

statistics object which contains all the simulations of the payoff and the control variates

Note

this function updates directly the relevant _payoff_statistics_with_cv member

compute_coefficients_mlmc(statistics: MCStatistics, level: int)[source]

Compute the (optimal) coefficients of the control variates for the MLMC.

Parameters
  • statistics – statistics object

  • level

    current level in the Multilevel Monte-Carlo

    See also

    function compute_coefficients()

underlying

Definition of a financial underlying.

Example
  • Spot underlying: the most common underlying corresponding to the spot price

  • Asian underlying: average of the considered underlying over a period of time

  • Libor underlyings: libor-like underlyings

class UnderlyingDimension(value)[source]

Bases: Enum

Dimension of the underlying; it is multidimensional if the payoff is a function of more than one underlying.

Example
  • a standard equity Call option is unidimensional

  • a Rainbow option is multidimensional as it involves to compute the maximum of performances

ONEDIMENSIONAL = 1
MULTIDIMENSIONAL = 2
class Discretisation(value)[source]

Bases: Enum

Discretisation type for some non-trivial underlying

Example
  • Asian option can be daily/weekly/etc. average

DAILY = 1
WEEKLY = 2
MONTHLY = 3
YEARLY = 4
discretisation_year_fraction(discretisation: Discretisation) float[source]

Convert the discretisation enum to the corresponding year fraction By default, the year fraction convention is Act365.

Parameters

discretisation – discretisation type

Returns

the year fraction

class Underlying[source]

Bases: ABC

Abstract class for an underlying object

Note

the values of the process might be passed as the logarithms of the spot for optimisation purpose.

underlying_dimension = 1
abstract value(times, path: array, jump_path: array, payoff_underlying=None) array[source]

call method when the process is simulated under the same representation

Parameters
  • times\(t_0, t_1,..., t_n\)

  • path\(log(S_0), log(S_1),...,log(S_n)\)

  • jump_path\(log(J_0), log(J_1),..., log(J_n)\) where \(J_i\) is the jump at time \(t_i\) some payoffs need the fine structure of the jumps (for example the DefaultTime underlying)

  • payoff_underlying – payoff underlying valued passed for optimisation purpose

Returns

value of the underlying for the trajectory defined by (times, path)

update(process_representation: ProcessRepresentation)[source]

update the underlying given the process representation type

imply_from_payoff_underlying(payoff_underlying_type) Callable[source]

If the underlying is closely related (potentially the same) to the payoff underlying, then we can use this knowledge to speed up the computation of the underlying in scope.

Parameters

payoff_underlying_type – underlying type of the payoff underlying

Returns

a function that will take the times, the path and the payoff underlying value and return the underlying value from the relevant quantities

check_consistency(process_dimension: int)[source]
compute_times_grid(maturity: float) TimeGrid[source]

Compute the time axes adapted to the underlying: - a spot underlying will only return 0, maturity - an Asian underlying will return t_0, t_1,…, t_n where the t_i are the times when the underlying is averaged

Parameters

maturity – maturity of the product

Returns

the time axes’ discretisation adapted to the underlying

class Spot[source]

Bases: Underlying

Spot underlying, the standard underlying used in financial payoffs. This is the spot at maturity.

underlying_dimension = 2
value(times, path: array, jump_path: array, payoff_underlying=None) array[source]

call method when the process is simulated under the same representation

Parameters
  • times\(t_0, t_1,..., t_n\)

  • path\(log(S_0), log(S_1),...,log(S_n)\)

  • jump_path\(log(J_0), log(J_1),..., log(J_n)\) where \(J_i\) is the jump at time \(t_i\) some payoffs need the fine structure of the jumps (for example the DefaultTime underlying)

  • payoff_underlying – payoff underlying valued passed for optimisation purpose

Returns

value of the underlying for the trajectory defined by (times, path)

class Libors[source]

Bases: Underlying

Libors underlyings.

Note

this object represents a Libor-like underlying and can used in the Lévy Forward Market too.

underlying_dimension = 1
value(times, path: array, jump_path: array, payoff_underlying=None) array[source]

call method when the process is simulated under the same representation

Parameters
  • times\(t_0, t_1,..., t_n\)

  • path\(log(S_0), log(S_1),...,log(S_n)\)

  • jump_path\(log(J_0), log(J_1),..., log(J_n)\) where \(J_i\) is the jump at time \(t_i\) some payoffs need the fine structure of the jumps (for example the DefaultTime underlying)

  • payoff_underlying – payoff underlying valued passed for optimisation purpose

Returns

value of the underlying for the trajectory defined by (times, path)

class LogSpot[source]

Bases: Underlying

Log-Spot underlying, simply the logarithm of the spot underlying

underlying_dimension = 2
value(times, path: array, jump_path: array, payoff_underlying=None) array[source]
Returns

the logarithm of the last spot underlying

class Asian(discretisation: Discretisation = Discretisation.DAILY)[source]

Bases: Underlying

Arithmetic average of a single underlying

underlying_dimension = 2
__init__(discretisation: Discretisation = Discretisation.DAILY)[source]

Arithmetic Asian underlying

update(process_representation: ProcessRepresentation)[source]

update the underlying given the process representation type

value(times, path: array, jump_path: array, payoff_underlying=None) array[source]
Returns

the average of the spot underlying over the times

compute_times_grid(maturity: float) TimeGrid[source]

Compute the time axes adapted to the underlying: - a spot underlying will only return 0, maturity - an Asian underlying will return t_0, t_1,…, t_n where the t_i are the times when the underlying is averaged

Parameters

maturity – maturity of the product

Returns

the time axes’ discretisation adapted to the underlying

class Mean[source]

Bases: Underlying

Arithmetic average of several underlyings

__init__()[source]
update(process_representation: ProcessRepresentation)[source]

update the underlying given the process representation type

value(times, path: array, jump_path: array, payoff_underlying=None) array[source]

call method when the process is simulated under the same representation

Parameters
  • times\(t_0, t_1,..., t_n\)

  • path\(log(S_0), log(S_1),...,log(S_n)\)

  • jump_path\(log(J_0), log(J_1),..., log(J_n)\) where \(J_i\) is the jump at time \(t_i\) some payoffs need the fine structure of the jumps (for example the DefaultTime underlying)

  • payoff_underlying – payoff underlying valued passed for optimisation purpose

Returns

value of the underlying for the trajectory defined by (times, path)

class Performances(spots: list[float])[source]

Bases: Underlying

Performances vector of underlyings, that is the ratios of the spot underlyings at maturity by their initial values

underlying_dimension = 2
__init__(spots: list[float])[source]
value(times, path: array, jump_path: array, payoff_underlying=None) float[source]

call method when the process is simulated under the same representation

Parameters
  • times\(t_0, t_1,..., t_n\)

  • path\(log(S_0), log(S_1),...,log(S_n)\)

  • jump_path\(log(J_0), log(J_1),..., log(J_n)\) where \(J_i\) is the jump at time \(t_i\) some payoffs need the fine structure of the jumps (for example the DefaultTime underlying)

  • payoff_underlying – payoff underlying valued passed for optimisation purpose

Returns

value of the underlying for the trajectory defined by (times, path)

class MaximumOfPerformances(spots: list[float])[source]

Bases: Underlying

Maximum of performances of underlyings

__init__(spots: list[float])[source]
Parameters

spots

initial spots values

Note

the performance is the ratios of the underlyings at time T over their initial values at time 0

value(times, path: array, jump_path: array, payoff_underlying=None) float[source]

call method when the process is simulated under the same representation

Parameters
  • times\(t_0, t_1,..., t_n\)

  • path\(log(S_0), log(S_1),...,log(S_n)\)

  • jump_path\(log(J_0), log(J_1),..., log(J_n)\) where \(J_i\) is the jump at time \(t_i\) some payoffs need the fine structure of the jumps (for example the DefaultTime underlying)

  • payoff_underlying – payoff underlying valued passed for optimisation purpose

Returns

value of the underlying for the trajectory defined by (times, path)

class NthSpot(index: int)[source]

Bases: Underlying

Value of the spot of the n-th underlying among M underlyings (M>=n)

__init__(index: int)[source]
Parameters

index – underlying index, index=1 corresponds to the first spot S1.

value(times, path: array, jump_path: array, payoff_underlying=None) array[source]
Returns

the logarithm of the last spot underlying

imply_from_payoff_underlying(payoff_underlying_type) Callable[source]

If the underlying is closely related (potentially the same) to the payoff underlying, then we can use this knowledge to speed up the computation of the underlying in scope.

Parameters

payoff_underlying_type – underlying type of the payoff underlying

Returns

a function that will take the times, the path and the payoff underlying value and return the underlying value from the relevant quantities

class Indicators(thresholds: list[float])[source]

Bases: Underlying

Indicator functions, that is, it is equal to 1 if above the threshold else 0

underlying_dimension = 2
__init__(thresholds: list[float])[source]

For the moment, this is the product of indicators with > condition :param thresholds: the indicator function is equal to 1 if greater than the threshold, 0 otherwise

value(times, path: array, jump_path: array, payoff_underlying=None) array[source]

call method when the process is simulated under the same representation

Parameters
  • times\(t_0, t_1,..., t_n\)

  • path\(log(S_0), log(S_1),...,log(S_n)\)

  • jump_path\(log(J_0), log(J_1),..., log(J_n)\) where \(J_i\) is the jump at time \(t_i\) some payoffs need the fine structure of the jumps (for example the DefaultTime underlying)

  • payoff_underlying – payoff underlying valued passed for optimisation purpose

Returns

value of the underlying for the trajectory defined by (times, path)

class DefaultTime(default_level: float)[source]

Bases: Underlying

Default times underlyings as modelled in the paper ‘A Structural Jump Threshold Framework for Credit Risk’ by Garreau and Kercheval

__init__(default_level: float)[source]
value(times, path: array, jump_path: array, payoff_underlying=None) array[source]

call method when the process is simulated under the same representation

Parameters
  • times\(t_0, t_1,..., t_n\)

  • path\(log(S_0), log(S_1),...,log(S_n)\)

  • jump_path\(log(J_0), log(J_1),..., log(J_n)\) where \(J_i\) is the jump at time \(t_i\) some payoffs need the fine structure of the jumps (for example the DefaultTime underlying)

  • payoff_underlying – payoff underlying valued passed for optimisation purpose

Returns

value of the underlying for the trajectory defined by (times, path)

class DefaultTimeNthUnderlying(default_levels: list[float], underlying_index: int)[source]

Bases: _DefaultTimes

Default time of the n-th underlying among M underlying (M>=n)

underlying_dimension = 1
__init__(default_levels: list[float], underlying_index: int)[source]
value(times, path: array, jump_path: array, payoff_underlying=None) array[source]

call method when the process is simulated under the same representation

Parameters
  • times\(t_0, t_1,..., t_n\)

  • path\(log(S_0), log(S_1),...,log(S_n)\)

  • jump_path\(log(J_0), log(J_1),..., log(J_n)\) where \(J_i\) is the jump at time \(t_i\) some payoffs need the fine structure of the jumps (for example the DefaultTime underlying)

  • payoff_underlying – payoff underlying valued passed for optimisation purpose

Returns

value of the underlying for the trajectory defined by (times, path)

class NthDefaultTimes(default_levels: list[float], index: int)[source]

Bases: _DefaultTimes

N-th default times, that is the first time when at least n underlyings (out of M, M>n) have defaulted

underlying_dimension = 1
__init__(default_levels: list[float], index: int)[source]
Parameters

index – underlying index, index=1 corresponds to the first spot S1.

value(times, path: array, jump_path: array, payoff_underlying=None) array[source]

call method when the process is simulated under the same representation

Parameters
  • times\(t_0, t_1,..., t_n\)

  • path\(log(S_0), log(S_1),...,log(S_n)\)

  • jump_path\(log(J_0), log(J_1),..., log(J_n)\) where \(J_i\) is the jump at time \(t_i\) some payoffs need the fine structure of the jumps (for example the DefaultTime underlying)

  • payoff_underlying – payoff underlying valued passed for optimisation purpose

Returns

value of the underlying for the trajectory defined by (times, path)