Skip to content

Commit 0b18303

Browse files
author
Damien Barker
committed
QPR-12959 fix overnight fallback index
1 parent 3d83ffb commit 0b18303

15 files changed

Lines changed: 143 additions & 13 deletions

File tree

OREAnalytics/orea/app/inputparameters.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ void InputParameters::setScenarioReader(const std::string& fileName) {
743743
scenarioReader_ = QuantLib::ext::make_shared<ScenarioFileReader>(
744744
fileName, QuantLib::ext::make_shared<SimpleScenarioFactory>(false));
745745
}
746-
} catch (const std::exception& e) {
746+
} catch (const std::exception&) {
747747
// If the file does not exist or fails, assume it is a scenario string
748748
scenarioReader_ = QuantLib::ext::make_shared<ScenarioBufferReader>(
749749
fileName, QuantLib::ext::make_shared<SimpleScenarioFactory>(true));

OREAnalytics/orea/engine/dependencymarket.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Handle<IborIndex> DependencyMarket::iborIndex(const string& name, const string&
221221
<< rfrName << "' to OvernightIndex, this is unexpected.");
222222
auto fallbackData = iborFallbackConfig_->fallbackData(name);
223223
if (auto original = QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(iip))
224-
ii = Handle<IborIndex>(QuantLib::ext::make_shared<QuantExt::FallbackIborIndex>(
224+
ii = Handle<IborIndex>(QuantLib::ext::make_shared<QuantExt::FallbackOvernightIndex>(
225225
original, oi, fallbackData.spread,
226226
fallbackData.switchDate, false));
227227
else

OREAnalytics/orea/scenario/scenariosimmarket.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ ScenarioSimMarket::ScenarioSimMarket(
506506
<< "' to overnight index when building the ibor fallback index '" << name
507507
<< "'");
508508
if (auto original = QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(i))
509-
i = QuantLib::ext::make_shared<QuantExt::FallbackIborIndex>(
509+
i = QuantLib::ext::make_shared<QuantExt::FallbackOvernightIndex>(
510510
original, rfrInd, fallbackData.spread, fallbackData.switchDate,
511511
iborFallbackConfig_->useRfrCurveInSimulationMarket());
512512
else

OREData/ored/marketdata/todaysmarket.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include <qle/indexes/dividendmanager.hpp>
4848
#include <qle/indexes/equityindex.hpp>
4949
#include <qle/indexes/fallbackiborindex.hpp>
50+
#include <qle/indexes/fallbackovernightindex.hpp>
5051
#include <qle/indexes/fxindex.hpp>
5152
#include <qle/indexes/inflationindexwrapper.hpp>
5253
#include <qle/termstructures/blackvolsurfacewithatm.hpp>
@@ -343,7 +344,7 @@ void TodaysMarket::buildNode(const std::string& configuration, ReducedNode& redu
343344
<< fallbackData.rfrIndex << "' as fallback for ibor index '" << node.name
344345
<< "', but this is not an overnight index. Are the fallback rules correct here?");
345346
if (auto original = QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(tmpIndex))
346-
tmpIndex = QuantLib::ext::make_shared<QuantExt::FallbackIborIndex>(
347+
tmpIndex = QuantLib::ext::make_shared<QuantExt::FallbackOvernightIndex>(
347348
original, oi, fallbackData.spread, fallbackData.switchDate,
348349
iborFallbackConfig_->useRfrCurveInTodaysMarket());
349350
else

OREData/ored/portfolio/fixingdates.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#include <qle/indexes/commodityindex.hpp>
5555
#include <qle/indexes/compositeindex.hpp>
5656
#include <qle/indexes/fallbackiborindex.hpp>
57+
#include <qle/indexes/fallbackovernightindex.hpp>
5758
#include <qle/indexes/genericindex.hpp>
5859
#include <qle/indexes/offpeakpowerindex.hpp>
5960

@@ -621,7 +622,7 @@ void FixingDateGetter::visit(QuantLib::OvernightIndexedCoupon& c) {
621622
}
622623

623624
void FixingDateGetter::visit(QuantExt::OvernightIndexedCoupon& c) {
624-
auto fallback = QuantLib::ext::dynamic_pointer_cast<FallbackIborIndex>(c.index());
625+
auto fallback = QuantLib::ext::dynamic_pointer_cast<FallbackOvernightIndex>(c.index());
625626
string indexName;
626627
if (fallback && c.fixingDate() >= fallback->switchDate())
627628
indexName = fallback->rfrIndex()->name();

OREData/ored/scripting/utilities.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ QuantLib::ext::shared_ptr<FallbackIborIndex> IndexInfo::irIborFallback(const Qua
509509
return nullptr;
510510
}
511511

512-
QuantLib::ext::shared_ptr<FallbackIborIndex>
512+
QuantLib::ext::shared_ptr<FallbackOvernightIndex>
513513
IndexInfo::irOvernightFallback(const QuantLib::ext::shared_ptr<IborFallbackConfig>& iborFallbackConfig,
514514
const Date& asof) const {
515515
if (isIrIbor_ && iborFallbackConfig->isIndexReplaced(name_, asof)) {
@@ -519,7 +519,7 @@ IndexInfo::irOvernightFallback(const QuantLib::ext::shared_ptr<IborFallbackConfi
519519
QL_REQUIRE(on, "IndexInfo::irIborFallback(): could not cast rfr index '"
520520
<< data.rfrIndex << "' for ibor fallback index '" << name_ << "' to an overnight index");
521521
if (auto original = QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(irIbor_))
522-
return QuantLib::ext::make_shared<FallbackIborIndex>(original, on, data.spread, data.switchDate,
522+
return QuantLib::ext::make_shared<FallbackOvernightIndex>(original, on, data.spread, data.switchDate,
523523
original->forwardingTermStructure());
524524
else
525525
return nullptr;

OREData/ored/scripting/utilities.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include <qle/time/futureexpirycalculator.hpp>
3333
#include <qle/indexes/fallbackiborindex.hpp>
34+
#include <qle/indexes/fallbackovernightindex.hpp>
3435

3536
#pragma once
3637

@@ -116,7 +117,7 @@ class IndexInfo {
116117
QuantLib::ext::shared_ptr<FallbackIborIndex> irIborFallback(const QuantLib::ext::shared_ptr<IborFallbackConfig>& iborFallbackConfig,
117118
const Date& asof = QuantLib::Date::maxDate()) const;
118119
// nullptr if it is no overnight fallback index
119-
QuantLib::ext::shared_ptr<FallbackIborIndex>
120+
QuantLib::ext::shared_ptr<FallbackOvernightIndex>
120121
irOvernightFallback(const QuantLib::ext::shared_ptr<IborFallbackConfig>& iborFallbackConfig,
121122
const Date& asof = QuantLib::Date::maxDate()) const;
122123
QuantLib::ext::shared_ptr<SwapIndex> irSwap() const { return irSwap_; }

QuantExt/qle/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ indexes/compositeindex.cpp
8888
indexes/dividendmanager.cpp
8989
indexes/equityindex.cpp
9090
indexes/fallbackiborindex.cpp
91+
indexes/fallbackovernightindex.cpp
9192
indexes/formulabasedindex.cpp
9293
indexes/fxindex.cpp
9394
indexes/genericiborindex.cpp
@@ -550,6 +551,7 @@ indexes/eqfxindexbase.hpp
550551
indexes/equityindex.hpp
551552
indexes/escpi.hpp
552553
indexes/fallbackiborindex.hpp
554+
indexes/fallbackovernightindex.hpp
553555
indexes/formulabasedindex.hpp
554556
indexes/frcpi.hpp
555557
indexes/fxindex.hpp

QuantExt/qle/indexes/fallbackiborindex.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
namespace QuantExt {
3333
using namespace QuantLib;
3434

35+
class FallbackOvernightIndex;
36+
3537
class FallbackIborIndex : public QuantLib::IborIndex {
3638
public:
3739
FallbackIborIndex(const QuantLib::ext::shared_ptr<IborIndex> originalIndex,
@@ -57,6 +59,7 @@ class FallbackIborIndex : public QuantLib::IborIndex {
5759

5860
private:
5961
Rate forecastFixing(const Date& valueDate, const Date& endDate, Time t) const override;
62+
friend class FallbackOvernightIndex;
6063
QuantLib::ext::shared_ptr<IborIndex> originalIndex_;
6164
QuantLib::ext::shared_ptr<OvernightIndex> rfrIndex_;
6265
Real spread_;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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/indexes/fallbackiborindex.hpp
20+
\brief wrapper class for ibor index managing the fallback rules
21+
\ingroup indexes
22+
*/
23+
24+
#include <qle/indexes/fallbackovernightindex.hpp>
25+
26+
namespace QuantExt {
27+
28+
FallbackOvernightIndex::FallbackOvernightIndex(const QuantLib::ext::shared_ptr<OvernightIndex> originalIndex,
29+
const QuantLib::ext::shared_ptr<OvernightIndex> rfrIndex, const Real spread,
30+
const Date& switchDate, const bool useRfrCurve)
31+
: OvernightIndex(originalIndex->familyName(), originalIndex->fixingDays(), originalIndex->currency(),
32+
originalIndex->fixingCalendar(), originalIndex->dayCounter(), Handle<YieldTermStructure>()) {
33+
iborFallbackIndex_ = std::make_unique<FallbackIborIndex>(originalIndex, rfrIndex, spread, switchDate, useRfrCurve);
34+
}
35+
36+
FallbackOvernightIndex::FallbackOvernightIndex(const QuantLib::ext::shared_ptr<OvernightIndex> originalIndex,
37+
const QuantLib::ext::shared_ptr<OvernightIndex> rfrIndex, const Real spread,
38+
const Date& switchDate, const Handle<YieldTermStructure>& forwardingCurve)
39+
: OvernightIndex(originalIndex->familyName(), originalIndex->fixingDays(),
40+
originalIndex->currency(), originalIndex->fixingCalendar(),
41+
originalIndex->dayCounter(), forwardingCurve) {
42+
iborFallbackIndex_ = std::make_unique<FallbackIborIndex>(originalIndex, rfrIndex, spread, switchDate, forwardingCurve);
43+
}
44+
45+
} // namespace QuantExt

0 commit comments

Comments
 (0)