Reference Every documented name
API reference
Metrics
FinancialMonteCarlo.pricer — Function
pricer(mcProcess, underlying, rfCurve, mcConfig, payoff)
pricer(market, rfCurve, mcConfig, portfolio)Monte Carlo estimate of the price of payoff: the mean of the discounted payoff over the simulated paths. The random number generator is reset to the seed of mcConfig first, so the result is reproducible. Returns a vector of prices for a vector of payoffs or a smile; for a smile in CudaMode it is a CuArray, so the computations on the prices can stay on the GPU.
Arguments
mcProcess: the model (a single name or multivariate process), or aMarketDataSetwithoutunderlying.underlying: theUnderlying(spot and dividends), a tuple of them for a multivariate model.rfCurve: the zero rate curve, e.g.ZeroRate.mcConfig: theMonteCarloConfiguration.payoff: a payoff, a vector of payoffs priced on the same paths, a smile, aFinancialMonteCarlo.Positionor, with aMarketDataSet, aFinancialMonteCarlo.Portfolio.
Examples
model, und = BlackScholesProcess(0.2), Underlying(100.0, 0.01)
mcConfig = MonteCarloConfiguration(10_000, 30)
pricer(model, und, ZeroRate(0.02), mcConfig, EuropeanOption(1.0, 100.0))
pricer(model, und, ZeroRate(0.02), mcConfig, [Forward(1.0), AmericanOption(1.0, 100.0, false)])FinancialMonteCarlo.variance — Function
variance(mcProcess, underlying, rfCurve, mcConfig, payoff)Variance of the discounted payoff per path (a vector for a vector of payoffs or a smile), such that the variance of the price estimate is this value divided by the number of paths Nsim. With FinancialMonteCarlo.StandardMC it is the sample variance of the paths; with FinancialMonteCarlo.AntitheticMC the paths of a pair (Z, -Z) are correlated, so it is twice the sample variance of the averages of the Nsim / 2 pairs (#76): smaller than the variance of the paths for a monotone payoff, larger for an even one (a straddle), for which antithetic sampling increases the error. With FinancialMonteCarlo.SobolMC the points are not independent and this is not an error estimate.
Arguments
mcProcess: the model.rfCurve: the zero rate curve.mcConfig: theMonteCarloConfiguration.payoff: a payoff, a vector of payoffs, a smile or aFinancialMonteCarlo.Position.
FinancialMonteCarlo.confinter — Function
confinter(mcProcess, underlying, rfCurve, mcConfig, payoff, alpha = 99 // 100)Confidence interval at level alpha for the price of payoff, based on the Student t approximation of the Monte Carlo estimator, from the independent samples: the paths, or the antithetic pairs with FinancialMonteCarlo.AntitheticMC (see variance). Not an error estimate with FinancialMonteCarlo.SobolMC, whose points are not independent. Returns a tuple (lower, upper), or a vector of them for a vector of payoffs or a smile.
Arguments
mcProcess: the model.rfCurve: the zero rate curve.mcConfig: theMonteCarloConfiguration.payoff: a payoff, a vector of payoffs, a smile or aFinancialMonteCarlo.Position.alpha: confidence level.
FinancialMonteCarlo.delta — Function
delta(mcProcess, underlying, rfCurve, mcConfig, payoff, dS0 = 1e-7)
delta(market, rfCurve, mcConfig, portfolio, underlying_name, dS0 = 1e-7)Delta of payoff by forward finite difference: the spot of the underlying is bumped by dS0 and the payoff repriced with the same seed. For a MarketDataSet and a FinancialMonteCarlo.Portfolio, only the underlying called underlying_name is bumped (also inside multivariate models); the delta is zero if it is not in the market data set.
Arguments
mcProcess: a single name model, or aMarketDataSetwithoutunderlying.underlying: theUnderlyingwhose spot is bumped.rfCurve: the zero rate curve, e.g.ZeroRate.mcConfig: theMonteCarloConfiguration.payoff: a payoff, a vector of payoffs priced on the same paths, a smile, aFinancialMonteCarlo.Positionor, with aMarketDataSet, aFinancialMonteCarlo.Portfolio.dS0: spot bump.
For exact pathwise deltas use a dual number as spot, see the Automatic differentiation section of the manual.
FinancialMonteCarlo.rho — Function
rho(mcProcess, underlying, rfCurve, mcConfig, payoff, dr = 1e-7)Rho of payoff by forward finite difference: the zero rate (every node of a curve of a ZeroRate, i.e. a parallel shift) is bumped by dr and the payoff repriced with the same seed. Returns a vector for a vector of payoffs or a smile.
Arguments
mcProcess: the model.underlying: theUnderlying(spot and dividends), a tuple of them for a multivariate model.rfCurve: the zero rate curve.mcConfig: theMonteCarloConfiguration.payoff: a payoff, a vector of payoffs, a smile or aFinancialMonteCarlo.Position.dr: rate bump.
FinancialMonteCarlo.distribution — Function
distribution(mcProcess, underlying, rfCurve, mcConfig, T)Simulated values of the underlying at time T, one per path (the last column of the paths returned by simulate).
Arguments
mcProcess: the model.underlying: theUnderlying(spot and dividends), a tuple of them for a multivariate model.rfCurve: the zero rate curve.mcConfig: theMonteCarloConfiguration.T: time, must be positive.
Market data
FinancialMonteCarlo.Underlying — Type
Underlying(S0, d = zero(S0))Spot price S0 and continuous dividend yield d of an asset, passed next to the model to every entry point (pricer(model, underlying, zeroCurve, method, payoff)): the models hold only their parameters (#72). d is either a number or a time dependent curve (see FinancialMonteCarlo.Curve and FinancialMonteCarlo.ImpliedCurve): one type, whose methods dispatch on the type of d where they differ. S0 must be non negative.
Examples
Underlying(100.0)
Underlying(100.0, 0.01)
Underlying(100.0, FinancialMonteCarlo.Curve([0.01, 0.02], 1.0))FinancialMonteCarlo.ZeroRate — Type
ZeroRate(r)Zero rate curve used for discounting and for the risk neutral drift: r is a constant rate, or a curve of instantaneous rates (a FinancialMonteCarlo.Curve, or a FinancialMonteCarlo.ImpliedCurve to reproduce quoted zero rates). One type, whose methods dispatch on the type of r where they differ.
Examples
ZeroRate(0.02)
ZeroRate(FinancialMonteCarlo.Curve([0.01, 0.02], 1.0)) # instantaneous rates on a uniform grid up to 1
ZeroRate(FinancialMonteCarlo.ImpliedCurve([0.01, 0.02], [0.5, 1.0])) # zero rates quoted at 0.5 and 1FinancialMonteCarlo.Curve — Type
Curve(r, T)Curve of instantaneous rates with values r at the increasing times T (two vectors or two tuples; or r on a uniform grid from 0 to a number T), linearly interpolated in between and flat outside. Models only use its integrals over time intervals, both for the drift and for discounting. Curves combine with +, -, * and / with numbers (on the values); two curves can be added and subtracted, which gives a FinancialMonteCarlo.CurveDifference (#81).
The nodes are SVectors (StaticArrays), so a curve is an isbits value: a model on a curve can be differentiated by Enzyme without runtime activity and captured by a GPU kernel (#79). The number of nodes is part of the type: a curve built from vectors has a type known only at run time, so build it once, outside the code that is differentiated or run in a loop, or from tuples, whose length is part of their type.
FinancialMonteCarlo.ImpliedCurve — Function
ImpliedCurve(r, T)Piecewise linear curve of instantaneous rates, starting from zero at time zero, whose integral up to each T[i] equals r[i] * T[i]: use it to turn zero rates (or dividend yields) quoted at maturities T into a FinancialMonteCarlo.Curve. r and T are two vectors or two tuples; with a scalar T the maturities are T/N, 2T/N, ..., T.
FinancialMonteCarlo.CurveDifference — Type
CurveDifference(a, b)The rate a - b, a and b numbers or curves: what - and + between two curves return, e.g. the drift r - d of a model whose rate and dividend are both curves. Lazy: its integral is the difference of the integrals of a and b, exact without building a curve on the union of their times, and its length is known from the types (#81). Numbers can be added to it and subtracted from it; curves are not multiplied or divided by each other (the product of two piecewise linear curves is not piecewise linear).
Monte Carlo configuration
FinancialMonteCarlo.MonteCarloConfiguration — Type
MonteCarloConfiguration(Nsim, Nstep; sampling = StandardMC(), mode = SerialMode(), seed = 0, rng = MersenneTwister(), reseed = true)Monte Carlo pricing method: the method argument of pricer and of the other metrics.
Arguments
Nsim: number of simulated paths, must be positive (and even forFinancialMonteCarlo.AntitheticMC).Nstep: number of time steps of each path, must be positive.sampling: anAbstractSampling:FinancialMonteCarlo.StandardMC,FinancialMonteCarlo.AntitheticMC,FinancialMonteCarlo.SobolMCorFinancialMonteCarlo.ControlVariates.mode: anAbstractMode:FinancialMonteCarlo.SerialMode,FinancialMonteCarlo.MultiThreading,FinancialMonteCarlo.MultiProcess(withDistributed) orFinancialMonteCarlo.CudaMode(withCUDA).seed: the seed ofrng. With batches (MultiThreading,MultiProcess) batchihas seedseed + i, orseed[i]whenseedis a vector with one seed per batch.rng: the random number generator, anyRandom.AbstractRNG. Each batch draws from its own copy.reseed: whentrue, every metric resets the generators to their seeds before simulating, so the results are reproducible; whenfalse, the streams continue from a call to the next.
Examples
MonteCarloConfiguration(10_000, 30)
MonteCarloConfiguration(10_000, 30; seed = 42)
MonteCarloConfiguration(10_000, 30; sampling = FinancialMonteCarlo.AntitheticMC())
MonteCarloConfiguration(10_000, 30; mode = FinancialMonteCarlo.MultiThreading())FinancialMonteCarlo.AbstractMethod — Type
Abstract type of the pricing methods: every package implementing pricer(model, zero_rate, method, payoff) subtypes it.
FinancialMonteCarlo.AbstractMonteCarloConfiguration — Type
Abstract type of the Monte Carlo pricing methods.
FinancialMonteCarlo.execution_mode — Function
execution_mode(method)The FinancialMonteCarlo.AbstractMode the pricing method runs in.
FinancialMonteCarlo.with_mode — Function
with_mode(method, mode)A copy of the pricing method that runs in mode.
FinancialMonteCarlo.AbstractSampling — Type
Abstract type of the sampling schemes of a MonteCarloConfiguration.
FinancialMonteCarlo.StandardMC — Type
Plain Monte Carlo sampling (the default sampling of MonteCarloConfiguration).
FinancialMonteCarlo.AntitheticMC — Type
Antithetic variates: the second half of the paths uses the negated normals of the first half. Requires an even number of paths.
FinancialMonteCarlo.SobolMC — Type
Quasi Monte Carlo sampling with Sobol low discrepancy sequences. Only in FinancialMonteCarlo.SerialMode.
FinancialMonteCarlo.ControlVariates — Type
ControlVariates(variate, conf_variate, sampling = StandardMC(); price = nothing)Control variates sampling for MonteCarloConfiguration. A pilot simulation with configuration conf_variate estimates the optimal coefficient of the control variate; the main simulation then uses sampling. The control must have the same maturity as the priced payoff.
The method needs the exact (discounted) price of the control: pass it as price, e.g. from the closed forms of FinancialToolbox (blsprice, blsbin, the barriers). It is known without it only for a Forward. Without it the price of the control is the mean of the pilot, which is about as noisy as the main estimate and cancels most of the variance reduction (#75).
FinancialMonteCarlo.AbstractMode — Type
Abstract type of the execution modes: where and how a pricing method runs.
FinancialMonteCarlo.SerialMode — Type
SerialMode()Execution on one thread of the CPU (the default mode of every method).
FinancialMonteCarlo.MultiThreading — Type
MultiThreading(nbatches = Threads.nthreads())Parallel mode splitting the paths into nbatches batches priced on different threads. Each batch has its own seed and its own copy of the generator of the MonteCarloConfiguration, so the result does not depend on the number of threads. Prices are the averages of the batch prices, weighted by their number of paths.
Generators that cannot be copied (VectorizedRNG) and FinancialMonteCarlo.SobolMC are not supported. Of the automatic differentiation backends, only the forward ones are supported: the batches would write to the same tape of ReverseDiff, and Mooncake cannot differentiate through tasks.
FinancialMonteCarlo.MultiProcess — Type
MultiProcess(nbatches = nworkers())Parallel mode splitting the paths into nbatches batches priced on the workers of Distributed, which needs using Distributed. Each batch has its own seed and its own copy of the generator of the MonteCarloConfiguration, so the result does not depend on the number of workers, which take the next batch when they finish one. Prices are the averages of the batch prices, weighted by their number of paths.
The workers must load the package and everything the priced objects use (@everywhere using FinancialMonteCarlo). To differentiate through a pricer, the function must exist on the workers too (@everywhere f(x) = ...): an anonymous function defined only on the main process raises an error. simulate and distribution send all the paths back to the main process, which can take longer than simulating them; the other metrics send back only their results.
reseed = false, generators that cannot be copied (VectorizedRNG) and FinancialMonteCarlo.SobolMC are not supported. Of the automatic differentiation backends, only the forward ones are supported.
FinancialMonteCarlo.CudaMode — Type
CudaMode()Execution on the GPU, which needs using CUDA. The paths, and the results of a smile, stay on the device.
Models
FinancialMonteCarlo.simulate — Function
simulate(mcProcess, underlying, zeroCurve, mcConfig, T)Simulate the paths of underlying (an Underlying, a tuple of them for a multivariate model, one per component) under mcProcess from time 0 to T, under the risk neutral measure given by zeroCurve.
Returns an Nsim × (Nstep + 1) matrix whose i-th row is the i-th path on the uniform time grid 0:T/Nstep:T (the first column is the spot). For multivariate processes, a vector with one such matrix per component. The element type is inferred from the inputs, so it can be a dual number.
New models implement the in-place simulate!(S, mcProcess, underlying, zeroCurve, mcConfig, T).
simulate(engine, mcConfig, T)Simulate the paths of an engine (e.g. BrownianMotion), which needs no zero rate curve, from time 0 to T. Returns an Nsim × (Nstep + 1) matrix, one path per row.
FinancialMonteCarlo.BlackScholesProcess — Type
BlackScholesProcess(σ)Black-Scholes model: under the risk neutral measure the underlying follows a geometric Brownian motion $dS_t = (r_t - d_t) S_t\,dt + σ S_t\,dW_t$.
Arguments
σ: volatility, must be positive.
Examples
model = BlackScholesProcess(0.2)
pricer(model, Underlying(100.0, 0.01), ZeroRate(0.02), MonteCarloConfiguration(10_000, 30), EuropeanOption(1.0, 100.0))FinancialMonteCarlo.BachelierProcess — Type
BachelierProcess(σ)Bachelier (normal) model: the price discounted with the carry is an arithmetic Brownian motion,
\[S_t = e^{\int_0^t (r_s - d_s)\,ds} \left(S_0 + σ W_t\right),\]
so the discounted price with dividends, $S_0 + σ W_t$, is a martingale. $S_T$ is normal, with mean the forward $F = S_0 e^{\int_0^T (r - d)}$ and standard deviation $σ \sqrt{T} e^{\int_0^T (r - d)}$: European prices are those of the Bachelier formula with that normal volatility ($σ$ itself when $r = d$, as on a future). Prices can be negative.
Arguments
σ: normal volatility, in units of the price, must be positive.
Examples
model = BachelierProcess(20.0)
pricer(model, Underlying(100.0, 0.01), ZeroRate(0.02), MonteCarloConfiguration(10_000, 30), EuropeanOption(1.0, 100.0))FinancialMonteCarlo.HestonProcess — Type
HestonProcess(σ, σ₀, λ, κ, ρ, θ)Heston stochastic volatility model:
\[dS_t = (r_t - d_t) S_t\,dt + \sqrt{v_t} S_t\,dW_t, \qquad dv_t = κ^*(θ^* - v_t)\,dt + σ \sqrt{v_t}\,dZ_t, \qquad d\langle W, Z\rangle_t = ρ\,dt,\]
with risk neutral parameters $κ^* = κ + λ$ and $θ^* = κθ / (κ + λ)$. Both are simulated with an Euler scheme on the log price, flooring the variance at a tiny positive value.
Arguments
σ: volatility of the variance, must be positive.σ₀: initial volatility, must be positive.λ: market price of volatility risk.κ: speed of mean reversion ($κ + λ$ must not be zero).ρ: correlation between the Brownian motions, in $[-1, 1]$.θ: long term variance.
FinancialMonteCarlo.KouProcess — Type
KouProcess(σ, λ, p, λ₊, λ₋)Kou jump diffusion: the log price is a Brownian motion with volatility σ plus a compound Poisson process with intensity λ and double exponential jumps (up with probability p, with exponential sizes of rate λ₊ up and λ₋ down). The drift is chosen to make the discounted price a martingale.
Arguments
σ: volatility, must be positive.λ: jump intensity, must be positive.p: probability of an up jump, in $[0, 1]$.λ₊: rate of the exponential up jumps, must be greater than 1 (for a finite forward).λ₋: rate of the exponential down jumps, must be positive.
FinancialMonteCarlo.MertonProcess — Type
MertonProcess(σ, λ, μ_jump, σ_jump)Merton jump diffusion: the log price is a Brownian motion with volatility σ plus a compound Poisson process with intensity λ and normally distributed jumps. The drift is chosen to make the discounted price a martingale.
Arguments
σ: volatility, must be positive.λ: jump intensity, must be positive.μ_jump: mean of the jumps of the log price.σ_jump: standard deviation of the jumps of the log price, must be positive.
FinancialMonteCarlo.VarianceGammaProcess — Type
VarianceGammaProcess(σ, θ, κ)Variance Gamma model: the log price is a Brownian motion with drift θ and volatility σ, evaluated at a gamma subordinator with unit mean rate and variance rate κ. The drift is chosen to make the discounted price a martingale.
Arguments
σ: volatility of the subordinated Brownian motion, must be positive.θ: drift of the subordinated Brownian motion.κ: variance rate of the subordinator, must be positive.
The parameters must satisfy $1 - σ^2 κ / 2 - θ κ > 0$ for the forward to be finite.
FinancialMonteCarlo.NormalInverseGaussianProcess — Type
NormalInverseGaussianProcess(σ, θ, κ)Normal Inverse Gaussian model: the log price is a Brownian motion with drift θ and volatility σ, evaluated at an inverse gaussian subordinator with unit mean rate and variance rate κ. The drift is chosen to make the discounted price a martingale.
Arguments
σ: volatility of the subordinated Brownian motion, must be positive.θ: drift of the subordinated Brownian motion.κ: variance rate of the subordinator, must be positive.
The parameters must satisfy $1 - σ^2 κ - 2 θ κ > 0$ for the forward to be finite.
FinancialMonteCarlo.LogNormalMixture — Type
LogNormalMixture(η, λ)LogNormal mixture model of Brigo and Mercurio: the local volatility diffusion, in $X_t = \log(S_t / S_0)$,
\[dX_t = \left(r_t - d_t - \frac{σ^2(t, X_t)}{2}\right) dt + σ(t, X_t)\,dW_t, \qquad σ^2(t, x) = \frac{\sum_i λ_i η_i^2 p_i(t, x)}{\sum_i λ_i p_i(t, x)},\]
where $p_i(t, \cdot)$ is the density of $X_t$ in the Black-Scholes model with volatility $η_i$. The law of $S_t$ is the mixture $\sum_i λ_i \text{Law}(S^i_t)$ at every time, so European prices are the weighted sums of the Black-Scholes prices with volatilities $η_i$.
Simulated with an Euler scheme on $X$, the local volatility taken at the start of each step (at $t = 0$, its limit $\sum_i λ_i η_i / \sum_i λ_i / η_i$): European prices converge to the closed form as the number of steps grows, slowly when the volatilities are far apart (the local volatility then changes sharply with $X$).
Examples
LogNormalMixture((0.2, 0.3), (0.4,)) # weights 0.4 and 0.6Arguments
η: tuple of the $n$ volatilities, all positive.λ: tuple of the first $n - 1$ weights, positive and summing to at most 1 (the last weight is1 - sum(λ)).
η and λ are tuples, so the number of components is part of the type: a model can be passed to a GPU kernel, and the loops over the components are unrolled.
FinancialMonteCarlo.ShiftedProcess — Type
ShiftedProcess(model, α)Shifted (displaced) version of any single name model: the model started from $(1 - α) S_0$ plus a deterministic shift $α S_0$ growing at the risk neutral rate,
\[S_t = X_t + α S_0 e^{\int_0^t (r_s - d_s)\,ds}, \qquad X_0 = (1 - α) S_0,\]
where $X$ follows model. The forward is the one of model; with $0 ≤ α < 1$ the price stays above $α$ times the forward, with $α < 0$ it can go below zero. ShiftedProcess(BlackScholesProcess(σ), α) is the displaced diffusion, and ShiftedProcess(LogNormalMixture(η, λ), α) the shifted lognormal mixture (it replaces ShiftedLogNormalMixture, removed).
The spot and the dividends are those of the underlying passed with the model (a bump of the spot, as in delta, moves the shift too); model is simulated from Underlying((1 - α) S0, d); the paths of model are simulated by its own simulate!, so every sampling, mode and number type it supports works shifted too.
Arguments
model: a single name model, e.g.BlackScholesProcess,BachelierProcess,HestonProcess.α: shift, as a fraction of the spot price, smaller than 1.
FinancialMonteCarlo.get_parameters returns the parameters of model followed by α.
Examples
model = ShiftedProcess(BlackScholesProcess(0.2), 0.3)
pricer(model, Underlying(100.0, 0.01), ZeroRate(0.02), MonteCarloConfiguration(10_000, 30), EuropeanOption(1.0, 100.0))FinancialMonteCarlo.GaussianCopulaNVariateProcess — Type
GaussianCopulaNVariateProcess(ρ, models...)
GaussianCopulaNVariateProcess(models...)
GaussianCopulaNVariateProcess(model_1, model_2, ρ₁₂)Multivariate model joining single name models through a Gaussian copula with correlation matrix ρ (the identity when omitted; for two models the scalar correlation ρ₁₂ can be passed instead). Each component keeps its own marginal distribution.
Arguments
ρ: symmetric positive definite correlation matrix, one row per model.models: the single name models of the components.
FinancialMonteCarlo.GaussianCopulaNVariateLogProcess — Type
GaussianCopulaNVariateLogProcess(ρ, models...)
GaussianCopulaNVariateLogProcess(models...)
GaussianCopulaNVariateLogProcess(model_1, model_2, ρ₁₂)Like GaussianCopulaNVariateProcess, but the copula is applied to the log returns $x ↦ S_0 e^x$ of the components.
Arguments
ρ: symmetric positive definite correlation matrix, one row per model.models: the single name models of the components.
Engines
FinancialMonteCarlo.BrownianMotion — Type
BrownianMotion(σ, μ)Engine simulating the arithmetic Brownian motion $X_t = μ t + σ W_t$, $X_0 = 0$. If μ is a curve (see FinancialMonteCarlo.Curve) a FinancialMonteCarlo.BrownianMotionVec with time dependent drift is returned.
Arguments
σ: volatility, must be positive.μ: drift.
FinancialMonteCarlo.BrownianMotionVec — Type
BrownianMotionVec(σ, μ)Engine simulating a Brownian motion with time dependent drift, $X_t = \int_0^t μ(s)\,ds + σ W_t$. Built by BrownianMotion when the drift is a curve.
Arguments
σ: volatility, must be positive.μ: drift curve.
FinancialMonteCarlo.GeometricBrownianMotion — Type
GeometricBrownianMotion(σ, μ, x0)Engine simulating the geometric Brownian motion $dX_t = μ X_t\,dt + σ X_t\,dW_t$, $X_0 = x_0$. If μ is a curve a GeometricBrownianMotionVec with time dependent drift is returned.
Arguments
σ: volatility, must be positive.μ: drift.x0: initial value.
FinancialMonteCarlo.GeometricBrownianMotionVec — Type
GeometricBrownianMotionVec(σ, μ, x0)Engine simulating a geometric Brownian motion with time dependent drift. Built by GeometricBrownianMotion when the drift is a curve.
Arguments
σ: volatility, must be positive.μ: drift curve.x0: initial value.
FinancialMonteCarlo.SubordinatedBrownianMotion — Type
SubordinatedBrownianMotion(σ, drift, θ, subordinator)Engine simulating a Brownian motion with drift θ and volatility σ evaluated at a subordinator, plus a deterministic drift: at every time step $X_{t+Δt} = X_t + \text{drift}\,Δt + θ\,Δτ + σ \sqrt{Δτ}\,Z$, with $Δτ$ drawn from subordinator. If drift is a curve a FinancialMonteCarlo.SubordinatedBrownianMotionVec is returned.
Arguments
σ: volatility, must be positive.drift: deterministic drift in calendar time.θ: drift in subordinated time.subordinator: univariate continuousDistributionof the subordinator increment over one time step.
FinancialMonteCarlo.SubordinatedBrownianMotionVec — Type
SubordinatedBrownianMotionVec(σ, drift, θ, subordinator)SubordinatedBrownianMotion with a time dependent deterministic drift.
Arguments
σ: volatility, must be positive.drift: drift curve in calendar time.θ: drift in subordinated time.subordinator: univariate continuousDistributionof the subordinator increment over one time step.
Jumps from uniforms
What AntitheticMC and SobolMC use to draw the jumps of KouProcess and MertonProcess from a fixed number of uniforms per path (also used by VibratoMonteCarlo.jl).
FinancialMonteCarlo.JumpUniforms — Type
JumpUniforms(λT, U)The table to draw the number of jumps of a compound Poisson process with mean λT from a uniform of type U, by inversion: FinancialMonteCarlo.jump_count gives the count. J.M is the Poisson quantile at 1 - sqrt(eps(U)): with SobolMC a path takes 1 + 2 J.M coordinates (the count, then a time and a size per jump) and draws its jumps from the rng when there are more. Used by AntitheticMC and SobolMC for KouProcess and MertonProcess.
FinancialMonteCarlo.jump_count — Function
jump_count(J::JumpUniforms, u)The number of jumps for the uniform u: the smallest n with $P(N_T ≤ n) ≥ u$. Above J.M the distribution function is computed term by term.
FinancialMonteCarlo.jump_quantile — Function
jump_quantile(model, u)The jump size of a MertonProcess (normal) or of a KouProcess (double exponential: downwards with probability 1 - p and rate λ₋, upwards with rate λ₊) at the uniform u, by inversion. Kou's quantile is continuous at u = 1 - p and in p. The methods are defined with the models.
Parameters
FinancialMonteCarlo.get_parameters — Function
get_parameters(x)Numeric parameters of a model or of a payoff, flattened into a vector in field order (the models of a copula are excluded). The inverse of FinancialMonteCarlo.set_parameters!.
FinancialMonteCarlo.set_parameters! — Function
set_parameters!(model, params)Return a copy of model whose parameters are replaced by the vector params, in the order of FinancialMonteCarlo.get_parameters. Despite the !, model is not modified: use the returned value. Useful to write calibration loops that do not depend on the model.
FinancialMonteCarlo.price_type — Function
price_type(inputs...)Number type of the paths and the prices computed from inputs (models, curves, payoffs, smiles, methods, numbers, arrays of them): the type of zero(T1) + zero(T2) + … over the number types Ti of their parameters, so a dual number or Float32 in any input reaches the result. Allocate with it, never with Float64.
A new input type needs a method of FinancialMonteCarlo.number_type only if it is not a subtype of BaseProcess{T} or AbstractPayoff{T}, which carry their number type.
Payoffs
FinancialMonteCarlo.payoff — Function
payoff(S, payoff, rfCurve, mcConfig, T1 = maturity(payoff))Discounted payout of payoff along each simulated path in S, i.e. the vector whose mean is the price. S is the output of simulate up to time T1, which can be later than the maturity of the payoff (as happens when several payoffs are priced on the same paths).
This is the generic interface: each payoff family has an engine implementing it on top of the payoff specific payout, see the Extending section of the manual.
FinancialMonteCarlo.Spot — Type
Spot()The spot price of the underlying today: its price is S0, whatever the model. Mostly useful inside positions and portfolios.
FinancialMonteCarlo.Forward — Type
Forward(T)Forward contract paying $S_T$ at maturity T (no strike).
Arguments
T: time to maturity, must be positive.
FinancialMonteCarlo.EuropeanOption — Type
EuropeanOption(T, K, isCall = true)European vanilla option paying $\max(S_T - K, 0)$ (call) or $\max(K - S_T, 0)$ (put) at maturity T.
Arguments
T: time to maturity, must be positive.K: strike, must be positive.isCall:true(default) for a call,falsefor a put.
FinancialMonteCarlo.BinaryEuropeanOption — Type
BinaryEuropeanOption(T, K, isCall = true)European cash-or-nothing digital option paying 1 at maturity T if $S_T > K$ (call) or $S_T < K$ (put).
Arguments
T: time to maturity, must be positive.K: strike, must be positive.isCall:true(default) for a call,falsefor a put.
FinancialMonteCarlo.BarrierOptionDownOut — Type
BarrierOptionDownOut(T, K, barrier, isCall = true)Down-and-out barrier option: a European option with strike K and maturity T that is knocked out if the underlying ever goes below barrier. The barrier is monitored on the simulation time grid.
Arguments
T: time to maturity, must be positive.K: strike, must be positive.barrier: lower barrier, must be positive.isCall:true(default) for a call,falsefor a put.
FinancialMonteCarlo.BarrierOptionDownIn — Type
BarrierOptionDownIn(T, K, barrier, isCall = true)Down-and-in barrier option: a European option with strike K and maturity T that pays only if the underlying goes below barrier at least once. The barrier is monitored on the simulation time grid.
Arguments
T: time to maturity, must be positive.K: strike, must be positive.barrier: lower barrier, must be positive.isCall:true(default) for a call,falsefor a put.
FinancialMonteCarlo.BarrierOptionUpOut — Type
BarrierOptionUpOut(T, K, barrier, isCall = true)Up-and-out barrier option: a European option with strike K and maturity T that is knocked out if the underlying ever goes above barrier. The barrier is monitored on the simulation time grid.
Arguments
T: time to maturity, must be positive.K: strike, must be positive.barrier: upper barrier, must be positive.isCall:true(default) for a call,falsefor a put.
FinancialMonteCarlo.BarrierOptionUpIn — Type
BarrierOptionUpIn(T, K, barrier, isCall = true)Up-and-in barrier option: a European option with strike K and maturity T that pays only if the underlying goes above barrier at least once. The barrier is monitored on the simulation time grid.
Arguments
T: time to maturity, must be positive.K: strike, must be positive.barrier: upper barrier, must be positive.isCall:true(default) for a call,falsefor a put.
FinancialMonteCarlo.DoubleBarrierOption — Type
DoubleBarrierOption(T, K, D, U, isCall = true)Double knock-out barrier option: a European option with strike K and maturity T that is knocked out if the underlying ever goes below D or above U. The barrier is monitored on the simulation time grid.
Arguments
T: time to maturity, must be positive.K: strike, must be positive.D: lower barrier, must be positive.U: upper barrier, must be positive.isCall:true(default) for a call,falsefor a put.
FinancialMonteCarlo.AsianFixedStrikeOption — Type
AsianFixedStrikeOption(T, K, isCall = true)Arithmetic Asian option with fixed strike, paying $\max(A_T - K, 0)$ (call) or $\max(K - A_T, 0)$ (put) at maturity T, where $A_T$ is the average of the underlying on the simulation time grid.
Arguments
T: time to maturity, must be positive.K: strike, must be positive.isCall:true(default) for a call,falsefor a put.
FinancialMonteCarlo.AsianFloatingStrikeOption — Type
AsianFloatingStrikeOption(T, isCall = true)Arithmetic Asian option with floating strike, paying $\max(S_T - A_T, 0)$ (call) or $\max(A_T - S_T, 0)$ (put) at maturity T, where $A_T$ is the average of the underlying on the simulation time grid.
Arguments
T: time to maturity, must be positive.isCall:true(default) for a call,falsefor a put.
FinancialMonteCarlo.AmericanOption — Type
AmericanOption(T, K, isCall = true)American vanilla option, exercisable at any time step up to maturity T with exercise value $\max(S_t - K, 0)$ (call) or $\max(K - S_t, 0)$ (put). Priced with the Longstaff-Schwartz regression.
Arguments
T: time to maturity, must be positive.K: strike, must be positive.isCall:true(default) for a call,falsefor a put.
FinancialMonteCarlo.BinaryAmericanOption — Type
BinaryAmericanOption(T, K, isCall = true)American digital option, exercisable at any time step up to maturity T, paying 1 when exercised in the money ($S_t > K$ for a call, $S_t < K$ for a put). Priced with the Longstaff-Schwartz regression.
Arguments
T: time to maturity, must be positive.K: strike, must be positive.isCall:true(default) for a call,falsefor a put.
FinancialMonteCarlo.BermudanOption — Type
BermudanOption(T, K, isCall = true)Bermudan vanilla option, exercisable at the dates in T (the last one being the maturity), with exercise value $\max(S_t - K, 0)$ (call) or $\max(K - S_t, 0)$ (put). Priced with the Longstaff-Schwartz regression. Exercise dates should lie on the simulation time grid.
Arguments
T: sorted vector of positive exercise dates.K: strike, must be positive.isCall:true(default) for a call,falsefor a put.
FinancialMonteCarlo.EuropeanOptionND — Type
EuropeanOptionND(T, K, isCall = true)European option on the sum of the underlyings of a multivariate model, paying $\max(\sum_i S^i_T - K, 0)$ (call) or $\max(K - \sum_i S^i_T, 0)$ (put) at maturity T.
Arguments
T: time to maturity, must be positive.K: strike, must be positive.isCall:true(default) for a call,falsefor a put.
FinancialMonteCarlo.EuropeanOptionSmile — Type
EuropeanOptionSmile(T, K::Vector, isCall::Vector{Bool})Set of EuropeanOptions with the same maturity T and strikes K, each a call or a put according to isCall. They are priced together on the same paths: pricer, variance, confinter, delta and rho return one value per strike. In CudaMode the strikes are computed in one kernel and the results are a CuArray, except for the tuples of confinter.
FinancialMonteCarlo.BinaryEuropeanOptionSmile — Type
BinaryEuropeanOptionSmile(T, K::Vector, isCall::Vector{Bool})Set of BinaryEuropeanOptions with the same maturity T and strikes K, each a call or a put according to isCall. They are priced together on the same paths: pricer, variance, confinter, delta and rho return one value per strike. In CudaMode the strikes are computed in one kernel and the results are a CuArray, except for the tuples of confinter.
FinancialMonteCarlo.EuropeanOptionSurface — Type
EuropeanOptionSurface(T::Vector, K::Vector{<:Vector}, isCall::Vector{<:Vector{Bool}})
EuropeanOptionSurface(smiles::Vector{<:EuropeanOptionSmile})The EuropeanOptionSmiles of several maturities T (positive, strictly increasing): K[i] and isCall[i] are the strikes and the flags of maturity T[i]. The strikes of every maturity are stored as one flat vector (ArraysOfArrays.flatview(surface.K)). pricer, variance, confinter, delta and rho return one value per quote, maturity by maturity, as the smiles one after the other; a pricing method can specialize them to price every quote at once. FinancialMonteCarlo.smiles(surface) gives the smiles.
FinancialMonteCarlo.BinaryEuropeanOptionSurface — Type
BinaryEuropeanOptionSurface(T::Vector, K::Vector{<:Vector}, isCall::Vector{<:Vector{Bool}})
BinaryEuropeanOptionSurface(smiles::Vector{<:BinaryEuropeanOptionSmile})The BinaryEuropeanOptionSmiles of several maturities, as EuropeanOptionSurface.
Portfolios
FinancialMonteCarlo.MarketDataSet — Type
MarketDataSetThe market of a portfolio: the underlyings by name (name → underlying) and the models by key (key → model), see →, joined with +. A single name model is linked to its name, a multivariate model to the tuple of the names of its components, e.g. ("ENI", "AAPL") → copula, whose underlyings are those of the names. name → (model, underlying) links both at once. Models and underlyings are kept in the order they were added; market[key] is the model of key, underlying(market, key) its underlying (a tuple for a multivariate model).
FinancialMonteCarlo.Position — Type
PositionLinear combination of payoffs on the same underlying: payoffs with their weights, in the order they were added. Positions are built with +, -, * and / on payoffs and numbers, e.g. 2 * EuropeanOption(T, K) - Forward(T), or with Position(payoff => weight, ...). The same contract appears once (its weights add up), and a leg whose weight is zero is removed. A position is priced on one simulation, path by path, so pricer, variance and confinter of a position are those of its discounted payoff.
A position iterates as payoff => weight pairs; position[payoff] is the weight of payoff (zero if absent).
FinancialMonteCarlo.Portfolio — Type
PortfolioThe positions on each underlying, by name: built with name → payoff or name → position (see →) and joined with +, which adds the positions on the same name. A basket payoff is linked to the tuple of the names of its underlyings. Priced against a MarketDataSet.
FinancialMonteCarlo.:→ — Function
name → underlying
name → model
name → (model, underlying)
name → payoffLink a name to its Underlying or to a model, giving a MarketDataSet, or to a payoff or FinancialMonteCarlo.Position, giving a FinancialMonteCarlo.Portfolio. name is a String for a single name, and a tuple of names, one per component, for a multivariate model or a basket payoff: ("ENI", "AAPL"). Names joined by _ ("ENI_AAPL") are deprecated. Type → as o<TAB>.
Index
FinancialMonteCarlo.AbstractMethodFinancialMonteCarlo.AbstractModeFinancialMonteCarlo.AbstractMonteCarloConfigurationFinancialMonteCarlo.AbstractSamplingFinancialMonteCarlo.AmericanOptionFinancialMonteCarlo.AntitheticMCFinancialMonteCarlo.AsianFixedStrikeOptionFinancialMonteCarlo.AsianFloatingStrikeOptionFinancialMonteCarlo.BachelierProcessFinancialMonteCarlo.BarrierOptionDownInFinancialMonteCarlo.BarrierOptionDownOutFinancialMonteCarlo.BarrierOptionUpInFinancialMonteCarlo.BarrierOptionUpOutFinancialMonteCarlo.BermudanOptionFinancialMonteCarlo.BinaryAmericanOptionFinancialMonteCarlo.BinaryEuropeanOptionFinancialMonteCarlo.BinaryEuropeanOptionSmileFinancialMonteCarlo.BinaryEuropeanOptionSurfaceFinancialMonteCarlo.BlackScholesProcessFinancialMonteCarlo.BrownianMotionFinancialMonteCarlo.BrownianMotionVecFinancialMonteCarlo.ControlVariatesFinancialMonteCarlo.CudaModeFinancialMonteCarlo.CurveFinancialMonteCarlo.CurveDifferenceFinancialMonteCarlo.DoubleBarrierOptionFinancialMonteCarlo.EuropeanOptionFinancialMonteCarlo.EuropeanOptionNDFinancialMonteCarlo.EuropeanOptionSmileFinancialMonteCarlo.EuropeanOptionSurfaceFinancialMonteCarlo.ForwardFinancialMonteCarlo.GaussianCopulaNVariateLogProcessFinancialMonteCarlo.GaussianCopulaNVariateProcessFinancialMonteCarlo.GeometricBrownianMotionFinancialMonteCarlo.GeometricBrownianMotionVecFinancialMonteCarlo.HestonProcessFinancialMonteCarlo.JumpUniformsFinancialMonteCarlo.KouProcessFinancialMonteCarlo.LogNormalMixtureFinancialMonteCarlo.MarketDataSetFinancialMonteCarlo.MertonProcessFinancialMonteCarlo.MonteCarloConfigurationFinancialMonteCarlo.MultiProcessFinancialMonteCarlo.MultiThreadingFinancialMonteCarlo.NormalInverseGaussianProcessFinancialMonteCarlo.PortfolioFinancialMonteCarlo.PositionFinancialMonteCarlo.SerialModeFinancialMonteCarlo.ShiftedProcessFinancialMonteCarlo.SobolMCFinancialMonteCarlo.SpotFinancialMonteCarlo.StandardMCFinancialMonteCarlo.SubordinatedBrownianMotionFinancialMonteCarlo.SubordinatedBrownianMotionVecFinancialMonteCarlo.UnderlyingFinancialMonteCarlo.VarianceGammaProcessFinancialMonteCarlo.ZeroRateFinancialMonteCarlo.:→FinancialMonteCarlo.ImpliedCurveFinancialMonteCarlo.confinterFinancialMonteCarlo.deltaFinancialMonteCarlo.distributionFinancialMonteCarlo.execution_modeFinancialMonteCarlo.get_parametersFinancialMonteCarlo.jump_countFinancialMonteCarlo.jump_quantileFinancialMonteCarlo.payoffFinancialMonteCarlo.price_typeFinancialMonteCarlo.pricerFinancialMonteCarlo.rhoFinancialMonteCarlo.set_parameters!FinancialMonteCarlo.simulateFinancialMonteCarlo.varianceFinancialMonteCarlo.with_mode