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

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)])
source
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

source
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

source
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

For exact pathwise deltas use a dual number as spot, see the Automatic differentiation section of the manual.

source
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

source
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: the Underlying (spot and dividends), a tuple of them for a multivariate model.
  • rfCurve: the zero rate curve.
  • mcConfig: the MonteCarloConfiguration.
  • T: time, must be positive.
source

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))
source
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 1
source
FinancialMonteCarlo.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.

source
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.

source
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).

source

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

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())
source
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).

source
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.

source
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.

source

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).

source
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.

source
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))
source
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))
source
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.
source
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.
source
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.
source
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.

source
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.

source
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.6

Arguments

  • η: tuple of the $n$ volatilities, all positive.
  • λ: tuple of the first $n - 1$ weights, positive and summing to at most 1 (the last weight is 1 - 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.

source
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

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))
source
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.
source
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.
source

Engines

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.
source
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 continuous Distribution of the subordinator increment over one time step.
source

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.

source
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.

source
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.

source

Parameters

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.

source

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.

source
FinancialMonteCarlo.Spot — Type
Spot()

The spot price of the underlying today: its price is S0, whatever the model. Mostly useful inside positions and portfolios.

source
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, false for a put.
source
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, false for a put.
source
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, false for a put.
source
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, false for a put.
source
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, false for a put.
source
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, false for a put.
source
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, false for a put.
source
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, false for a put.
source
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, false for a put.
source
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, false for a put.
source
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, false for a put.
source
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, false for a put.
source
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, false for a put.
source
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.

source

Portfolios

FinancialMonteCarlo.MarketDataSet — Type
MarketDataSet

The 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).

source
FinancialMonteCarlo.Position — Type
Position

Linear 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).

source
FinancialMonteCarlo.Portfolio — Type
Portfolio

The 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.

source

Index