Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
trscashflow.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2023 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/cashflows/trscashflow.hpp
20 \brief cashflow paying the total return of an asset
21 \ingroup cashflows
22*/
23
24#pragma once
25
26#include <ql/cashflow.hpp>
27#include <ql/handle.hpp>
28#include <ql/patterns/visitor.hpp>
29#include <ql/termstructures/yieldtermstructure.hpp>
30#include <ql/time/daycounter.hpp>
33
34namespace QuantExt {
35using namespace QuantLib;
36
37//! bond trs cashflow
38class TRSCashFlow : public CashFlow, public Observer {
39public:
40 TRSCashFlow(const Date& paymentDate, const Date& fixingStartDate, const Date& fixingEndDate,
41 const Real notional, const QuantLib::ext::shared_ptr<Index>& Index,
42 const Real initialPrice = Null<Real>(), const QuantLib::ext::shared_ptr<FxIndex>& fxIndex = nullptr);
43
44 //! \name CashFlow interface
45 //@{
46 Real amount() const override;
47 Date date() const override;
48 //@}
49
50 //! \name Inspectors
51 //@{
52 const Date& fixingStartDate() const { return fixingStartDate_; }
53 const Date& fixingEndDate() const { return fixingEndDate_; }
54 virtual const Real notional() const { return notional_; }
55 virtual const Real notional(Date date) const { return notional_; }
56 const QuantLib::ext::shared_ptr<Index>& index() const { return index_; }
57 const Real initialPrice() const { return initialPrice_; }
58 const QuantLib::ext::shared_ptr<FxIndex>& fxIndex() const { return fxIndex_; }
59 Real fxStart() const;
60 Real fxEnd() const;
61 Real assetStart() const;
62 Real assetEnd() const;
63 //@}
64
65 //! \name Observer interface
66 //@{
67 void update() override { notifyObservers(); }
68 //@}
69
70 //! \name Visitability
71 //@{
72 virtual void accept(AcyclicVisitor&) override;
73 //@}
74
75protected:
78 QuantLib::ext::shared_ptr<Index> index_;
79 Real initialPrice_ = QuantLib::Null<Real>();
80 QuantLib::ext::shared_ptr<FxIndex> fxIndex_;
81};
82
83//! helper class building a sequence of trs cashflows
84/*! \ingroup cashflows
85 */
86class TRSLeg {
87public:
88 TRSLeg(const std::vector<Date>& valuationDates, const std::vector<Date>& paymentDates, const Real notional,
89 const QuantLib::ext::shared_ptr<Index>& index, const QuantLib::ext::shared_ptr<FxIndex>& fxIndex = nullptr);
91 operator Leg() const;
92
93private:
94 std::vector<Date> valuationDates_;
95 std::vector<Date> paymentDates_;
97 QuantLib::ext::shared_ptr<Index> index_;
98 QuantLib::ext::shared_ptr<FxIndex> fxIndex_;
100};
101
102} // namespace QuantExt
bond index class representing historical and forward bond prices
bond trs cashflow
Definition: trscashflow.hpp:38
Real assetEnd() const
Definition: trscashflow.cpp:57
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
Definition: trscashflow.hpp:80
const QuantLib::ext::shared_ptr< FxIndex > & fxIndex() const
Definition: trscashflow.hpp:58
void update() override
Definition: trscashflow.hpp:67
QuantLib::ext::shared_ptr< Index > index_
Definition: trscashflow.hpp:78
Real amount() const override
Definition: trscashflow.cpp:32
Real assetStart() const
Definition: trscashflow.cpp:52
virtual void accept(AcyclicVisitor &) override
Definition: trscashflow.cpp:36
const QuantLib::ext::shared_ptr< Index > & index() const
Definition: trscashflow.hpp:56
const Real initialPrice() const
Definition: trscashflow.hpp:57
const Date & fixingEndDate() const
Definition: trscashflow.hpp:53
Real fxStart() const
Definition: trscashflow.cpp:44
Date date() const override
Definition: trscashflow.cpp:34
virtual const Real notional() const
Definition: trscashflow.hpp:54
virtual const Real notional(Date date) const
Definition: trscashflow.hpp:55
const Date & fixingStartDate() const
Definition: trscashflow.hpp:52
helper class building a sequence of trs cashflows
Definition: trscashflow.hpp:86
TRSLeg & withInitialPrice(Real)
Definition: trscashflow.cpp:65
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
Definition: trscashflow.hpp:98
QuantLib::ext::shared_ptr< Index > index_
Definition: trscashflow.hpp:97
std::vector< Date > valuationDates_
Definition: trscashflow.hpp:94
std::vector< Date > paymentDates_
Definition: trscashflow.hpp:95
FX index class.