QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
simplifynotificationgraph.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2023 Peter Caspers
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20/*! \file simplifynotificationgraph.hpp
21 \brief utility functions to reduce number of notifications sent by observables
22*/
23
24#ifndef quantlib_simplify_notification_graph
25#define quantlib_simplify_notification_graph
26
27#include <ql/cashflow.hpp>
28#include <ql/instrument.hpp>
31
32
33namespace QuantLib {
34
35 //! Utility function to optimize the observability graph of an instrument
36 /*! This function unregisters the given instrument from the given cashflows and
37 instead registers with the observables of the cashflows. This is safe to do if
38
39 - the coupon pricers of the cashflows are set before the function is called and never
40 updated afterwards
41 - the cashflows are not themselves originating notifications, i.e. they only pass through
42 notifications from their observables (which is usually the case)
43 - the set of cashflows does not dynamically change (usually satisfied as well)
44
45 If unregisterCoupons is set to true, all given cashflows are in addition unregistered from
46 all their observables. This can be done
47
48 - if the coupons are not asked for results directly
49 - if deepUpdate() is called on the instrument before retrieving a result; to determine
50 whether the result might have changed, isCalculated() can be called on the instrument.
51
52 There are overloads of this function for specific instrument types like Swap, Bond.
53 */
54 void simplifyNotificationGraph(Instrument& instrument,
55 const Leg& leg,
56 bool unregisterCoupons = false);
57
58 //! Utility function to opimize the observability graph of a swap
59 void simplifyNotificationGraph(Swap& swap, bool unregisterCoupons = false);
60
61 //! Utility function to opimize the observability graph of a bond
62 void simplifyNotificationGraph(Bond& bond, bool unregisterCoupons = false);
63
64}
65
66#endif
concrete bond class
Base class for cash flows.
Abstract instrument class.
Definition: any.hpp:35
void swap(Array &v, Array &w) noexcept
Definition: array.hpp:903
void simplifyNotificationGraph(Instrument &instrument, const Leg &leg, bool unregisterCoupons)
Utility function to optimize the observability graph of an instrument.
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78
Interest rate swap.