Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
lgmcg.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2023 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 models/lgmcg.hpp
20 \brief computation graph based lgm model calculations
21 \ingroup models
22*/
23
24#pragma once
25
28
29#include <ql/indexes/iborindex.hpp>
30
31namespace ore::data {
32
33using namespace QuantLib;
34using namespace QuantExt;
35
36class LgmCG {
37public:
38 LgmCG(const std::string& qualifier, QuantExt::ComputationGraph& g,
39 const std::function<QuantLib::ext::shared_ptr<IrLgm1fParametrization>()>& p,
40 std::vector<std::pair<std::size_t, std::function<double(void)>>>& modelParameters,
41 const bool sloppySimDates = false, const std::set<Date>& effSimDates = {})
42 : qualifier_(qualifier), g_(g), p_(p), modelParameters_(modelParameters),
43 effSimDates_(effSimDates) {}
44
45 QuantLib::ext::shared_ptr<IrLgm1fParametrization> parametrization() const { return p_(); }
46
47 std::size_t numeraire(const Date& d, const std::size_t x,
48 const Handle<YieldTermStructure>& discountCurve = Handle<YieldTermStructure>(),
49 const std::string& discountCurveId = "default") const;
50
51 std::size_t discountBond(const Date& d, const Date& e, const std::size_t x,
52 const Handle<YieldTermStructure>& discountCurve = Handle<YieldTermStructure>(),
53 const std::string& discountCurveId = "default") const;
54
55 std::size_t reducedDiscountBond(const Date& d, Date e, const std::size_t x,
56 const Handle<YieldTermStructure>& discountCurve = Handle<YieldTermStructure>(),
57 const std::string& discountCurveId = "default") const;
58
59 /* Handles IborIndex and SwapIndex. Requires observation time t <= fixingDate */
60 std::size_t fixing(const QuantLib::ext::shared_ptr<InterestRateIndex>& index, const Date& fixingDate, const Date& t,
61 const std::size_t x) const;
62
63private:
64 std::string qualifier_;
66 std::function<QuantLib::ext::shared_ptr<IrLgm1fParametrization>()> p_;
67 std::vector<std::pair<std::size_t, std::function<double(void)>>>& modelParameters_;
68 std::set<Date> effSimDates_;
69};
70
71} // namespace ore::data
QuantExt::ComputationGraph & g_
Definition: lgmcg.hpp:65
std::size_t numeraire(const Date &d, const std::size_t x, const Handle< YieldTermStructure > &discountCurve=Handle< YieldTermStructure >(), const std::string &discountCurveId="default") const
Definition: lgmcg.cpp:34
std::vector< std::pair< std::size_t, std::function< double(void)> > > & modelParameters_
Definition: lgmcg.hpp:67
QuantLib::ext::shared_ptr< IrLgm1fParametrization > parametrization() const
Definition: lgmcg.hpp:45
std::string qualifier_
Definition: lgmcg.hpp:64
std::function< QuantLib::ext::shared_ptr< IrLgm1fParametrization >()> p_
Definition: lgmcg.hpp:66
LgmCG(const std::string &qualifier, QuantExt::ComputationGraph &g, const std::function< QuantLib::ext::shared_ptr< IrLgm1fParametrization >()> &p, std::vector< std::pair< std::size_t, std::function< double(void)> > > &modelParameters, const bool sloppySimDates=false, const std::set< Date > &effSimDates={})
Definition: lgmcg.hpp:38
std::size_t reducedDiscountBond(const Date &d, Date e, const std::size_t x, const Handle< YieldTermStructure > &discountCurve=Handle< YieldTermStructure >(), const std::string &discountCurveId="default") const
Definition: lgmcg.cpp:73
std::set< Date > effSimDates_
Definition: lgmcg.hpp:68
std::size_t fixing(const QuantLib::ext::shared_ptr< InterestRateIndex > &index, const Date &fixingDate, const Date &t, const std::size_t x) const
Definition: lgmcg.cpp:105
std::size_t discountBond(const Date &d, const Date &e, const std::size_t x, const Handle< YieldTermStructure > &discountCurve=Handle< YieldTermStructure >(), const std::string &discountCurveId="default") const
Definition: lgmcg.cpp:60