Skip to content

Commit 3987032

Browse files
mgronckijenkins
authored andcommitted
QPR-12164 add required fx fixings for t0 conversion
1 parent 6b2b05b commit 3987032

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

OREData/ored/portfolio/trs.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <boost/assign/list_of.hpp>
3333
#include <boost/bimap.hpp>
3434
#include <boost/optional.hpp>
35+
#include <boost/range/adaptor/map.hpp>
3536

3637
namespace ore {
3738
namespace data {
@@ -653,6 +654,23 @@ void TRS::build(const boost::shared_ptr<EngineFactory>& engineFactory) {
653654
wrapper->setPricingEngine(boost::make_shared<TRSWrapperAccrualEngine>());
654655
instrument_ = boost::make_shared<VanillaInstrument>(wrapper);
655656

657+
// if the first valuation date is > today, we potentially need fixings for fx conversion as of "today"
658+
659+
if (Date today = Settings::instance().evaluationDate(); !valuationDates.empty() && valuationDates.front() > today) {
660+
std::set<boost::shared_ptr<QuantExt::FxIndex>> tmp;
661+
auto fxIndicesVal = fxIndices | boost::adaptors::map_values;
662+
tmp.insert(fxIndicesVal.begin(), fxIndicesVal.end());
663+
tmp.insert(fxIndexAsset.begin(), fxIndexAsset.end());
664+
tmp.insert(fxIndexReturn);
665+
tmp.insert(fxIndexAdditionalCashflows);
666+
for (auto const& fx : tmp) {
667+
if (fx != nullptr) {
668+
requiredFixings_.addFixingDate(fx->fixingCalendar().adjust(today, Preceding),
669+
IndexNameTranslator::instance().oreName(fx->name()));
670+
}
671+
}
672+
}
673+
656674
// set trade member variables (leave legs empty for the time being, we just have the funding leg really)
657675

658676
npvCurrency_ = fundingCurrency;

0 commit comments

Comments
 (0)