Scenarios

Scenario Cube

DiffFusion.ScenarioCubeType
struct 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 type ModelValue where
    • N_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 leg
  • numeraire_context_key - the context_key of the NumeraireEntry; this label should indicate the cash flow currency.
  • discount_curve_key - a flag specifying whether prices in X are discounted prices (for XVA) or undiscounted prices (for CCR).

Pricing Scenarios

DiffFusion.scenariosFunction
scenarios(
    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_scenariosFunction
join_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_scenariosFunction
interpolate_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.aggregateFunction
aggregate(
    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.