Simulated Paths

The concept of a path adds a layer of abstraction. On the one-hand side we have models and simulations. These objects are specified by the mathematical details of stochastic processes. On the other hand-side we have payoffs and products. These objects are specified by the business context.

A path is used to link business context and payoff evaluation to models and simulations.

Path Creation

DiffFusion.AbstractPathType
abstract type AbstractPath end

An AbstractPath specifies the interface for path implementations.

This aims at providing the flexibility to add other types of paths in the future.

source
DiffFusion.PathType
struct Path <: AbstractPath
    sim::Simulation
    ts_dict::Dict{String,<:Termstructure}
    state_alias_dict::Dict{String,Int}
    context::Context
    interpolation::PathInterpolation
end

A Path combines a model, simulated model states and term structures. The interface to market references is established by a valuation context.

Paths are used by payoffs to calculate simulated zero bonds, asset prices and further building blocks of financial instrument payoffs.

source
DiffFusion.pathFunction
path(
    sim::Simulation,
    ts_dict::Dict{String,<:Termstructure},
    cxt::Context,
    ip::PathInterpolation = NoPathInterpolation
    )

Create a Path object.

source
path(
    sim::Simulation,
    ts::Vector{Termstructure},
    cxt::Context,
    ip::PathInterpolation = NoPathInterpolation
    )

Create a Path object from a list of term structures.

source
DiffFusion.PathInterpolationType
@enum(
    PathInterpolation,
    NoPathInterpolation,
    LinearPathInterpolation,
)

PathInterpolation encodes how simulated states can be interpolates.

source

Path Functions

DiffFusion.numeraireFunction
numeraire(p::AbstractPath, t::ModelTime, curve_key::String)

Calculate the numeraire in the domestic currency.

We allow for curve-specific numeraire calculation e.g. to allow for trade-specific discounting in AMC valuation.

source
numeraire(p::Path, t::ModelTime, curve_key::String)

Calculate the numeraire in the domestic currency.

We allow for curve-specific numeraire calculation e.g. to allow for trade-specific discounting in AMC valuation.

source
DiffFusion.bank_accountFunction
bank_account(p::AbstractPath, t::ModelTime, key::String)

Calculate a continuous compounded bank account value.

source
bank_account(p::Path, t::ModelTime, key::String)

Calculate a continuous compounded bank account value.

source
DiffFusion.zero_bondFunction
zero_bond(p::AbstractPath, t::ModelTime, T::ModelTime, key::String)

Calculate a zero coupon bond price.

source
zero_bond(p::Path, t::ModelTime, T::ModelTime, key::String)

Calculate a zero coupon bond price.

source
DiffFusion.zero_bondsFunction
zero_bonds(
    yts::YieldTermstructure,
    m::GaussianHjmModel,
    t::ModelTime,
    T::AbstractVector,
    SX::ModelState,
    )

Zero bond price reconstruction.

Returns a vector of length p where p is the number of paths in SX.

source
zero_bond(p::AbstractPath, t::ModelTime, T::ModelTime, key::String)

Calculate a zero coupon bond prices.

source
zero_bonds(p::Path, t::ModelTime, T::AbstractVector, key::String)

Calculate zero coupon bond prices.

source
DiffFusion.compounding_factorFunction
compounding_factor(p::AbstractPath, t::ModelTime, T1::ModelTime, T2::ModelTime, key::String)

Calculate a compounding factor P(t,T1) / P(t,T2).

source
compounding_factor(p::Path, t::ModelTime, T1::ModelTime, T2::ModelTime, key::String)

Calculate a compounding factor P(t,T1) / P(t,T2).

source
DiffFusion.assetFunction
asset(p::AbstractPath, t::ModelTime, key::String)

Calculate asset price.

source
asset(p::Path, t::ModelTime, key::String)

Calculate asset price.

source
DiffFusion.forward_assetFunction
forward_asset(p::AbstractPath, t::ModelTime, T::ModelTime, key::String)

Calculate forward asset price as expectation in T-forward measure.

source
forward_asset(p::Path, t::ModelTime, T::ModelTime, key::String)

Calculate forward asset price as expectation in T-forward measure, conditional on time-t.

source
DiffFusion.forward_asset_and_zero_bondsFunction
forward_asset_and_zero_bonds(p::AbstractPath, t::ModelTime, T::ModelTime, key::String)

Calculate asset and zero bond components for forward asset price calculation.

source
forward_asset_zero_bonds(p::Path, t::ModelTime, T::ModelTime, key::String)

Calculate asset (plus deterministic jumps) as well as domestic and foreign zero bond price associated with an Asset key.

This function implements methodology redundant to forward_asset(...). But it returns asset and zero bonds separately.

This function is used for barrier option pricing.

source
DiffFusion.fixingFunction
fixing(p::AbstractPath, t::ModelTime, key::String)

Return a fixing from a term structure.

This is used to handle fixings for indices etc.

source
fixing(p::Path, t::ModelTime, key::String)

Return a fixing from a term structure.

source
DiffFusion.asset_convexity_adjustmentFunction
asset_convexity_adjustment(
    p::AbstractPath,
    t::ModelTime,
    T0::ModelTime,
    T1::ModelTime,
    T2::ModelTime,
    key::String
    )

Return the convexity adjustment for a YoY asset payoff.

source
asset_convexity_adjustment(
    p::Path,
    t::ModelTime,
    T0::ModelTime,
    T1::ModelTime,
    T2::ModelTime,
    key::String
    )

Return the convexity adjustment for a YoY asset payoff.

source
DiffFusion.forward_indexFunction
forward_index(p::AbstractPath, t::ModelTime, T::ModelTime, key::String)

Expectation Et^T[ST] of a tradeable asset.

source
forward_index(p::Path, t::ModelTime, T::ModelTime, key::String)

Expectation Et^T[ST] of a tradeable asset.

source
DiffFusion.index_convexity_adjustmentFunction
index_convexity_adjustment(
    p::AbstractPath,
    t::ModelTime,
    T0::ModelTime,
    T1::ModelTime,
    T2::ModelTime,
    key::String
    )

Return the convexity adjustment for a YoY index payoff.

source
index_convexity_adjustment(
    p::Path,
    t::ModelTime,
    T0::ModelTime,
    T1::ModelTime,
    T2::ModelTime,
    key::String
    )

Return the convexity adjustment for a YoY index payoff.

source
DiffFusion.future_indexFunction
future_index(p::AbstractPath, t::ModelTime, T::ModelTime, key::String)

Expectation E_t^Q[F(T,T)] of a Future index/price.

source
future_index(p::Path, t::ModelTime, T::ModelTime, key::String)

Expectation E_t^Q[F(T,T)] of a Future index/price.

source

Auxiliary methods

Base.lengthFunction
length(p::AbstractPath)

Return the number of realisations represented by the AbstractPath object.

We assume that model functions applied to an AbstractPath return a vector of length(p) where p is the number realisations.

source
length(p::Path)

Derive the number of realisations from the linked simulation.

source
DiffFusion.state_variableFunction
state_variable(sim::Simulation, t::ModelTime, ip::PathInterpolation)

Derive a state variable for a given observation time.

source
DiffFusion.discountFunction
discount(
    t::ModelTime,
    ts_dict::Dict{String,Termstructure},
    first_alias::String,
    second_alias::Union{String,Nothing} = nothing,
    operation::Union{String,Nothing} = nothing,
    )

Derive the discount factor for one or two of curve alias and a curve operation.

source