Scenarios
Scenario Cube
DiffFusion.ScenarioCube
— Typestruct ScenarioCube
X::AbstractArray
times::AbstractVector
leg_aliases::AbstractVector
numeraire_context_key::String
discount_curve_key::Union{String,Nothing}
end
A ScenarioCube represents the result of MC pricing results of a list of product legs and is calculated for a list of observation times.
Elements are
X
- tensor of size (N_1
,N_2
,N_3
) and typeModelValue
whereN_1
is number of Monte Carlo paths,N_2
is number of time steps,N_3
is number of legs.
times
- a vector representing observation times.leg_aliases
- a list of aliases (identifiers) corresponding to each legnumeraire_context_key
- the context_key of theNumeraireEntry
; this label should indicate the cash flow currency.discount_curve_key
- a flag specifying whether prices inX
are discounted prices (for XVA) or undiscounted prices (for CCR).
Pricing Scenarios
DiffFusion.scenarios
— Functionscenarios(
legs::AbstractVector,
times::AbstractVector,
path::Path,
discount_curve_key::Union{String,Nothing};
with_progress_bar::Bool = true,
)
Calculate ScenarioCube
for a vector of CashFlowLeg
objects and a vector of scenario observation times
.
Scenario Cube Operations
DiffFusion.join_scenarios
— Functionjoin_scenarios(cube1::ScenarioCube, cube2::ScenarioCube)
Join two scenario cubes along leg-axis.
join_scenarios(cubes::AbstractVector{ScenarioCube})
Join a list of scenario cubes along leg-axis.
DiffFusion.interpolate_scenarios
— Functioninterpolate_scenarios(
t::ModelTime,
cube::ScenarioCube,
)
Interpolation scenarios along time axis.
We implement linear interpolation with flat extrapolation.
Other interpolations, e.g., piece-wise flat or Brownian Bridge should be incorporated here.
DiffFusion.concatenate_scenarios
— Functionconcatenate_scenarios(cubes::AbstractVector{ScenarioCube})
Concatenate a list of scenarios along time axis.
DiffFusion.aggregate
— Functionaggregate(
scens::ScenarioCube,
average_paths::Bool=true,
aggregate_legs::Bool=true,
)
Average paths and aggregate legs in ScenarioCube.
scens
is the input ScenarioCube
.
If average_paths
is true then reduce scenario cube along path axis. Otherwise, keep individual paths.
If aggregate_legs
is true then reduce scenario cube along the axis of legs. Otherwise, keep individual legs.