Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
gaussiancamcg.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2023 Quaternion Risk Management Ltd
3 All rights reserved.
4*/
5
6/*! \file models/gaussiancamcg.hpp
7 \brief Gaussian CAM model
8 \ingroup utilities
9*/
10
11#pragma once
12
15
17
18#include <ql/termstructures/volatility/swaption/swaptionvolstructure.hpp>
19
20namespace ore {
21namespace data {
22
23class GaussianCamCG : public ModelCGImpl {
24public:
25 /* For the constructor arguments see ModelCGImpl, plus the notes in GaussianCam */
26 GaussianCamCG(const Handle<CrossAssetModel>& cam, const Size paths, const std::vector<std::string>& currencies,
27 const std::vector<Handle<YieldTermStructure>>& curves, const std::vector<Handle<Quote>>& fxSpots,
28 const std::vector<std::pair<std::string, QuantLib::ext::shared_ptr<InterestRateIndex>>>& irIndices,
29 const std::vector<std::pair<std::string, QuantLib::ext::shared_ptr<ZeroInflationIndex>>>& infIndices,
30 const std::vector<std::string>& indices, const std::vector<std::string>& indexCurrencies,
31 const std::set<Date>& simulationDates, const Size timeStepsPerYear = 1,
32 const IborFallbackConfig& iborFallbackConfig = IborFallbackConfig::defaultConfig(),
33 const std::vector<Size>& projectedStateProcessIndices = {},
34 const std::vector<std::string>& conditionalExpectationModelStates = {},
35 const bool sloppySimDates = false);
36
37 // Model interface implementation
38 Type type() const override { return Type::MC; }
39 const Date& referenceDate() const override;
40 std::size_t npv(const std::size_t amount, const Date& obsdate, const std::size_t filter,
41 const boost::optional<long>& memSlot, const std::size_t addRegressor1,
42 const std::size_t addRegressor2) const override;
43 std::size_t fwdCompAvg(const bool isAvg, const std::string& indexInput, const Date& obsdate, const Date& start,
44 const Date& end, const Real spread, const Real gearing, const Integer lookback,
45 const Natural rateCutoff, const Natural fixingDays, const bool includeSpread, const Real cap,
46 const Real floor, const bool nakedOption, const bool localCapFloor) const override;
47 QuantLib::Size size() const override;
48
49 // t0 market data functions from the ModelCG interface
50 Real getDirectFxSpotT0(const std::string& forCcy, const std::string& domCcy) const override;
51 Real getDirectDiscountT0(const Date& paydate, const std::string& currency) const override;
52
53protected:
54 // ModelCGImpl interface implementation
55 virtual std::size_t getFutureBarrierProb(const std::string& index, const Date& obsdate1, const Date& obsdate2,
56 const std::size_t barrier, const bool above) const override {
57 QL_FAIL("getFutureBarrierProb not implemented by GaussianCamCG");
58 }
59 // ModelCGImpl interface implementation
60 void performCalculations() const override;
61 std::size_t getIndexValue(const Size indexNo, const Date& d, const Date& fwd = Null<Date>()) const override;
62 std::size_t getIrIndexValue(const Size indexNo, const Date& d, const Date& fwd = Null<Date>()) const override;
63 std::size_t getInfIndexValue(const Size indexNo, const Date& d, const Date& fwd = Null<Date>()) const override;
64 std::size_t getDiscount(const Size idx, const Date& s, const Date& t) const override;
65 std::size_t getNumeraire(const Date& s) const override;
66 std::size_t getFxSpot(const Size idx) const override;
67
68 // input parameters
69 const Handle<CrossAssetModel> cam_;
70 const std::vector<Handle<YieldTermStructure>> curves_;
71 const std::vector<Handle<Quote>> fxSpots_;
73 const std::vector<Size> projectedStateProcessIndices_;
74 const bool sloppySimDates_;
75
76 // updated in performCalculations()
77 mutable Date referenceDate_; // the model reference date
78 mutable std::set<Date> effectiveSimulationDates_; // the dates effectively simulated (including today)
79 mutable TimeGrid timeGrid_; // the (possibly refined) time grid for the simulation
80 mutable std::vector<Size> positionInTimeGrid_; // for each effective simulation date the index in the time grid
81 mutable std::map<Date, std::vector<std::size_t>> underlyingPaths_; // per simulation date index states
82 mutable std::map<Date, std::vector<std::size_t>> irStates_; // per simulation date ir states for currencies_
83 mutable std::map<Date, std::vector<std::pair<std::size_t, std::size_t>>>
84 infStates_; // per simulation date dk (x,y) or jy (x,y)
85 mutable std::vector<Size> indexPositionInProcess_; // maps index no to position in state process
86 mutable std::vector<Size> infIndexPositionInProcess_; // maps inf index no to position in state process
87 mutable std::vector<Size> currencyPositionInProcess_; // maps currency no to position in state process
88 mutable std::vector<Size> irIndexPositionInCam_; // maps ir index no to currency idx in cam
89 mutable std::vector<Size> infIndexPositionInCam_; // maps inf index no to inf idx in cam
90 mutable std::vector<Size> currencyPositionInCam_; // maps currency no to position in cam parametrizations
91 mutable std::vector<Size> eqIndexInCam_; // maps index no to eq position in cam (or null, if not an eq index)
92 mutable bool conditionalExpectationUseIr_; // derived from input conditionalExpectationModelState
93 mutable bool conditionalExpectationUseInf_; // derived from input conditionalExpectationModelState
94 mutable bool conditionalExpectationUseAsset_; // derived from input conditionalExpectationModelState
95
96 mutable std::size_t underlyingPathsCgVersion_ = 0;
97
98 // data when paths are injected via the AMCModelCG interface
99 const std::vector<QuantLib::Real>* injectedPathTimes_ = nullptr;
100 const std::vector<std::vector<std::size_t>>* injectedPaths_ = nullptr;
101 const std::vector<bool>* injectedPathIsRelevantTime_;
103 Size overwriteModelSize_ = Null<Size>();
104};
105
106} // namespace data
107} // namespace ore
void performCalculations() const override
std::map< Date, std::vector< std::size_t > > underlyingPaths_
std::size_t npv(const std::size_t amount, const Date &obsdate, const std::size_t filter, const boost::optional< long > &memSlot, const std::size_t addRegressor1, const std::size_t addRegressor2) const override
QuantLib::Size size() const override
std::size_t underlyingPathsCgVersion_
std::vector< Size > infIndexPositionInCam_
std::vector< Size > infIndexPositionInProcess_
std::size_t getNumeraire(const Date &s) const override
std::vector< Size > indexPositionInProcess_
std::vector< Size > eqIndexInCam_
std::size_t getFxSpot(const Size idx) const override
Real getDirectFxSpotT0(const std::string &forCcy, const std::string &domCcy) const override
std::size_t getInfIndexValue(const Size indexNo, const Date &d, const Date &fwd=Null< Date >()) const override
const std::vector< QuantLib::Real > * injectedPathTimes_
const Date & referenceDate() const override
Real getDirectDiscountT0(const Date &paydate, const std::string &currency) const override
std::vector< Size > currencyPositionInProcess_
std::vector< Size > irIndexPositionInCam_
std::map< Date, std::vector< std::pair< std::size_t, std::size_t > > > infStates_
virtual std::size_t getFutureBarrierProb(const std::string &index, const Date &obsdate1, const Date &obsdate2, const std::size_t barrier, const bool above) const override
std::vector< Size > currencyPositionInCam_
const Handle< CrossAssetModel > cam_
Type type() const override
std::set< Date > effectiveSimulationDates_
std::size_t getIrIndexValue(const Size indexNo, const Date &d, const Date &fwd=Null< Date >()) const override
std::map< Date, std::vector< std::size_t > > irStates_
const std::vector< Handle< Quote > > fxSpots_
std::size_t fwdCompAvg(const bool isAvg, const std::string &indexInput, 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
const std::vector< std::vector< std::size_t > > * injectedPaths_
std::size_t getDiscount(const Size idx, const Date &s, const Date &t) const override
const std::vector< Size > projectedStateProcessIndices_
std::size_t getIndexValue(const Size indexNo, const Date &d, const Date &fwd=Null< Date >()) const override
const std::vector< bool > * injectedPathIsRelevantTime_
const std::vector< Handle< YieldTermStructure > > curves_
std::vector< Size > positionInTimeGrid_
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