Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
blackmultilegoptionengine.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 blackmultilegoptionengine.hpp
20 \brief Simple Black European swaption engine
21*/
22
23#pragma once
24
26
27#include <ql/instruments/nonstandardswaption.hpp>
28#include <ql/instruments/swaption.hpp>
29#include <ql/pricingengines/genericmodelengine.hpp>
30#include <ql/termstructures/volatility/swaption/swaptionvolstructure.hpp>
31
32namespace QuantExt {
33
35public:
36 BlackMultiLegOptionEngineBase(const Handle<YieldTermStructure>& discountCurve,
37 const Handle<SwaptionVolatilityStructure>& volatility);
38
39 static bool instrumentIsHandled(const MultiLegOption& m, std::vector<std::string>& messages);
40
41protected:
42 static bool instrumentIsHandled(const std::vector<Leg>& legs, const std::vector<bool>& payer,
43 const std::vector<Currency>& currency, const QuantLib::ext::shared_ptr<Exercise>& exercise,
44 const Settlement::Type& settlementType, const Settlement::Method& settlementMethod,
45 std::vector<std::string>& messages);
46
47 void calculate() const;
48
49 // inputs set in ctor
50 Handle<YieldTermStructure> discountCurve_;
51 Handle<SwaptionVolatilityStructure> volatility_;
52
53 // inputs set by derived classes
54 mutable std::vector<Leg> legs_;
55 mutable std::vector<bool> payer_;
56 mutable std::vector<Currency> currency_;
57 mutable QuantLib::ext::shared_ptr<Exercise> exercise_;
58 mutable Settlement::Type settlementType_;
59 mutable Settlement::Method settlementMethod_;
60
61 // outputs
62 mutable Real npv_, underlyingNpv_;
63 mutable std::map<std::string, boost::any> additionalResults_;
64};
65
66class BlackMultiLegOptionEngine : public QuantLib::GenericEngine<MultiLegOption::arguments, MultiLegOption::results>,
68public:
69 BlackMultiLegOptionEngine(const Handle<YieldTermStructure>& discountCurve,
70 const Handle<SwaptionVolatilityStructure>& volatility);
71
72 void calculate() const override;
73};
74
75class BlackSwaptionFromMultilegOptionEngine : public QuantLib::GenericEngine<Swaption::arguments, Swaption::results>,
77public:
78 BlackSwaptionFromMultilegOptionEngine(const Handle<YieldTermStructure>& discountCurve,
79 const Handle<SwaptionVolatilityStructure>& volatility);
80
81 void calculate() const override;
82};
83
85 : public QuantLib::GenericEngine<NonstandardSwaption::arguments, NonstandardSwaption::results>,
87public:
88 BlackNonstandardSwaptionFromMultilegOptionEngine(const Handle<YieldTermStructure>& discountCurve,
89 const Handle<SwaptionVolatilityStructure>& volatility);
90
91 void calculate() const override;
92};
93
94} // namespace QuantExt
QuantLib::ext::shared_ptr< Exercise > exercise_
std::map< std::string, boost::any > additionalResults_
Handle< SwaptionVolatilityStructure > volatility_
static bool instrumentIsHandled(const MultiLegOption &m, std::vector< std::string > &messages)
multi leg option instrument