Skip to content

Commit 3a80f3d

Browse files
mgronckijenkins
authored andcommitted
QPR-12221 fix null calendar in fxkiko
1 parent ab2321f commit 3a80f3d

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

OREData/ored/marketdata/market.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <ored/utilities/indexparser.hpp>
2222
#include <ored/utilities/log.hpp>
2323
#include <ored/utilities/parsers.hpp>
24+
#include <ored/utilities/marketdata.hpp>
2425

2526
#include <qle/indexes/fxindex.hpp>
2627
#include <qle/termstructures/blackinvertedvoltermstructure.hpp>
@@ -190,17 +191,13 @@ QuantLib::Handle<QuantExt::FxIndex> Market::fxIndex(const string& fxIndex, const
190191
Calendar calendar = NullCalendar();
191192

192193
if (source != target) {
193-
const boost::shared_ptr<Conventions>& conventions = InstrumentConventions::instance().conventions();
194-
// first check if we have a convention specific to the pair (e.g. XAUUSD), otherwise use
195194
try {
196-
auto comCon =
197-
boost::dynamic_pointer_cast<data::CommodityForwardConvention>(conventions->get(fxIndex));
198-
calendar = comCon->advanceCalendar();
195+
auto [sDays, cal, _] = getFxIndexConventions(fxIndex);
196+
calendar = cal;
199197
} catch (...) {
200-
WLOG("Market::fxIndex Cannot find commodity conventions for " << fxIndex);
198+
WLOG("Market::fxIndex Cannot find commodity conventions for " << fxIndex);
201199
}
202200
}
203-
204201
fxInd = Handle<QuantExt::FxIndex>(boost::make_shared<QuantExt::FxIndex>(
205202
fxIndexBase->familyName(), spotDays, fxIndexBase->sourceCurrency(), fxIndexBase->targetCurrency(),
206203
calendar, spot, sorTS, tarTS));

OREData/ored/portfolio/fxkikobarrieroption.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,13 @@ void FxKIKOBarrierOption::build(const boost::shared_ptr<EngineFactory>& engineFa
120120
Handle<Quote> spot = market->fxSpot(boughtCurrency_ + soldCurrency_);
121121

122122
boost::shared_ptr<QuantExt::FxIndex> fxIndex;
123-
if (!fxIndex_.empty())
124-
fxIndex = parseFxIndex(fxIndex_);
123+
if (!fxIndex_.empty()) {
124+
auto fxi = market->fxIndex(fxIndex_);
125+
if (!fxi.empty()) {
126+
fxIndex = fxi.currentLink();
127+
}
128+
}
129+
125130

126131
// checking fixings
127132
if (startDate_ != "" && parseDate(startDate()) < today) {

OREData/ored/utilities/marketdata.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ std::tuple<Natural, Calendar, BusinessDayConvention> getFxIndexConventions(const
187187
TLOG("getFxIndexConvention(" << index << "): " << fxCon->spotDays() << " / " << fxCon->advanceCalendar().name()
188188
<< " from convention.");
189189
return std::make_tuple(fxCon->spotDays(), fxCon->advanceCalendar(), fxCon->convention());
190+
} else if (auto comCon = boost::dynamic_pointer_cast<CommodityForwardConvention>(con); comCon !=nullptr
191+
&& (isPseudoCurrency(ccy1) || isPseudoCurrency(ccy2))) {
192+
TLOG("getFxIndexConvention(" << index << "): " << fxCon->spotDays() << " / " << fxCon->advanceCalendar().name()
193+
<< " from convention.");
194+
return std::make_tuple(0, comCon->advanceCalendar(), comCon->bdc());
190195
}
191196

192197
// default calendar for pseudo currencies is USD

0 commit comments

Comments
 (0)