American Monte Carlo
DiffFusion.AmcPayoff
— Typeabstract type AmcPayoff <: Payoff end
AmcPayoff is used to implement common methods for AMC payoffs. Concrete AMC payoffs are assumed to hold a fields links::AmcPayoffLinks
and regr::AmcPayoffRegression
.
An AMC payoff is special and does not fit into the structure of unary/binary nodes. Instead, we have several edges to other payoffs with observation times before (x and y) and after (z) its own observation time.
DiffFusion.AmcPayoffLinks
— Typestruct AmcPayoffLinks
obs_time::ModelTime
x::AbstractVector
y::AbstractVector
z::AbstractVector
curve_key::String
end
An AmcPayoffLinks object holds common data fields for an American Monte Carlo (AMC) payoff.
Here, obs_time
is the observation time of the AMC payoff and x
, y
, z
are related Payoff
vectors. The elements of x
and y
represent random variables with observation times after obs_time
. The elements of z
represent random variables with observation time (at or) before obs_time
. z
is the vector of regression variables.
The parameter curve_key
is used to specify a discount curve for numeraire price calculation.
We calculate $X$ as the sum of discounted payoff values of x
and $Y$ as the sum of discounted payoff values of y
. $Z = [ Z_1, Z_2, ... ]$ represent the (undiscounted) values of the regression variables from the payoff vector z
.
Then we estimate the trigger variable
$T = E[ X - Y | Z_1, Z_2, ... ]$
An actual AMC payoff uses $X$, $Y$, and $T$ to calculate its values.
DiffFusion.AmcPayoffRegression
— Typemutable struct AmcPayoffRegression
path::Union{AbstractPath, Nothing}
make_regression::Union{Function, Nothing}
regression::Any
end
AmcPayoffRegression holds the common data fields to regression and regression calibration for AMC payoffs. These data fields are supposed to be updated subsequent creation of the object. As a consequence, AmcPayoffRegression is declared mutable.
The element path
is a Monte Carlo path. This element is typically linked to a simulation and a context mapping.
make_regression
is a function/functor with signature
make_regression(C::AbstractMatrix, O::AbstractVector) -> obj.
This function is typically a lambda for polynomial_regression (or similar) where parameters like maximum polynomial degree are fixed.
The result of make_regression
is stored in the regression
field. For the result object regression
we assume that a method
predict(regression, C)
is defined. The method predict
is supposed to return a prediction for a matrix of controls C
. See PolynomialRegression
as an example.
DiffFusion.AmcMax
— Typestruct AmcMax <: AmcPayoff
links::AmcPayoffLinks
regr::AmcPayoffRegression
end
An AmcMax payoff is used to model long call rights.
It calculates the expectation of maximum of (sum of) discounted payoffs x
and (sum of) discounted payoffs y
. Expectation is calculated conditional on information at obs_time
. This is approximated by regression variable payoffs z
.
DiffFusion.AmcMax
— MethodAmcMax(
obs_time::ModelTime,
x::AbstractVector,
y::AbstractVector,
z::AbstractVector,
path::Union{AbstractPath, Nothing},
make_regression::Union{Function, Nothing},
curve_key::String,
)
Create an AmcMax payoff.
DiffFusion.AmcMin
— Typestruct AmcMin <: AmcPayoff
links::AmcPayoffLinks
regr::AmcPayoffRegression
end
An AmcMin payoff is used to model short call rights.
It calculates the expectation of minimum of (sum of) discounted payoffs x
and (sum of) discounted payoffs y
. Expectation is calculated conditional on information at obs_time
. This is approximated by regression variable payoffs z
.
DiffFusion.AmcMin
— MethodAmcMin(
obs_time::ModelTime,
x::AbstractVector,
y::AbstractVector,
z::AbstractVector,
path::Union{AbstractPath, Nothing},
make_regression::Union{Function, Nothing},
curve_key::String,
)
Create an AmcMin payoff.
DiffFusion.AmcOne
— Typestruct AmcOne <: AmcPayoff
links::AmcPayoffLinks
regr::AmcPayoffRegression
end
An AmcOne payoff is used to model the indicator variable $1_{(X > Y)}$.
It calculates the expectation of maximum of (sum of) discounted payoffs x
and (sum of) discounted payoffs y
. Expectation is calculated conditional on information at obs_time
. This is approximated by regression variable payoffs z
.
DiffFusion.AmcOne
— MethodAmcOne(
obs_time::ModelTime,
x::AbstractVector,
y::AbstractVector,
z::AbstractVector,
path::Union{AbstractPath, Nothing},
make_regression::Union{Function, Nothing},
curve_key::String,
)
Create an AmcOne payoff.
DiffFusion.AmcSum
— Typestruct AmcSum <: AmcPayoff
links::AmcPayoffLinks
regr::AmcPayoffRegression
end
An AmcSum
payoff is used to model general conditional expectations
$B(t) E[ X(T)/B(T) | Z(t) ]$
AmcSum
payoffs are typically used to calculate future model prices in exposure simulation applications.
DiffFusion.AmcSum
— MethodAmcSum(
obs_time::ModelTime,
x::AbstractVector,
z::AbstractVector,
path::Union{AbstractPath, Nothing},
make_regression::Union{Function, Nothing},
curve_key::String,
)
Create an AmcSum payoff.
DiffFusion.reset_regression!
— Functionreset_regression!(
p::AmcPayoff,
path::Union{AbstractPath, Nothing} = nothing,
make_regression::Union{Function, Nothing} = nothing,
)
Reset the regression properties for an AMC payoffs.
This method is used to allow setting and updating AMC regression after payoff creation.
reset_regression!(
p::UnaryNode,
path::Union{AbstractPath, Nothing} = nothing,
make_regression::Union{Function, Nothing} = nothing,
)
Delegate resetting the regression properties to child payoff.
reset_regression!(
p::BinaryNode,
path::Union{AbstractPath, Nothing} = nothing,
make_regression::Union{Function, Nothing} = nothing,
)
Delegate resetting the regression properties to child payoffs.
reset_regression!(
p::Union{Leaf, CompoundedRate, Optionlet, Swaption},
path::Union{AbstractPath, Nothing} = nothing,
make_regression::Union{Function, Nothing} = nothing,
)
Ignore resetting the regression properties for Leaf and similar payoffs.
Note that some rates payoffs and rates options are no Leafs.
reset_regression!(
p::Payoff,
path::Union{AbstractPath, Nothing} = nothing,
make_regression::Union{Function, Nothing} = nothing,
)
Throw an error if reset_regression! is not implemented for concrete payoff.
reset_regression!(
leg::BermudanSwaptionLeg,
path::Union{AbstractPath, Nothing} = nothing,
make_regression::Union{Function, Nothing} = nothing,
)
Reset the regression properties for the AMC payoffs of the BermudanSwaptionLeg
.
This method is used to allow setting and updating AMC regression after leg creation.
DiffFusion.calibrate_regression
— Functioncalibrate_regression(links::AmcPayoffLinks, regr::AmcPayoffRegression)
Calibrate the regression for an AMC payoff.
DiffFusion.has_amc_payoff
— Functionhas_amc_payoff(p::AmcPayoff)
Determine whether a payoff is or contains an AMC payoff.
AMC payoffs require special treatment e.g. for sensitivity calculation.
has_amc_payoff(p::UnaryNode)
Determine whether a payoff is or contains an AMC payoff.
has_amc_payoff(p::BinaryNode)
Determine whether a payoff is or contains an AMC payoff.
has_amc_payoff(p::Union{Leaf, CompoundedRate, Optionlet, Swaption})
Determine whether a payoff is or contains an AMC payoff.
has_amc_payoff(p::Payoff)
Determine whether a payoff is or contains an AMC payoff.
has_amc_payoff(payoffs::AbstractVector)
Determine whether any payoff is or contains an AMC payoff.