Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
multilegoption.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2017 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 multilegoption.hpp
20 \brief multi leg option instrument
21*/
22
23#pragma once
24
25#include <ql/cashflow.hpp>
26#include <ql/currency.hpp>
27#include <ql/exercise.hpp>
28#include <ql/instrument.hpp>
29#include <ql/instruments/swaption.hpp>
30#include <ql/pricingengine.hpp>
31#include <ql/settings.hpp>
32
33namespace QuantExt {
34using namespace QuantLib;
35
36class MultiLegOption : public Instrument {
37public:
38 class arguments;
39 class results;
40 class engine;
41
42 //! exercise = nullptr means that the instrument is identical to the underlying itself (i.e. a swap)
43 MultiLegOption(const std::vector<Leg>& legs, const std::vector<bool>& payer, const std::vector<Currency>& currency,
44 const QuantLib::ext::shared_ptr<Exercise>& exercise = QuantLib::ext::shared_ptr<Exercise>(),
45 const Settlement::Type settlementType = Settlement::Physical,
46 Settlement::Method settlementMethod = Settlement::PhysicalOTC);
47
48 const std::vector<Leg>& legs() const { return legs_; }
49 const std::vector<bool>& payer() const { return payer_; }
50 const std::vector<Currency>& currency() const { return currency_; }
51 const QuantLib::ext::shared_ptr<Exercise> exercise() const { return exercise_; }
52 const Settlement::Type settlementType() const { return settlementType_; }
53 const Settlement::Method settlementMethod() const { return settlementMethod_; }
54
55 void deepUpdate() override;
56 bool isExpired() const override;
57 void setupArguments(PricingEngine::arguments*) const override;
58 void fetchResults(const PricingEngine::results*) const override;
59
60 const Date& maturityDate() const { return maturity_; }
61 Real underlyingNpv() const;
62
63private:
64 const std::vector<Leg> legs_;
65 const std::vector<bool> payer_;
66 const std::vector<Currency> currency_;
67 const QuantLib::ext::shared_ptr<Exercise> exercise_;
68 const Settlement::Type settlementType_;
69 const Settlement::Method settlementMethod_;
71 // results
72 mutable Real underlyingNpv_;
73};
74
76public:
77 std::vector<Leg> legs;
78 std::vector<bool> payer;
79 std::vector<Currency> currency;
80 QuantLib::ext::shared_ptr<Exercise> exercise;
81 Settlement::Type settlementType;
82 Settlement::Method settlementMethod;
83 void validate() const override {}
84};
85
87public:
89 void reset() override;
90};
91
92class MultiLegOption::engine : public GenericEngine<MultiLegOption::arguments, MultiLegOption::results> {};
93
94} // namespace QuantExt
QuantLib::ext::shared_ptr< Exercise > exercise
std::vector< Currency > currency
const Settlement::Method settlementMethod_
const std::vector< Leg > & legs() const
void setupArguments(PricingEngine::arguments *) const override
bool isExpired() const override
const QuantLib::ext::shared_ptr< Exercise > exercise_
void deepUpdate() override
const Settlement::Type settlementType() const
const Date & maturityDate() const
const Settlement::Method settlementMethod() const
const Settlement::Type settlementType_
const std::vector< bool > payer_
const std::vector< Leg > legs_
void fetchResults(const PricingEngine::results *) const override
const QuantLib::ext::shared_ptr< Exercise > exercise() const
const std::vector< Currency > & currency() const
const std::vector< Currency > currency_
const std::vector< bool > & payer() const