Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
cbo.cpp
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 cbo.cpp
20 \brief collateralized bond obligation instrument
21*/
22
24
25namespace QuantExt {
26
27CBO::CBO(const QuantLib::ext::shared_ptr<BondBasket>& basket, const Schedule& schedule,
28 Rate seniorFee, const DayCounter& feeDayCounter, const std::vector<Tranche>& tranches,
29 Rate subordinatedFee, Rate equityKicker, const Currency& ccy,
30 const std::string& investedTrancheName)
31 : basket_(basket), schedule_(schedule), seniorFee_(seniorFee), feeDayCounter_(feeDayCounter),
32 tranches_(tranches), subordinatedFee_(subordinatedFee), equityKicker_(equityKicker), ccy_(ccy),
33 investedTrancheName_(investedTrancheName) {
34 QL_REQUIRE(basket->bonds().size() > 0, "basket is empty");
35 QL_REQUIRE(tranches.size() > 0, "no tranches specified");
36}
37
38//------------------------------
39// Notes
40//------------------------------
41
42//------------------------------
43// Functions
44//------------------------------
45
46Real CBO::basketValue() const {
47 calculate();
48 return basketValue_;
49}
50
51std::vector<Real> CBO::trancheValue() const {
52 calculate();
53 return trancheValue_;
54}
55
56Real CBO::feeValue() const {
57 calculate();
58 return feeValue_;
59}
60
61Real CBO::basketValueStd() const {
62 calculate();
63 return basketValueStd_;
64}
65
66std::vector<Real> CBO::trancheValueStd() const {
67 calculate();
68 return trancheValueStd_;
69}
70
71Real CBO::feeValueStd() const {
72 calculate();
73 return feeValueStd_;
74}
75
76const std::vector<CashflowTable>& CBO::trancheCashflows() const {
77 calculate();
78 return trancheCashflows_;
79}
80
81bool CBO::isExpired() const {
82 if (schedule_.dates().back() <= Settings::instance().evaluationDate())
83 return true;
84 else
85 return false;
86}
87
88void CBO::setupArguments(PricingEngine::arguments* args) const {
89 CBO::arguments* arguments = dynamic_cast<CBO::arguments*>(args);
90 QL_REQUIRE(arguments != 0, "wrong argument type");
100
101}
102
103void CBO::fetchResults(const PricingEngine::results* r) const {
104 Instrument::fetchResults(r);
105
106 const CBO::results* results = dynamic_cast<const CBO::results*>(r);
107 QL_REQUIRE(results != 0, "wrong result type");
108
116}
117
118void CBO::setupExpired() const {
119 Instrument::setupExpired();
120 basketValue_ = 0.0;
121 trancheValue_.clear();
122 feeValue_ = 0.0;
123
124 basketValueStd_ = 0.0;
125 trancheValueStd_.clear();
126 feeValueStd_ = 0.0;
127 trancheCashflows_.clear();
128}
129
131 QL_REQUIRE(basket && !basket->bonds().empty(), "no basket given");
132 QL_REQUIRE(seniorFee != Null<Real>(), "no senior fee given");
133 QL_REQUIRE(!feeDayCounter.empty(), "no fee day counter given");
134}
135
137 Instrument::results::reset();
138 basketValue = Null<Real>();
139 trancheValue.clear();
140 basketValueStd = Null<Real>();
141 trancheValueStd.clear();
142 trancheCashflows.clear();
143 feeValue = Null<Real>();
144 subfeeValue = Null<Real>();
145}
146
147} // namespace QuantExt
collateralized bond obligation instrument
QuantLib::ext::shared_ptr< BondBasket > basket
Definition: cbo.hpp:130
std::vector< Tranche > tranches
Definition: cbo.hpp:135
DayCounter feeDayCounter
Definition: cbo.hpp:134
std::string investedTrancheName
Definition: cbo.hpp:138
void validate() const override
Definition: cbo.cpp:130
std::vector< CashflowTable > trancheCashflows
Definition: cbo.hpp:153
std::vector< Real > trancheValueStd
Definition: cbo.hpp:150
std::vector< Real > trancheValue
Definition: cbo.hpp:146
void reset() override
Definition: cbo.cpp:136
Real basketValueStd() const
Definition: cbo.cpp:61
Rate seniorFee_
Definition: cbo.hpp:107
std::string investedTrancheName_
Definition: cbo.hpp:113
Schedule schedule_
Definition: cbo.hpp:106
QuantLib::ext::shared_ptr< BondBasket > basket_
Definition: cbo.hpp:105
std::vector< Real > trancheValue_
Definition: cbo.hpp:116
QuantLib::ext::shared_ptr< BondBasket > basket() const
Definition: cbo.hpp:79
Rate subfeeValue() const
std::vector< Real > trancheValue() const
Definition: cbo.cpp:51
void setupArguments(PricingEngine::arguments *) const override
Definition: cbo.cpp:88
bool isExpired() const override
Definition: cbo.cpp:81
Real basketValue_
Definition: cbo.hpp:115
Currency ccy_
Definition: cbo.hpp:112
Rate subordinatedFee_
Definition: cbo.hpp:110
Real feeValueStd_
Definition: cbo.hpp:121
Rate feeValueStd() const
Definition: cbo.cpp:71
Real basketValueStd_
Definition: cbo.hpp:119
std::vector< Real > trancheValueStd_
Definition: cbo.hpp:120
std::vector< CashflowTable > trancheCashflows_
Definition: cbo.hpp:123
std::vector< Tranche > tranches_
Definition: cbo.hpp:109
void setupExpired() const override
Definition: cbo.cpp:118
DayCounter feeDayCounter_
Definition: cbo.hpp:108
void fetchResults(const PricingEngine::results *) const override
Definition: cbo.cpp:103
Rate feeValue() const
Definition: cbo.cpp:56
Real basketValue() const
Definition: cbo.cpp:46
const std::vector< CashflowTable > & trancheCashflows() const
Definition: cbo.cpp:76
Real feeValue_
Definition: cbo.hpp:117
CBO(const QuantLib::ext::shared_ptr< BondBasket > &basket, const QuantLib::Schedule &schedule, Rate seniorFee, const DayCounter &feeDayCounter, const std::vector< Tranche > &tranches, Rate subordinatedFee, Rate equityKicker, const Currency &ccy, const std::string &investedTrancheName)
Definition: cbo.cpp:27
std::vector< Real > trancheValueStd() const
Definition: cbo.cpp:66
Rate equityKicker_
Definition: cbo.hpp:111