Examples (Module) Functions
In this section we document data and functions to work with the product and model examples.
DiffFusion.Examples._yaml_path
— Constantconst _yaml_path = @__DIR__
The path of example CSV files.
DiffFusion.Examples._csv_path
— Constantconst _csv_path = @__DIR__
The path of example CSV files.
DiffFusion.Examples.examples
— ConstantA list of example models and instrument specifications.
DiffFusion.Examples.load
— Functionload(name::String)
Return a list of dictionaries representing a DiffFusion example.
Example details can be modified by changing the dictionary entries.
DiffFusion.Examples.build
— Functionbuild(dict_list::Vector{OrderedDict{String, Any}})
Return a dictionary of objects and configurations representing a DiffFusion example.
The resulting dictionary is supposed to be queried and amended by methods operating on examples.
DiffFusion.Examples.get_object
— FunctionReturn the first object of a given type from an example dictionary.
Model Setup
DiffFusion.Examples.model
— Functionmodel(example::OrderedDict{String,Any})
Return the hybrid model of an example.
DiffFusion.Examples.correlation_holder
— Functioncorrelation_holder(example::OrderedDict{String,Any})
Return the correlation holder of an example.
DiffFusion.Examples.context
— Functioncontext(example::OrderedDict{String,Any})
Return the context of a given example.
DiffFusion.Examples.term_structures
— Functionterm_structures(example::OrderedDict{String,Any})
Return a dictionary of term structures for an example.
DiffFusion.Examples.simulation!
— Functionsimulation!(example::OrderedDict{String,Any})
Return a Monte Carlo simulation for a given example.
If no simulation exists it is created.
DiffFusion.Examples.path!
— Functionpath!(example::OrderedDict{String,Any})
Return a Monte Carlo path for a given example.
Product Setup
DiffFusion.Examples.fixed_rate_leg
— Functionfixed_rate_leg(
alias::String,
effective_time::ModelTime,
maturity_time::ModelTime,
coupons_per_year::Int,
fixed_rate::ModelValue,
notional::ModelValue,
discount_curve_key::String,
fx_key::Union{String, Nothing} = nothing,
payer_receiver = 1.0,
)
Create a fixed rate cash flow leg.
DiffFusion.Examples.simple_rate_leg
— Functionsimple_rate_leg(
alias::String,
effective_time::ModelTime,
maturity_time::ModelTime,
coupons_per_year::Int,
forward_curve_key::String,
fixing_key::Union{String, Nothing},
spread_rate::Union{ModelValue, Nothing},
notional::ModelValue,
discount_curve_key::String,
fx_key::Union{String, Nothing} = nothing,
payer_receiver = 1.0,
)
Create a Libor cash flow leg.
DiffFusion.Examples.compounded_rate_leg
— Functioncompounded_rate_leg(
alias::String,
effective_time::ModelTime,
maturity_time::ModelTime,
coupons_per_year::Int,
forward_curve_key::String,
fixing_key::Union{String, Nothing},
spread_rate::Union{ModelValue, Nothing},
notional::ModelValue,
discount_curve_key::String,
fx_key::Union{String, Nothing} = nothing,
payer_receiver = 1.0,
)
Create a RFR compounded leg.
DiffFusion.Examples.random_swap
— Functionrandom_swap(example::OrderedDict{String,Any}, type_key::Union{String,Nothing} = nothing)
Sample a random swap.
DiffFusion.Examples.random_swaption
— Functionrandom_swaption(
example::OrderedDict{String,Any},
type_key::Union{String,Nothing} = nothing,
)
Sample a random European swaption.
DiffFusion.Examples.random_bermudan
— Functionrandom_bermudan(
example::OrderedDict{String,Any},
type_key::Union{String,Nothing} = nothing,
)
Sample a random Bermudan swaption.
DiffFusion.Examples.portfolio!
— Functionportfolio!(
example::OrderedDict{String,Any},
n_swaps::Int = 10,
n_swaptions::Int = 0,
)
Create a portfolio of swaps and swaptions and store it in the dictionary.
DiffFusion.Examples.display_portfolio
— FunctionPrint portfolio in terminal.
DiffFusion.Examples.scenarios!
— Functionscenarios!(example::OrderedDict{String,Any})
Create the exposure scenarios for the portfolio.