Skip to content

Commit 406faff

Browse files
damienbarkerfarahkhashman
authored andcommitted
Merge branch 'bugfix/QPR-13630' into 'master'
QPR-13630 portfolio build if allFixings = false or enrich fixings (GH295) Closes QPR-13630 See merge request qs/oreplus!3008
1 parent 31826c0 commit 406faff

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

OREAnalytics/orea/app/analytic.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,29 @@ QuantLib::ext::shared_ptr<EngineFactory> Analytic::Impl::engineFactory() {
211211
}
212212

213213
void Analytic::setUp() {
214+
214215
if (!portfolio_) {
215216
portfolio_ = QuantLib::ext::make_shared<Portfolio>();
216217
if (inputs()->portfolio()) {
217218
for (const auto& [tradeId, trade] : inputs()->portfolio()->trades())
218219
portfolio_->add(trade);
219220
}
220221
}
222+
221223
buildConfigurations();
222-
if (inputs()->enrichIndexFixings() && portfolio_)
223-
enrichIndexFixings(portfolio_);
224+
225+
/* if we do not load all fixings, and the portfolio is not built at this point,
226+
we built it against a dummy market using the portfolio analyser, so that
227+
we can ask the portfolio for its required fixings in the market data loader
228+
and also enrich the index fixings here (if desired). */
229+
if (!portfolio_->empty() && !inputs()->allFixings()) {
230+
if (!portfolio_->isBuilt()) {
231+
PortfolioAnalyser(portfolio_, inputs_->pricingEngine(), inputs_->baseCurrency(),
232+
configurations().curveConfig, inputs_->refDataManager(), inputs_->iborFallbackConfig());
233+
}
234+
if (inputs()->enrichIndexFixings())
235+
enrichIndexFixings(portfolio_);
236+
}
224237
}
225238

226239
void Analytic::buildMarket(const QuantLib::ext::shared_ptr<ore::data::InMemoryLoader>& loader,
@@ -344,13 +357,6 @@ void Analytic::enrichIndexFixings(const QuantLib::ext::shared_ptr<ore::data::Por
344357

345358
startTimer("enrichIndexFixings()");
346359
QL_REQUIRE(portfolio, "portfolio cannot be empty");
347-
348-
//! if the portfolio is not built, create a portfolio analyser which builds the portfolio under a dummy market
349-
if (!portfolio->isBuilt()) {
350-
PortfolioAnalyser(
351-
portfolio_, inputs_->pricingEngine(), inputs_->baseCurrency(), configurations().curveConfig,
352-
inputs_->refDataManager(), inputs_->iborFallbackConfig());
353-
}
354360

355361
auto isFallbackFixingDateWithinLimit = [this](Date originalFixingDate, Date fallbackFixingDate) {
356362
if (fallbackFixingDate > originalFixingDate) {

OREAnalytics/orea/app/marketdataloader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ void MarketDataLoader::populateFixings(
208208
amendInflationFixingDates(fixings_);
209209
}
210210

211-
if (fixings_.size() > 0 && impl_)
211+
if ((inputs_->allFixings() || fixings_.size() > 0) && impl_)
212212
impl()->retrieveFixings(loader_, fixings_, lastAvailableFixingLookupMap);
213213

214214
applyFixings(loader_->loadFixings());

0 commit comments

Comments
 (0)