QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
recoveryratemodel.hpp
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>
25#include <ql/experimental/credit/defaultprobabilitykey.hpp>
26#include <ql/experimental/credit/recoveryratequote.hpp>
27
28namespace QuantLib {
29
33 class RecoveryRateModel : public virtual Observable {
34 public:
38 virtual Real recoveryValue(const Date& defaultDate,
39 const DefaultProbKey& defaultKey = DefaultProbKey()) const {
40 // no check on dates...
41 return recoveryValueImpl(defaultDate, defaultKey);
42 }
46 virtual bool appliesToSeniority(Seniority) const = 0;
47 ~RecoveryRateModel() override = default;
48
49 protected:
53 virtual Real recoveryValueImpl(const Date&,
54 const DefaultProbKey& defaultKey
55 ) const = 0;
56 };
57
58
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:
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
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35
Seniority
Seniority of a bond.
Definition: defaulttype.hpp:37