QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
recoveryratemodel.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2009 Jose Aparicio
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20#ifndef quantlib_recovery_rate_model_hpp
21#define quantlib_recovery_rate_model_hpp
22
23#include <ql/settings.hpp>
24#include <ql/handle.hpp>
27
28namespace QuantLib {
29
30 /*! Models of the recovery rate provide future values of a recovery
31 rate in the event of a default.
32 */
33 class RecoveryRateModel : public virtual Observable {
34 public:
35 /*! returns the expected recovery rate at a future time conditional
36 on some default event type and seniority.
37 */
38 virtual Real recoveryValue(const Date& defaultDate,
39 const DefaultProbKey& defaultKey = DefaultProbKey()) const {
40 // no check on dates...
41 return recoveryValueImpl(defaultDate, defaultKey);
42 }
43 /*! Returns true if the model will return recovery rates for
44 the requested seniority.
45 */
46 virtual bool appliesToSeniority(Seniority) const = 0;
47 ~RecoveryRateModel() override = default;
48
49 protected:
50 /*! Returns Null<Real> if unable to produce a recovery for
51 the requested seniority.
52 */
53 virtual Real recoveryValueImpl(const Date&,
54 const DefaultProbKey& defaultKey
55 ) const = 0;
56 };
57
58
59 /*! Simple Recovery Rate model returning the constant value of the quote
60 independently of the date and the seniority.
61 */
63 public Observer {
64 public:
66 explicit ConstantRecoveryModel(Real recovery,
68 void update() override { notifyObservers(); }
69 bool appliesToSeniority(Seniority) const override { return true; }
70
71 protected:
72 /*! Notice the quote's value is returned without a
73 check on a match of the seniorties of the
74 quote and the request.
75 */
76 Real recoveryValueImpl(const Date&, const DefaultProbKey&) const override {
77 // no match on requested seniority, all pass
78 return quote_->value();
79 }
80
81 private:
83 };
84
85}
86
87#endif
Handle< RecoveryRateQuote > quote_
Real recoveryValueImpl(const Date &, const DefaultProbKey &) const override
bool appliesToSeniority(Seniority) const override
Concrete date class.
Definition: date.hpp:125
Shared handle to an observable.
Definition: handle.hpp:41
Object that notifies its changes to a set of observers.
Definition: observable.hpp:62
Object that gets notified when a given observable changes.
Definition: observable.hpp:116
~RecoveryRateModel() override=default
virtual Real recoveryValueImpl(const Date &, const DefaultProbKey &defaultKey) const =0
virtual Real recoveryValue(const Date &defaultDate, const DefaultProbKey &defaultKey=DefaultProbKey()) const
virtual bool appliesToSeniority(Seniority) const =0
Classes for default-event description.
QL_REAL Real
real number
Definition: types.hpp:50
Globally accessible relinkable pointer.
Definition: any.hpp:35
Seniority
Seniority of a bond.
Definition: defaulttype.hpp:37
global repository for run-time library settings