-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
catbond.hpp
136 lines (113 loc) · 5.25 KB
/
catbond.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
Copyright (C) 2012, 2013 Grzegorz Andruszkiewicz
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
<quantlib-dev@lists.sf.net>. The license is also available online at
<http://quantlib.org/license.shtml>.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/
/*! \file catbond.hpp
\brief cat bond class
*/
#ifndef quantlib_catbond_hpp
#define quantlib_catbond_hpp
#include <ql/instruments/bond.hpp>
#include <ql/time/dategenerationrule.hpp>
#include <ql/time/schedule.hpp>
#include <ql/indexes/iborindex.hpp>
#include <ql/experimental/catbonds/catrisk.hpp>
#include <ql/experimental/catbonds/riskynotional.hpp>
namespace QuantLib {
class CatBond : public Bond
{
public:
class arguments;
class results;
class engine;
CatBond(Natural settlementDays,
const Calendar& calendar,
const Date& issueDate,
const ext::shared_ptr<NotionalRisk>& notionalRisk)
: Bond(settlementDays, calendar, issueDate), notionalRisk_(notionalRisk) {}
~CatBond() override = default;
void setupArguments(PricingEngine::arguments*) const override;
void fetchResults(const PricingEngine::results*) const override;
Real lossProbability() const { return lossProbability_; }
Real expectedLoss() const { return expectedLoss_; }
Real exhaustionProbability() const { return exhaustionProbability_; }
protected:
ext::shared_ptr<NotionalRisk> notionalRisk_;
mutable Real lossProbability_;
mutable Real exhaustionProbability_;
mutable Real expectedLoss_;
};
class CatBond::arguments : public Bond::arguments {
public:
Date startDate;
ext::shared_ptr<NotionalRisk> notionalRisk;
void validate() const override;
};
//! results for a cat bond calculation
class CatBond::results : public Bond::results {
public:
Real lossProbability;
Real exhaustionProbability;
Real expectedLoss;
};
//! base class for cat bond engine
class CatBond::engine
: public GenericEngine<CatBond::arguments,
CatBond::results> {};
//! floating-rate cat bond (possibly capped and/or floored)
/*! \ingroup instruments
\test calculations are tested by checking results against
cached values.
*/
class FloatingCatBond : public CatBond {
public:
FloatingCatBond(Natural settlementDays,
Real faceAmount,
const Schedule& schedule,
const ext::shared_ptr<IborIndex>& iborIndex,
const DayCounter& accrualDayCounter,
const ext::shared_ptr<NotionalRisk>& notionalRisk,
BusinessDayConvention paymentConvention = Following,
Natural fixingDays = Null<Natural>(),
const std::vector<Real>& gearings = std::vector<Real>(1, 1.0),
const std::vector<Spread>& spreads = std::vector<Spread>(1, 0.0),
const std::vector<Rate>& caps = std::vector<Rate>(),
const std::vector<Rate>& floors = std::vector<Rate>(),
bool inArrears = false,
Real redemption = 100.0,
const Date& issueDate = Date());
FloatingCatBond(Natural settlementDays,
Real faceAmount,
const Date& startDate,
const Date& maturityDate,
Frequency couponFrequency,
const Calendar& calendar,
const ext::shared_ptr<IborIndex>& iborIndex,
const DayCounter& accrualDayCounter,
const ext::shared_ptr<NotionalRisk>& notionalRisk,
BusinessDayConvention accrualConvention = Following,
BusinessDayConvention paymentConvention = Following,
Natural fixingDays = Null<Natural>(),
const std::vector<Real>& gearings = std::vector<Real>(1, 1.0),
const std::vector<Spread>& spreads = std::vector<Spread>(1, 0.0),
const std::vector<Rate>& caps = std::vector<Rate>(),
const std::vector<Rate>& floors = std::vector<Rate>(),
bool inArrears = false,
Real redemption = 100.0,
const Date& issueDate = Date(),
const Date& stubDate = Date(),
DateGeneration::Rule rule = DateGeneration::Backward,
bool endOfMonth = false);
};
}
#endif