Skip to content

Commit 07c6c95

Browse files
committed
Merge remote-tracking branch 'github/bugfix/tradebuilderoverwrite' into github-222
2 parents 0c82e14 + 7b6a5b5 commit 07c6c95

File tree

6 files changed

+37
-5
lines changed

6 files changed

+37
-5
lines changed

Docs/UserGuide/conventions.tex

+6
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ \subsubsection{OIS Conventions}
258258
<FixedPaymentConvention> </FixedPaymentConvention>
259259
<Rule> </Rule>
260260
<PaymentCalendar> </PaymentCalendar>
261+
<RateCutoff> </RateCutoff>
261262
</OIS>
262263
\end{minted}
263264
\caption{OIS conventions}
@@ -285,6 +286,11 @@ \subsubsection{OIS Conventions}
285286
not provided, this defaults to \emph{Backward}.
286287
\item PaymentCalendar [Optional]: The business day calendar used for determining coupon payment dates.
287288
If not specified, this defaults to the fixing calendar defined on the overnight index.
289+
\item RateCutoff: The rate cut-off on the overnight leg. Generally, the overnight fixing
290+
is only observed up to a certain number of days before the end of the interest period date.
291+
The last observed rate is applied for the remaining days in the period.
292+
This rate cut-off gives the number of days e.g.\ 1 for ESTR or SOFR.
293+
If not specified, this defaults to 0 days.
288294
\end{itemize}
289295

290296
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Examples/Input/conventions.xml

+9
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,7 @@
889889
<FixedConvention>Following</FixedConvention>
890890
<FixedPaymentConvention>Following</FixedPaymentConvention>
891891
<Rule>Backward</Rule>
892+
<RateCutoff>1</RateCutoff>
892893
</OIS>
893894
<OIS>
894895
<Id>DKK-OIS-CONVENTIONS</Id>
@@ -901,6 +902,7 @@
901902
<FixedConvention>Following</FixedConvention>
902903
<FixedPaymentConvention>Following</FixedPaymentConvention>
903904
<Rule>Backward</Rule>
905+
<RateCutoff>1</RateCutoff>
904906
</OIS>
905907
<OIS>
906908
<Id>SEK-OIS-CONVENTIONS</Id>
@@ -913,6 +915,7 @@
913915
<FixedConvention>Following</FixedConvention>
914916
<FixedPaymentConvention>Following</FixedPaymentConvention>
915917
<Rule>Backward</Rule>
918+
<RateCutoff>1</RateCutoff>
916919
</OIS>
917920
<OIS>
918921
<Id>CHF-OIS-CONVENTIONS</Id>
@@ -925,6 +928,7 @@
925928
<FixedConvention>Following</FixedConvention>
926929
<FixedPaymentConvention>Following</FixedPaymentConvention>
927930
<Rule>Backward</Rule>
931+
<RateCutoff>1</RateCutoff>
928932
</OIS>
929933
<OIS>
930934
<Id>CHF-OIS-SARON-CONVENTIONS</Id>
@@ -937,6 +941,7 @@
937941
<FixedConvention>Following</FixedConvention>
938942
<FixedPaymentConvention>Following</FixedPaymentConvention>
939943
<Rule>Backward</Rule>
944+
<RateCutoff>1</RateCutoff>
940945
</OIS>
941946
<OIS>
942947
<Id>USD-OIS-CONVENTIONS</Id>
@@ -949,6 +954,7 @@
949954
<FixedConvention>Following</FixedConvention>
950955
<FixedPaymentConvention>Following</FixedPaymentConvention>
951956
<Rule>Backward</Rule>
957+
<RateCutoff>1</RateCutoff>
952958
</OIS>
953959
<AverageOIS>
954960
<Id>USD-AVERAGE-OIS-CONVENTIONS</Id>
@@ -973,6 +979,7 @@
973979
<FixedConvention>Following</FixedConvention>
974980
<FixedPaymentConvention>Following</FixedPaymentConvention>
975981
<Rule>Backward</Rule>
982+
<RateCutoff>1</RateCutoff>
976983
</OIS>
977984
<OIS>
978985
<Id>JPY-OIS-CONVENTIONS</Id>
@@ -985,6 +992,7 @@
985992
<FixedConvention>Following</FixedConvention>
986993
<FixedPaymentConvention>Following</FixedPaymentConvention>
987994
<Rule>Backward</Rule>
995+
<RateCutoff>1</RateCutoff>
988996
</OIS>
989997
<OIS>
990998
<Id>CAD-OIS-CONVENTIONS</Id>
@@ -997,6 +1005,7 @@
9971005
<FixedConvention>Following</FixedConvention>
9981006
<FixedPaymentConvention>Following</FixedPaymentConvention>
9991007
<Rule>Backward</Rule>
1008+
<RateCutoff>1</RateCutoff>
10001009
</OIS>
10011010
<!-- Tenor Basis Swaps -->
10021011
<TenorBasisTwoSwap>

OREData/ored/configuration/conventions.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright (C) 2016 Quaternion Risk Management Ltd
3+
Copyright (C) 2024 Oleg Kulkov
34
All rights reserved.
45
56
This file is part of ORE, a free-software/open-source library
@@ -285,11 +286,12 @@ QuantLib::ext::shared_ptr<IborIndex> FraConvention::index() const { return parse
285286
OisConvention::OisConvention(const string& id, const string& spotLag, const string& index,
286287
const string& fixedDayCounter, const string& fixedCalendar, const string& paymentLag,
287288
const string& eom, const string& fixedFrequency, const string& fixedConvention,
288-
const string& fixedPaymentConvention, const string& rule, const string& paymentCal)
289+
const string& fixedPaymentConvention, const string& rule, const string& paymentCal,
290+
const string& rateCutoff)
289291
: Convention(id, Type::OIS), strSpotLag_(spotLag), strIndex_(index), strFixedDayCounter_(fixedDayCounter),
290292
strFixedCalendar_(fixedCalendar), strPaymentLag_(paymentLag), strEom_(eom), strFixedFrequency_(fixedFrequency),
291293
strFixedConvention_(fixedConvention), strFixedPaymentConvention_(fixedPaymentConvention), strRule_(rule),
292-
strPaymentCal_(paymentCal) {
294+
strPaymentCal_(paymentCal), strRateCutoff_(rateCutoff) {
293295
build();
294296
}
295297

@@ -306,6 +308,8 @@ void OisConvention::build() {
306308
strFixedPaymentConvention_.empty() ? Following : parseBusinessDayConvention(strFixedPaymentConvention_);
307309
rule_ = strRule_.empty() ? DateGeneration::Backward : parseDateGenerationRule(strRule_);
308310
paymentCal_ = strPaymentCal_.empty() ? Calendar() : parseCalendar(strPaymentCal_);
311+
rateCutoff_ = strRateCutoff_.empty() ? 0 : lexical_cast<Natural>(strRateCutoff_);
312+
309313
}
310314

311315
void OisConvention::fromXML(XMLNode* node) {
@@ -327,6 +331,7 @@ void OisConvention::fromXML(XMLNode* node) {
327331
strFixedPaymentConvention_ = XMLUtils::getChildValue(node, "FixedPaymentConvention", false);
328332
strRule_ = XMLUtils::getChildValue(node, "Rule", false);
329333
strPaymentCal_ = XMLUtils::getChildValue(node, "PaymentCalendar", false);
334+
strRateCutoff_ = XMLUtils::getChildValue(node, "RateCutoff", false);
330335

331336
build();
332337
}
@@ -354,6 +359,8 @@ XMLNode* OisConvention::toXML(XMLDocument& doc) const {
354359
XMLUtils::addChild(doc, node, "Rule", strRule_);
355360
if (!strPaymentCal_.empty())
356361
XMLUtils::addChild(doc, node, "PaymentCalendar", strPaymentCal_);
362+
if (!strRateCutoff_.empty())
363+
XMLUtils::addChild(doc, node, "RateCutoff", strRateCutoff_);
357364

358365
return node;
359366
}

OREData/ored/configuration/conventions.hpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright (C) 2016 Quaternion Risk Management Ltd
3+
Copyright (C) 2024 Oleg Kulkov
34
All rights reserved.
45
56
This file is part of ORE, a free-software/open-source library
@@ -381,7 +382,8 @@ class OisConvention : public Convention {
381382
const string& fixedCalendar, const string& paymentLag = "", const string& eom = "",
382383
const string& fixedFrequency = "", const string& fixedConvention = "",
383384
const string& fixedPaymentConvention = "", const string& rule = "",
384-
const std::string& paymentCalendar = "");
385+
const std::string& paymentCalendar = "",
386+
const std::string& rateCutoff = "");
385387
//@}
386388

387389
//! \name Inspectors
@@ -399,6 +401,7 @@ class OisConvention : public Convention {
399401
BusinessDayConvention fixedPaymentConvention() const { return fixedPaymentConvention_; }
400402
DateGeneration::Rule rule() const { return rule_; }
401403
QuantLib::Calendar paymentCalendar() const { return paymentCal_; }
404+
Natural rateCutoff() const { return rateCutoff_; }
402405
//@}
403406

404407
//! \name Serialisation
@@ -419,6 +422,7 @@ class OisConvention : public Convention {
419422
BusinessDayConvention fixedPaymentConvention_;
420423
DateGeneration::Rule rule_;
421424
QuantLib::Calendar paymentCal_;
425+
Natural rateCutoff_;
422426

423427
// Strings to store the inputs
424428
string strSpotLag_;
@@ -432,6 +436,7 @@ class OisConvention : public Convention {
432436
string strFixedPaymentConvention_;
433437
string strRule_;
434438
std::string strPaymentCal_;
439+
string strRateCutoff_;
435440
};
436441

437442
//! Container for storing Ibor Index conventions

OREData/ored/portfolio/tradefactory.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
Copyright (C) 2016-2022 Quaternion Risk Management Ltd
33
Copyright (C) 2021 Skandinaviska Enskilda Banken AB (publ)
4+
Copyright (C) 2023 Oleg Kulkov
45
All rights reserved.
56
67
This file is part of ORE, a free-software/open-source library
@@ -41,8 +42,11 @@ QuantLib::ext::shared_ptr<AbstractTradeBuilder> TradeFactory::getBuilder(const s
4142
void TradeFactory::addBuilder(const std::string& className, const QuantLib::ext::shared_ptr<AbstractTradeBuilder>& builder,
4243
const bool allowOverwrite) {
4344
boost::unique_lock<boost::shared_mutex> lock(mutex_);
44-
QL_REQUIRE(builders_.insert(std::make_pair(className, builder)).second || allowOverwrite,
45-
"TradeFactory: duplicate builder for className '" << className << "'.");
45+
{
46+
auto [it, ins] = builders_.try_emplace(className, builder);
47+
if (!ins) QL_REQUIRE(allowOverwrite && (it->second = builder),
48+
"TradeFactory: duplicate builder for className '" << className << "'.");
49+
}
4650
}
4751

4852
QuantLib::ext::shared_ptr<Trade> TradeFactory::build(const string& className) const { return getBuilder(className)->build(); }

xsd/conventions.xsd

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
<xs:element type="businessDayConvention" name="FixedPaymentConvention" minOccurs="0" maxOccurs="1"/>
106106
<xs:element type="dateRule" name="Rule" minOccurs="0" maxOccurs="1"/>
107107
<xs:element type="xs:string" name="PaymentCalendar" minOccurs="0" maxOccurs="1"/>
108+
<xs:element type="xs:integer" name="RateCutoff" minOccurs="0" maxOccurs="1"/>
108109
</xs:all>
109110
</xs:complexType>
110111

0 commit comments

Comments
 (0)