Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
iborfallbackcurve.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
19/*! \file qle/termstructures/iborfallbackcurve.hpp
20 \brief projection curve for ibor fallback indices
21*/
22
24
26
27namespace QuantExt {
28
29IborFallbackCurve::IborFallbackCurve(const QuantLib::ext::shared_ptr<IborIndex>& originalIndex,
30 const QuantLib::ext::shared_ptr<OvernightIndex>& rfrIndex, const Real spread,
31 const Date& switchDate)
32 : YieldTermStructure(originalIndex->forwardingTermStructure()->dayCounter()), originalIndex_(originalIndex),
33 rfrIndex_(rfrIndex), spread_(spread), switchDate_(switchDate) {
34 registerWith(originalIndex->forwardingTermStructure());
35 registerWith(rfrIndex->forwardingTermStructure());
36 // Always enable extrapolation: The original and rfr index forwarding curves might have different settings
37 // so we do not want to make things overly complicated here.
38 enableExtrapolation();
39}
40
41QuantLib::ext::shared_ptr<IborIndex> IborFallbackCurve::originalIndex() const { return originalIndex_; }
42
43QuantLib::ext::shared_ptr<OvernightIndex> IborFallbackCurve::rfrIndex() const { return rfrIndex_; }
44
45Real IborFallbackCurve::spread() const { return spread_; }
46
47const Date& IborFallbackCurve::switchDate() const { return switchDate_; }
48
50 return originalIndex_->forwardingTermStructure()->referenceDate();
51}
52
53Date IborFallbackCurve::maxDate() const { return originalIndex_->forwardingTermStructure()->maxDate(); }
54
55Calendar IborFallbackCurve::calendar() const { return originalIndex_->forwardingTermStructure()->calendar(); }
56
58 return originalIndex_->forwardingTermStructure()->settlementDays();
59}
60
61Real IborFallbackCurve::discountImpl(QuantLib::Time t) const {
62 Date today = Settings::instance().evaluationDate();
63 if (today < switchDate_) {
64 return originalIndex_->forwardingTermStructure()->discount(t);
65 }
66 Date endDate = today + originalIndex_->tenor();
67 Real couponTime = rfrIndex_->dayCounter().yearFraction(today, endDate);
68 Real curveTime = timeFromReference(endDate);
69 Real s = std::log(1.0 + couponTime * spread_) / curveTime;
70 return rfrIndex_->forwardingTermStructure()->discount(t) * std::exp(-s * t);
71}
72
73} // namespace QuantExt
Calendar calendar() const override
QuantLib::ext::shared_ptr< IborIndex > originalIndex_
QuantLib::ext::shared_ptr< OvernightIndex > rfrIndex_
const Date & referenceDate() const override
IborFallbackCurve(const QuantLib::ext::shared_ptr< IborIndex > &originalIndex, const QuantLib::ext::shared_ptr< OvernightIndex > &rfrIndex, const Real spread, const Date &switchDate)
Natural settlementDays() const override
Date maxDate() const override
Real discountImpl(QuantLib::Time t) const override
QuantLib::ext::shared_ptr< OvernightIndex > rfrIndex() const
const Date & switchDate() const
QuantLib::ext::shared_ptr< IborIndex > originalIndex() const
projection curve for ibor fallback indices
SimpleQuote & spread_
coupon paying the compounded daily overnight rate, copy of QL class, added includeSpread flag