Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
swaption.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 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 portfolio/builders/swap.hpp
20 \brief Engine builders for Swaptions
21 \ingroup builders
22*/
23
24#pragma once
25
30#include <qle/models/lgm.hpp>
32
33#include <boost/make_shared.hpp>
34
35namespace ore {
36namespace data {
37
38//! Swaption engine builder base class
40 : public CachingPricingEngineBuilder<string, const string&, const string&, const std::vector<Date>&, const Date&,
41 const std::vector<Real>&, const bool, const string&, const string&> {
42public:
43 SwaptionEngineBuilder(const string& model, const string& engine, const set<string>& tradeTypes)
45
46protected:
47 string keyImpl(const string& id, const string& key, const std::vector<Date>& dates, const Date& maturity,
48 const std::vector<Real>& strikes, const bool isAmerican, const std::string& discountCurve,
49 const std::string& securitySpread) override {
50 return id;
51 }
52};
53
54//! European Swaption Engine Builder
55/*! European Swaptions are priced with Black or Bachelier pricing engines,
56 depending on the volatility type provided by Market */
58public:
60 : SwaptionEngineBuilder("BlackBachelier", "BlackBachelierSwaptionEngine", {"EuropeanSwaption"}) {}
61
62private:
63 QuantLib::ext::shared_ptr<PricingEngine> engineImpl(const string& id, const string& key, const std::vector<Date>& dates,
64 const Date& maturity, const std::vector<Real>& strikes,
65 const bool isAmerican, const std::string& discountCurve,
66 const std::string& securitySpread) override;
67};
68
69//! Abstract LGMSwaptionEngineBuilder class
71public:
73 : SwaptionEngineBuilder("LGM", engine, {"EuropeanSwaption", "BermudanSwaption", "AmericanSwaption"}) {}
74
75protected:
76 QuantLib::ext::shared_ptr<QuantExt::LGM> model(const string& id, const string& key, const std::vector<Date>& dates,
77 const Date& maturity, const std::vector<Real>& strikes,
78 const bool isAmerican);
79};
80
81//! Implementation of BermudanAmericanSwaptionEngineBuilder using LGM Grid pricer
83public:
85
86private:
87 QuantLib::ext::shared_ptr<PricingEngine> engineImpl(const string& id, const string& key, const std::vector<Date>& dates,
88 const Date& maturity, const std::vector<Real>& strikes,
89 const bool isAmerican, const std::string& discountCurve,
90 const std::string& securitySpread) override;
91};
92
93//! Implementation of BermudanAmericanSwaptionEngineBuilder using LGM FD pricer
95public:
97
98private:
99 QuantLib::ext::shared_ptr<PricingEngine> engineImpl(const string& id, const string& key, const std::vector<Date>& dates,
100 const Date& maturity, const std::vector<Real>& strikes,
101 const bool isAmerican, const std::string& discountCurve,
102 const std::string& securitySpread) override;
103};
104
105//! Implementation of LGMBermudanAmericanSwaptionEngineBuilder using MC pricer
107public:
109
110private:
111 QuantLib::ext::shared_ptr<PricingEngine> engineImpl(const string& id, const string& key, const std::vector<Date>& dates,
112 const Date& maturity, const std::vector<Real>& strikes,
113 const bool isAmerican, const std::string& discountCurve,
114 const std::string& securitySpread) override;
115};
116
117// Implementation of BermudanAmericanSwaptionEngineBuilder for external cam, with additional simulation dates (AMC)
119public:
120 LGMAmcSwaptionEngineBuilder(const QuantLib::ext::shared_ptr<QuantExt::CrossAssetModel>& cam,
121 const std::vector<Date>& simulationDates)
122 : LGMSwaptionEngineBuilder("AMC"), cam_(cam), simulationDates_(simulationDates) {}
123
124private:
125 string keyImpl(const string& id, const string& ccy, const std::vector<Date>& dates, const Date& maturity,
126 const std::vector<Real>& strikes, const bool isAmerican, const std::string& discountCurve,
127 const std::string& securitySpread) override {
128 return ccy + "_" + std::to_string(isAmerican) + discountCurve + securitySpread;
129 }
130 QuantLib::ext::shared_ptr<PricingEngine> engineImpl(const string& id, const string& key, const std::vector<Date>& dates,
131 const Date& maturity, const std::vector<Real>& strikes,
132 const bool isAmerican, const std::string& discountCurve,
133 const std::string& securitySpread) override;
134
135 const QuantLib::ext::shared_ptr<QuantExt::CrossAssetModel> cam_;
136 const std::vector<Date> simulationDates_;
137};
138
139} // namespace data
140} // namespace ore
Abstract template engine builder class.
Abstract template EngineBuilder class that can cache engines and coupon pricers.
const string & engine() const
Return the engine name.
const set< string > & tradeTypes() const
Return the possible trade types.
const string & model() const
Return the model name.
European Swaption Engine Builder.
Definition: swaption.hpp:57
QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const string &id, const string &key, const std::vector< Date > &dates, const Date &maturity, const std::vector< Real > &strikes, const bool isAmerican, const std::string &discountCurve, const std::string &securitySpread) override
Definition: swaption.cpp:68
const std::vector< Date > simulationDates_
Definition: swaption.hpp:136
string keyImpl(const string &id, const string &ccy, const std::vector< Date > &dates, const Date &maturity, const std::vector< Real > &strikes, const bool isAmerican, const std::string &discountCurve, const std::string &securitySpread) override
Definition: swaption.hpp:125
const QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > cam_
Definition: swaption.hpp:135
QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const string &id, const string &key, const std::vector< Date > &dates, const Date &maturity, const std::vector< Real > &strikes, const bool isAmerican, const std::string &discountCurve, const std::string &securitySpread) override
Definition: swaption.cpp:320
LGMAmcSwaptionEngineBuilder(const QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > &cam, const std::vector< Date > &simulationDates)
Definition: swaption.hpp:120
Implementation of BermudanAmericanSwaptionEngineBuilder using LGM FD pricer.
Definition: swaption.hpp:94
QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const string &id, const string &key, const std::vector< Date > &dates, const Date &maturity, const std::vector< Real > &strikes, const bool isAmerican, const std::string &discountCurve, const std::string &securitySpread) override
Definition: swaption.cpp:267
Implementation of BermudanAmericanSwaptionEngineBuilder using LGM Grid pricer.
Definition: swaption.hpp:82
QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const string &id, const string &key, const std::vector< Date > &dates, const Date &maturity, const std::vector< Real > &strikes, const bool isAmerican, const std::string &discountCurve, const std::string &securitySpread) override
Definition: swaption.cpp:239
Implementation of LGMBermudanAmericanSwaptionEngineBuilder using MC pricer.
Definition: swaption.hpp:106
QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const string &id, const string &key, const std::vector< Date > &dates, const Date &maturity, const std::vector< Real > &strikes, const bool isAmerican, const std::string &discountCurve, const std::string &securitySpread) override
Definition: swaption.cpp:297
Abstract LGMSwaptionEngineBuilder class.
Definition: swaption.hpp:70
LGMSwaptionEngineBuilder(const string &engine)
Definition: swaption.hpp:72
Swaption engine builder base class.
Definition: swaption.hpp:41
SwaptionEngineBuilder(const string &model, const string &engine, const set< string > &tradeTypes)
Definition: swaption.hpp:43
string keyImpl(const string &id, const string &key, const std::vector< Date > &dates, const Date &maturity, const std::vector< Real > &strikes, const bool isAmerican, const std::string &discountCurve, const std::string &securitySpread) override
Definition: swaption.hpp:47
Pricing Engine Factory.
Classes and functions for log message handling.
@ data
Definition: log.hpp:77
Time maturity
Definition: utilities.cpp:66
Serializable Credit Default Swap.
Definition: namespaces.docs:23