Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
hwcg.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 HwCG {
37public:
38 HwCG(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), sloppySimDates_(sloppySimDates),
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, 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, const 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_;
69 std::set<Date> effSimDates_;
70};
71
72} // namespace ore::data
QuantExt::ComputationGraph & g_
Definition: hwcg.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: hwcg.cpp:34
HwCG(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: hwcg.hpp:38
std::vector< std::pair< std::size_t, std::function< double(void)> > > & modelParameters_
Definition: hwcg.hpp:67
QuantLib::ext::shared_ptr< IrLgm1fParametrization > parametrization() const
Definition: hwcg.hpp:45
std::string qualifier_
Definition: hwcg.hpp:64
std::function< QuantLib::ext::shared_ptr< IrLgm1fParametrization >()> p_
Definition: hwcg.hpp:66
std::set< Date > effSimDates_
Definition: hwcg.hpp:69
std::size_t reducedDiscountBond(const Date &d, const Date &e, const std::size_t x, const Handle< YieldTermStructure > &discountCurve=Handle< YieldTermStructure >(), const std::string &discountCurveId="default") const
Definition: hwcg.cpp:91
std::size_t fixing(const QuantLib::ext::shared_ptr< InterestRateIndex > &index, const Date &fixingDate, const Date &t, const std::size_t x) const
Definition: hwcg.cpp:106
bool sloppySimDates_
Definition: hwcg.hpp:68
std::size_t discountBond(const Date &d, Date e, const std::size_t x, const Handle< YieldTermStructure > &discountCurve=Handle< YieldTermStructure >(), const std::string &discountCurveId="default") const
Definition: hwcg.cpp:55