File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
3637namespace ore {
3738namespace 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;
You can’t perform that action at this time.
0 commit comments