Skip to content

Commit e31e934

Browse files
committed
QPR-13700 missing file
1 parent faf579c commit e31e934

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
Copyright (C) 2025 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+
#pragma once
20+
21+
#include <ql/cashflows/iborcoupon.hpp>
22+
23+
namespace QuantExt {
24+
25+
//! utility to locally set usingAtParCoupons in IborCoupon::Settings, using RAII to restore original state
26+
class LocalIborCouponSettings {
27+
public:
28+
explicit LocalIborCouponSettings(const bool usingAtParCoupons) {
29+
usingAtParCouponsSaved_ = QuantLib::IborCoupon::Settings::instance().usingAtParCoupons();
30+
updateGlobalSetting(usingAtParCoupons);
31+
}
32+
~LocalIborCouponSettings() { updateGlobalSetting(usingAtParCouponsSaved_); }
33+
34+
private:
35+
void updateGlobalSetting(const bool usingAtParCoupons) {
36+
if (usingAtParCoupons)
37+
QuantLib::IborCoupon::Settings::instance().createAtParCoupons();
38+
else
39+
QuantLib::IborCoupon::Settings::instance().createIndexedCoupons();
40+
}
41+
bool usingAtParCouponsSaved_;
42+
};
43+
44+
} // namespace QuantExt

0 commit comments

Comments
 (0)