Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
bondtrscashflow.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 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/bondtrscashflow.hpp
20 \brief cashflow paying the total return of a bond
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>
34
35namespace QuantExt {
36using namespace QuantLib;
37
38//! bond trs cashflow
40public:
41 BondTRSCashFlow(const Date& paymentDate, const Date& fixingStartDate, const Date& fixingEndDate,
42 const Real bondNotional, const QuantLib::ext::shared_ptr<BondIndex>& bondIndex,
43 const Real initialPrice = Null<Real>(), const QuantLib::ext::shared_ptr<FxIndex>& fxIndex = nullptr);
44
45 const Real notional(Date date) const override;
46 const Real notional() const override { return TRSCashFlow::notional(); };
47
48 void setFixingStartDate(QuantLib::Date fixingDate);
49};
50
51//! helper class building a sequence of bond trs cashflows
52/*! \ingroup cashflows
53 */
55public:
56 BondTRSLeg(const std::vector<Date>& valuationDates, const std::vector<Date>& paymentDates, const Real bondNotional,
57 const QuantLib::ext::shared_ptr<BondIndex>& bondIndex, const QuantLib::ext::shared_ptr<FxIndex>& fxIndex = nullptr);
59 operator Leg() const;
60
61private:
62 std::vector<Date> valuationDates_;
63 std::vector<Date> paymentDates_;
65 QuantLib::ext::shared_ptr<BondIndex> bondIndex_;
66 QuantLib::ext::shared_ptr<FxIndex> fxIndex_;
67 Real initialPrice_ = QuantLib::Null<QuantLib::Real>();
68};
69
70} // namespace QuantExt
bond index class representing historical and forward bond prices
void setFixingStartDate(QuantLib::Date fixingDate)
const Real notional() const override
helper class building a sequence of bond trs cashflows
BondTRSLeg & withInitialPrice(Real)
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
std::vector< Date > valuationDates_
std::vector< Date > paymentDates_
QuantLib::ext::shared_ptr< BondIndex > bondIndex_
bond trs cashflow
Definition: trscashflow.hpp:38
const QuantLib::ext::shared_ptr< FxIndex > & fxIndex() const
Definition: trscashflow.hpp:58
const Real initialPrice() const
Definition: trscashflow.hpp:57
const Date & fixingEndDate() const
Definition: trscashflow.hpp:53
Date date() const override
Definition: trscashflow.cpp:34
virtual const Real notional() const
Definition: trscashflow.hpp:54
const Date & fixingStartDate() const
Definition: trscashflow.hpp:52
FX index class.
cashflow paying the total return of an asset