Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
riskparticipationagreement_tlock.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 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 riskparticipationagreement_tlock.hpp
20 \brief RPA instrument for tlock underlyings
21*/
22
23#pragma once
24
25#include <ql/cashflow.hpp>
26#include <ql/instrument.hpp>
27#include <ql/instruments/bond.hpp>
28#include <ql/instruments/swaption.hpp>
29#include <ql/position.hpp>
30#include <ql/pricingengine.hpp>
31
32namespace QuantExt {
33
34using namespace QuantLib;
35
36class RiskParticipationAgreementTLock : public QuantLib::Instrument {
37public:
38 class arguments;
39 class results;
40 class engine;
41 /*! The bond must be a fixed rate bond, i.e. it may only contain FixedCoupons.
42 The udnerlying payout is (referenceRate - bond yield) * DV01 if payer = false, otherwise multiplied by -1.
43 As in the swap RPA, protectionFeepayer = true means protection is received, protection fee is paid. */
44 RiskParticipationAgreementTLock(const QuantLib::ext::shared_ptr<QuantLib::Bond>& bond, Real bondNotional, bool payer,
45 Real referenceRate, const DayCounter& dayCounter, const Date& terminationDate,
46 const Date& paymentDate, const std::vector<Leg>& protectionFee,
47 const bool protectionFeePayer, const std::vector<std::string>& protectionFeeCcys,
48 const Real participationRate, const Date& protectionStart,
49 const Date& protectionEnd, const bool settlesAccrual,
50 const Real fixedRecoveryRate = Null<Real>());
51
52 //! Instrument interface
53 bool isExpired() const override;
54
55 //! Inspectors
56 const QuantLib::ext::shared_ptr<QuantLib::Bond>& bond() const { return bond_; }
57 bool payer() { return payer_; }
58 Real referenceRate() const { return referenceRate_; }
59 const DayCounter& dayCounter() const { return dayCounter_; }
60 const Date& terminationDate() const { return terminationDate_; }
61 const Date& paymentDate() const { return paymentDate_; }
62
63 const std::vector<Leg>& protectionFee() const { return protectionFee_; }
64 bool protectionFeePayer() const { return protectionFeePayer_; }
65 const std::vector<std::string>& protectionFeeCcys() const { return protectionFeeCcys_; }
66 Real participationRate() const { return participationRate_; }
67 const Date& protectionStart() const { return protectionStart_; }
68 const Date& protectionEnd() const { return protectionEnd_; }
69 bool settlesAccrual() const { return settlesAccrual_; }
70 Real fixedRecoveryRate() const { return fixedRecoveryRate_; }
71
72 // maturity = max protection end, last prot fee pay date
73 const Date& maturity() const { return maturity_; }
74
75private:
77 void setupExpired() const override;
78 void fetchResults(const QuantLib::PricingEngine::results*) const override;
79
80 // underlying
81 QuantLib::ext::shared_ptr<QuantLib::Bond> bond_;
83 bool payer_;
85 DayCounter dayCounter_;
88
89 // protection data
90 std::vector<Leg> protectionFee_;
92 std::vector<std::string> protectionFeeCcys_;
97
99};
100
102public:
104 : payer(false), referenceRate(0.0), protectionFeePayer(false), participationRate(0.0), settlesAccrual(false),
105 fixedRecoveryRate(0.0) {}
106 void validate() const override {}
107
108 // underlying
109 QuantLib::ext::shared_ptr<QuantLib::Bond> bond;
111 bool payer;
113 DayCounter dayCounter;
116
117 // protection data
118 std::vector<Leg> protectionFee;
120 std::vector<std::string> protectionFeeCcys;
125
126 // maturity
128};
129
131public:
132 void reset() override { Instrument::results::reset(); }
133};
134
136 : public GenericEngine<RiskParticipationAgreementTLock::arguments, RiskParticipationAgreementTLock::results> {};
137
138} // namespace QuantExt
void fetchResults(const QuantLib::PricingEngine::results *) const override
bool isExpired() const override
Instrument interface.
const QuantLib::ext::shared_ptr< QuantLib::Bond > & bond() const
Inspectors.
const std::vector< std::string > & protectionFeeCcys() const
void setupArguments(QuantLib::PricingEngine::arguments *) const override
QuantLib::ext::shared_ptr< QuantLib::Bond > bond_