Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
multiccycompositeinstrument.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 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 qle/instruments/multiccycompositeinstrument.hpp
20\brief bond option class
21\ingroup instruments
22*/
23
24#pragma once
25
26#include <list>
27#include <ql/instrument.hpp>
28#include <ql/quotes/simplequote.hpp>
29#include <tuple>
30#include <utility>
31
32namespace QuantExt {
33using namespace QuantLib;
34
35//! %Composite instrument
36/*! This instrument is an aggregate of other instruments. Its NPV
37 is the sum of the NPVs of its components, each possibly
38 multiplied by a given factor, and an FX rate.
39
40 \warning Methods that drive the calculation directly (such as
41 recalculate(), freeze() and others) might not work
42 correctly.
43
44 \ingroup instruments
45*/
46class MultiCcyCompositeInstrument : public Instrument {
47 typedef std::tuple<ext::shared_ptr<Instrument>, Real, Handle<Quote>> component;
48 typedef std::list<component>::iterator iterator;
49 typedef std::list<component>::const_iterator const_iterator;
50
51public:
52 //! adds an instrument to the composite
53 void add(const ext::shared_ptr<Instrument>& instrument, Real multiplier = 1.0,
54 const Handle<Quote>& fx = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(1.0)));
55 //! shorts an instrument from the composite
56 void subtract(const ext::shared_ptr<Instrument>& instrument, Real multiplier = 1.0,
57 const Handle<Quote>& fx = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(1.0)));
58 //! \name Observer interface
59 //@{
60 void deepUpdate() override;
61 //@}
62 //! \name Instrument interface
63 //@{
64 bool isExpired() const override;
65
66protected:
67 void performCalculations() const override;
68 //@}
69private:
70 std::list<component> components_;
71};
72
73} // namespace QuantExt
std::list< component >::const_iterator const_iterator
void add(const ext::shared_ptr< Instrument > &instrument, Real multiplier=1.0, const Handle< Quote > &fx=Handle< Quote >(QuantLib::ext::make_shared< SimpleQuote >(1.0)))
adds an instrument to the composite
std::tuple< ext::shared_ptr< Instrument >, Real, Handle< Quote > > component
void subtract(const ext::shared_ptr< Instrument > &instrument, Real multiplier=1.0, const Handle< Quote > &fx=Handle< Quote >(QuantLib::ext::make_shared< SimpleQuote >(1.0)))
shorts an instrument from the composite