markovchain
markovchain
One-dimensional CTMC implementation
- vol_adjustment(model: LevyModel, h: float)[source]
For processes with infinite variation, the small jumps of size less than h are approximated by a Brownian motion. This function computes the corresponding coefficient.
- Parameters
model – Lévy model
h – spatial step h
- compute_mu_h(levy_measure, grid: CTMCGrid, axis: array, origin: int) float[source]
Computation of the drift mu_h of the CTMC
- Parameters
levy_measure – Lévy measure of the process
grid – states grid
axis – axis
origin – origin coordinate
- Returns
the drift mu_h
- class MarkovChain(times: array, values: list[numpy.array], states_increments: list[numpy.array])[source]
Bases:
objectMarkov Chain object storing the simulation times, its values and state increments.
- __init__(times: array, values: list[numpy.array], states_increments: list[numpy.array])[source]
- Parameters
times – simulation times
values – Markov chain values
states_increments – Markov chain increments
- times
- values
- states_increments
- class MarkovChainProcess(model: LevyModel, method: SamplingMethod, grid: CTMCGrid)[source]
Bases:
LevyProcessDescription of a Markov-Chain process approximating a Lévy model over spatial states axes
- Parameters
model – Lévy model
grid – states grid
method – sampling method to simulate the discrete states
- __init__(model: LevyModel, method: SamplingMethod, grid: CTMCGrid)[source]
- class MCSimulation[source]
Bases:
objectMethod to simulation the Markov Chain via Monte-Carlo
- simulate_markov_chain() MarkovChain[source]
- static helper_simulate_markov_chain(grid, sampling, all_nb_of_jumps) tuple[list[numpy.array], list[numpy.array]][source]
simulate one path of the non-deterministic part of the underlying
- Parameters
grid – states grid
sampling – sampling method
all_nb_of_jumps – number of jumps for each time interval
- class MCSimulationFixedTimes(process: MarkovChainProcess)[source]
Bases:
MCSimulation,SimulationFixedTimesSimulation of the Markov Chain at (pre-defined) fixed times
- __init__(process: MarkovChainProcess)[source]
- simulate_markov_chain() MarkovChain[source]
simulate one path of the non-deterministic part of the underlying
- class MCSimulationWithJumpTimes(process: MarkovChainProcess)[source]
Bases:
MCSimulation,SimulationWithJumpTimesSimulation of the Markov Chain at stochastic jump times
- __init__(process: MarkovChainProcess)[source]
- simulate_markov_chain() MarkovChain[source]
simulate one path of the non-deterministic part of the underlying
- class MCSimulationMaximumStep(process: MarkovChainProcess, epsilon: float)[source]
Bases:
MCSimulationWithJumpTimes,SimulationMaximumStepSimulation of the Markov Chain at stochastic jump times with maximum time step of size epsilon
- __init__(process: MarkovChainProcess, epsilon: float)[source]
markovchainlevycopula
Lévy copula simulated through a Markov Chain process
- vol_adjustment_ij(i: int, j: int, h: float, levy_model: LevyCopulaModel)[source]
For processes with infinite variation, the small jumps of size less than h are approximated by a Brownian motion. This function computes the corresponding diffusion matrix.
- Parameters
i – i-th coordinate
j – j-th coordinate
levy_model – Lévy copula model
h – spatial step h .. seealso:: function
vol_adjustment()
- class MarkovChainLevyCopula(levy_copula_model: LevyCopulaModel, grid: CTMCGrid, method: SamplingMethod)[source]
Bases:
LevyProcessLévy copula simulated via a Markov Chain process
- __init__(levy_copula_model: LevyCopulaModel, grid: CTMCGrid, method: SamplingMethod)[source]
- Parameters
levy_copula_model – Lévy copula model
grid – states grid
method – sampling method
- class MCLevyCopulaSimulation(process: MarkovChainLevyCopula)[source]
Bases:
objectSimulation method of Markov Chain process for Lévy copulas
- __init__(process: MarkovChainLevyCopula)[source]
- simulate_markov_chain() MarkovChain[source]
- class MCLevyCopulaSimulationFixedTimes(process: MarkovChainLevyCopula)[source]
Bases:
MCLevyCopulaSimulation,SimulationFixedTimesSimulation of a Markov Chain for Lévy copula at (pre-defined) fixed times
- __init__(process: MarkovChainLevyCopula)[source]
- simulate_one_path() StochasticPath[source]
Simulation of the path for deterministic payoff dates
- simulate_markov_chain() MarkovChain[source]
simulate one path of the non-deterministic part of the underlying
- class MCLevyCopulaSimulationWithJumpTimes(process: MarkovChainLevyCopula)[source]
Bases:
MCLevyCopulaSimulation,SimulationWithJumpTimesSimulation of a Markov Chain for Lévy copula at the stochastic jump times
- __init__(process: MarkovChainLevyCopula)[source]
- simulate_one_path() StochasticPath[source]
Simulation of the path for stochastic payoff dates
- simulate_markov_chain() MarkovChain[source]
simulate one path of the non-deterministic part of the underlying
- class MCLevyCopulaSimulationMaximumStep(process: MarkovChainLevyCopula, epsilon: float)[source]
Bases:
MCLevyCopulaSimulationWithJumpTimes,SimulationMaximumStepSimulation of a Markov Chain for Lévy copula at the stochastic jump times with maximum time increment of size epsilon
- __init__(process: MarkovChainLevyCopula, epsilon: float)[source]
- Parameters
process – Lévy process
epsilon – minimum time increment
markovchainsde
Lévy-driven SDE process
- class MarkovChainSDE(model: LevyDrivenSDEModel, method: SamplingMethod, grid: CTMCGrid)[source]
Bases:
ProcessMarkov Chain for a process defined by a Lévy-driven SDE
- __init__(model: LevyDrivenSDEModel, method: SamplingMethod, grid: CTMCGrid)[source]
- Parameters
model – Lévy-driven SDE model
method – sampling method of the Markov Chain
grid – states grid
- initialisation(product: Product, _: Optional[float] = None) None[source]
Initialisation of the process from the characteristics of the product in scope
- Parameters
product – financial product
max_step_epsilon – if epsilon != None then jump times with max step epsilon are used to build the time discretisation steps
- one_simulation_cost(product) float[source]
Returns: the simulating cost corresponding to the numbers of uniform random variables simulated
- pre_computation(mc_paths: int, product: Product) None[source]
Pre-computation, for example simulate the random variables if possible :param mc_paths: number of Monte-Carlo paths :param product: financial product to price
- deterministic_path(times: array) array[source]
- Parameters
times – times of the path
- Returns
the deterministic part of the path
- simulate_one_path() StochasticPath[source]
Simulate (only) one path of the non-deterministic part of the underlying
- class MarkovChainLevyLiborModel(model: LevyLiborModel, method: SamplingMethod, grid: CTMCGrid)[source]
Bases:
MarkovChainSDEMarkov Chain for the Lévy Libor Model and the Forward Market Model
- __init__(model: LevyLiborModel, method: SamplingMethod, grid: CTMCGrid)[source]
- Parameters
model – Lévy-driven SDE model
method – sampling method of the Markov Chain
grid – states grid
- initialisation(product: Product, _: Optional[float] = None) None[source]
Initialisation of the process from the characteristics of the product in scope
- Parameters
product – financial product
max_step_epsilon – if epsilon != None then jump times with max step epsilon are used to build the time discretisation steps