Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
overnightfallbackcurve.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
29OvernightFallbackCurve::OvernightFallbackCurve(const QuantLib::ext::shared_ptr<OvernightIndex>& 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<OvernightIndex> OvernightFallbackCurve::originalIndex() const { return originalIndex_; }
42
43QuantLib::ext::shared_ptr<OvernightIndex> OvernightFallbackCurve::rfrIndex() const { return rfrIndex_; }
44
46
47const Date& OvernightFallbackCurve::switchDate() const { return switchDate_; }
48
50 return originalIndex_->forwardingTermStructure()->referenceDate();
51}
52
53Date OvernightFallbackCurve::maxDate() const { return originalIndex_->forwardingTermStructure()->maxDate(); }
54
55Calendar OvernightFallbackCurve::calendar() const { return originalIndex_->forwardingTermStructure()->calendar(); }
56
58 return originalIndex_->forwardingTermStructure()->settlementDays();
59}
60
61Real OvernightFallbackCurve::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
QuantLib::ext::shared_ptr< OvernightIndex > originalIndex() const
QuantLib::ext::shared_ptr< OvernightIndex > rfrIndex_
const Date & referenceDate() const override
Real discountImpl(QuantLib::Time t) const override
QuantLib::ext::shared_ptr< OvernightIndex > rfrIndex() const
QuantLib::ext::shared_ptr< OvernightIndex > originalIndex_
OvernightFallbackCurve(const QuantLib::ext::shared_ptr< OvernightIndex > &originalIndex, const QuantLib::ext::shared_ptr< OvernightIndex > &rfrIndex, const Real spread, const Date &switchDate)
SimpleQuote & spread_
coupon paying the compounded daily overnight rate, copy of QL class, added includeSpread flag