Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
creditlinkedswap.cpp
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
20
21#include <ql/event.hpp>
22
23namespace QuantExt {
24
25CreditLinkedSwap::CreditLinkedSwap(const std::vector<Leg>& legs, const std::vector<bool>& legPayers,
26 const std::vector<LegType>& legTypes, const bool settlesAccrual,
27 const Real fixedRecoveryRate,
28 const QuantExt::CreditDefaultSwap::ProtectionPaymentTime& defaultPaymentTime,
29 const Currency& currency)
30 : legs_(legs), legPayers_(legPayers), legTypes_(legTypes), settlesAccrual_(settlesAccrual),
31 fixedRecoveryRate_(fixedRecoveryRate), defaultPaymentTime_(defaultPaymentTime), currency_(currency) {
32 QL_REQUIRE(legs_.size() == legPayers_.size(), "CreditLinkedSwap: legs size (" << legs_.size()
33 << ") must match legPayers size ("
34 << legPayers_.size() << ")");
35 QL_REQUIRE(legs_.size() == legTypes_.size(), "CreditLinkedSwap: legs size (" << legs_.size()
36 << ") must match legTypes size ("
37 << legTypes_.size() << ")");
38}
39
40bool CreditLinkedSwap::isExpired() const { return QuantLib::detail::simple_event(maturity()).hasOccurred(); }
41
44 QL_REQUIRE(a != nullptr, "CreditLinkedSwap::setupArguments(): wrong argument type");
45 a->legs = legs_;
53}
54
56 Date maturity = Date::minDate();
57 for (auto const& l : legs_) {
58 for (auto const& c : l) {
59 maturity = std::max(maturity, c->date());
60 }
61 }
62 return maturity;
63}
64
65} // namespace QuantExt
std::vector< LegType > legTypes_
std::vector< bool > legPayers_
bool isExpired() const override
CreditLinkedSwap(const std::vector< Leg > &legs, const std::vector< bool > &legPayers, const std::vector< LegType > &legTypes, const bool settlesAccrual, const Real fixedRecoveryRate, const QuantExt::CreditDefaultSwap::ProtectionPaymentTime &defaultPaymentTime, const Currency &currency)
QuantExt::CreditDefaultSwap::ProtectionPaymentTime defaultPaymentTime_
void setupArguments(QuantLib::PricingEngine::arguments *) const override
credit linked swap instrument
QuantExt::CreditDefaultSwap::ProtectionPaymentTime defaultPaymentTime