Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
fdgaussiancam.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2024 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file ored/scripting/models/fdgaussiancam.hpp
20 \brief fd gaussian cross asset model for single underlying ir model
21 \ingroup utilities
22*/
23
24#pragma once
25
28
30
32#include <qle/models/lgmbackwardsolver.hpp>
33
34#include <ql/termstructures/volatility/swaption/swaptionvolstructure.hpp>
35
36namespace ore {
37namespace data {
38
39class FdGaussianCam : public ModelImpl {
40public:
41 /* see GaussianCam, this is the FD variant for a single underlying IR model */
42 FdGaussianCam(const Handle<CrossAssetModel>& cam, const std::string& currency,
43 const Handle<YieldTermStructure>& curve,
44 const std::vector<std::pair<std::string, QuantLib::ext::shared_ptr<InterestRateIndex>>>& irIndices,
45 const std::set<Date>& simulationDates, const Size stateGridPoints = 50,
46 const Size timeStepsPerYear = 24, const Real mesherEpsilon = 1E-4,
47 const IborFallbackConfig& iborFallbackConfig = IborFallbackConfig::defaultConfig());
48
49 // Model interface implementation
50 Type type() const override { return Type::FD; }
51 const Date& referenceDate() const override;
52 RandomVariable npv(const RandomVariable& amount, const Date& obsdate, const Filter& filter,
53 const boost::optional<long>& memSlot, const RandomVariable& addRegressor1,
54 const RandomVariable& addRegressor2) const override;
55 RandomVariable fwdCompAvg(const bool isAvg, const std::string& index, const Date& obsdate, const Date& start,
56 const Date& end, const Real spread, const Real gearing, const Integer lookback,
57 const Natural rateCutoff, const Natural fixingDays, const bool includeSpread,
58 const Real cap, const Real floor, const bool nakedOption,
59 const bool localCapFloor) const override;
60 Real extractT0Result(const RandomVariable& result) const override;
61 // override to set time on result
62 RandomVariable pay(const RandomVariable& amount, const Date& obsdate, const Date& paydate,
63 const std::string& currency) const override;
64 // override to clear cache
65 void releaseMemory() override;
66
67private:
68 // ModelImpl interface implementation
69 void performCalculations() const override;
70 RandomVariable getFutureBarrierProb(const std::string& index, const Date& obsdate1, const Date& obsdate2,
71 const RandomVariable& barrier, const bool above) const override;
72 RandomVariable getIndexValue(const Size indexNo, const Date& d, const Date& fwd = Null<Date>()) const override;
73 RandomVariable getIrIndexValue(const Size indexNo, const Date& d, const Date& fwd = Null<Date>()) const override;
74 RandomVariable getInfIndexValue(const Size indexNo, const Date& d, const Date& fwd = Null<Date>()) const override;
75 RandomVariable getDiscount(const Size idx, const Date& s, const Date& t) const override;
76 RandomVariable getNumeraire(const Date& s) const override;
77 Real getFxSpot(const Size idx) const override;
78
79 // input parameters
80 Handle<CrossAssetModel> cam_;
81 std::string currency_;
82 Handle<YieldTermStructure> curve_;
83 std::set<Date> simulationDates_;
88
89 // computed values
90 mutable Date referenceDate_; // the model reference date
91 mutable std::set<Date> effectiveSimulationDates_; // the dates effectively simulated (including today)
92 mutable std::unique_ptr<LgmBackwardSolver> solver_; // the lgm solver
93
94 // internal cache for ir index fixings
95 mutable std::map<std::tuple<Size, Date, Date>, RandomVariable> irIndexValueCache_;
96};
97
98} // namespace data
99} // namespace ore
additional interface for amc enabled models
std::set< Date > simulationDates_
RandomVariable getInfIndexValue(const Size indexNo, const Date &d, const Date &fwd=Null< Date >()) const override
void performCalculations() const override
void releaseMemory() override
RandomVariable getFutureBarrierProb(const std::string &index, const Date &obsdate1, const Date &obsdate2, const RandomVariable &barrier, const bool above) const override
RandomVariable getIrIndexValue(const Size indexNo, const Date &d, const Date &fwd=Null< Date >()) const override
RandomVariable npv(const RandomVariable &amount, const Date &obsdate, const Filter &filter, const boost::optional< long > &memSlot, const RandomVariable &addRegressor1, const RandomVariable &addRegressor2) const override
std::unique_ptr< LgmBackwardSolver > solver_
Real getFxSpot(const Size idx) const override
std::map< std::tuple< Size, Date, Date >, RandomVariable > irIndexValueCache_
const Date & referenceDate() const override
RandomVariable getNumeraire(const Date &s) const override
Handle< CrossAssetModel > cam_
Handle< YieldTermStructure > curve_
Real extractT0Result(const RandomVariable &result) const override
Type type() const override
std::set< Date > effectiveSimulationDates_
RandomVariable pay(const RandomVariable &amount, const Date &obsdate, const Date &paydate, const std::string &currency) const override
RandomVariable getDiscount(const Size idx, const Date &s, const Date &t) const override
RandomVariable getIndexValue(const Size indexNo, const Date &d, const Date &fwd=Null< Date >()) const override
IborFallbackConfig iborFallbackConfig_
RandomVariable fwdCompAvg(const bool isAvg, const std::string &index, const Date &obsdate, const Date &start, const Date &end, const Real spread, const Real gearing, const Integer lookback, const Natural rateCutoff, const Natural fixingDays, const bool includeSpread, const Real cap, const Real floor, const bool nakedOption, const bool localCapFloor) const override
static IborFallbackConfig defaultConfig()
SafeStack< Filter > filter
Build a cross asset model.
@ data
Definition: log.hpp:77
basis implementation for a script engine model
Serializable Credit Default Swap.
Definition: namespaces.docs:23