36 std::vector<std::string> tokens;
37 boost::split(tokens, fixingId, boost::is_any_of(
"-"));
38 QL_REQUIRE(tokens.size() == 4,
"MarketDataLoader::additional_fx_fixings: Invalid fixing id, "
39 <<
"must be of form FX-TYPE-CCY1-CCY, e.g FX-ECB-EUR-GBP");
42 relevantFixings[tokens[0] +
"-" + tokens[1] +
"-" + tokens[3] +
"-" + tokens[2]].addDates(fixingDates,
false);
44 vector<string> baseCcys = {
"USD",
"EUR"};
46 for (
auto ccy : baseCcys) {
48 string fixingType = tokens[0] +
"-" + tokens[1] +
"-";
49 if (tokens[2] != ccy) {
50 string fix = fixingType + ccy +
"-" + tokens[2];
51 relevantFixings[fix].addDates(fixingDates,
false);
53 if (tokens[3] != ccy) {
54 fix = fixingType + tokens[2] +
"-" + ccy;
55 relevantFixings[fix].addDates(fixingDates,
false);
59 if (tokens[3] != ccy) {
60 string fix = fixingType + ccy +
"-" + tokens[3];
61 relevantFixings[fix].addDates(fixingDates,
false);
63 if (tokens[2] != ccy) {
64 fix = fixingType + tokens[3] +
"-" + ccy;
65 relevantFixings[fix].addDates(fixingDates,
false);
73 map<pair<string, Date>, set<Date>>& commodityMap) {
75 QuantLib::ext::shared_ptr<Conventions> conventions = InstrumentConventions::instance().conventions();
78 string commName = ind->underlyingName();
80 QuantLib::ext::shared_ptr<CommodityFutureConvention> cfc;
81 if (conventions->has(commName)) {
82 cfc = QuantLib::ext::dynamic_pointer_cast<CommodityFutureConvention>(conventions->get(commName));
88 if (cfc->contractFrequency() == Daily) {
89 for (
const auto& [fd, _]: fixingDates) {
92 Date wLookback = fd - Period(1, Weeks);
94 dates.insert(wLookback++);
95 }
while (wLookback <= fd);
97 TLOG(
"Adding (date, id) = (" << io::iso_date(fd) <<
"," << fixingId <<
")");
100 fixings[fixingId].addDates(dates,
false);
101 commodityMap[pair(fixingId, fd)].insert(dates.begin(), dates.end());
105 for (
const auto& [fd,_] : fixingDates) {
107 Date wLookback = fd - Period(45, Days);
109 dates.insert(wLookback++);
110 }
while (wLookback <= fd);
112 TLOG(
"Adding (date, id) = (" << io::iso_date(fd) <<
"," << fixingId <<
")");
115 fixings[fixingId].addDates(dates,
false);
116 commodityMap[pair(fixingId, fd)].insert(dates.begin(), dates.end());
124 const QuantLib::ext::shared_ptr<ReferenceDataManager> refData,
125 const QuantLib::ext::shared_ptr<CurveConfigurations>& curveConfigs) {
127 Date
asof = Settings::instance().evaluationDate();
128 QuantLib::ext::shared_ptr<CurrencyHedgedEquityIndexReferenceDatum> currencyHedgedIndexData;
130 for (
const auto& [equityName, _] : mktParams.
mapping(MarketObject::EquityCurve, configuration)) {
133 if (indexDecomposition) {
134 indexDecomposition->addAdditionalFixingsForEquityIndexDecomposition(
asof, fixings);
136 }
catch (
const std::exception& e) {
137 ALOG(
"adding additional equity fixing failed, " << e.what());
144 QL_REQUIRE(
impl_,
"No MarketDataLoader implementation of type MarketDataLoaderImpl set");
149 const std::pair<std::string, RequiredFixings::FixingDates>& fixing,
150 std::map<std::pair<std::string, QuantLib::Date>, std::set<QuantLib::Date>>& lastAvailableFixingLookupMap) {
159 fixings_[fixing.first].addDates(fixing.second);
163 const std::vector<QuantLib::ext::shared_ptr<ore::data::TodaysMarketParameters>>& todaysMarketParameters,
164 const std::set<QuantLib::Date>& loaderDates) {
168 LOG(
"Asking portfolio for its required fixings");
170 std::map<std::pair<std::string, QuantLib::Date>, std::set<QuantLib::Date>> lastAvailableFixingLookupMap;
174 portfolioFixings =
inputs_->portfolio()->fixings();
175 LOG(
"The portfolio depends on fixings from " << portfolioFixings.size() <<
" indices");
176 for (
const auto& it : portfolioFixings)
180 LOG(
"Add fixings possibly required for bootstrapping TodaysMarket");
181 for (
const auto& tmp : todaysMarketParameters) {
182 for (
const auto d : loaderDates)
184 LOG(
"Add fixing possibly required for equity index delta risk decomposition")
186 inputs_->curveConfigs().get());
189 if (
inputs_->eomInflationFixings()) {
190 LOG(
"Adjust inflation fixing dates to the end of the month before the request");
201 for (
const auto& [indexName, fixingDates] :
fixings_) {
202 for (
const auto& [d, mandatory] :fixingDates) {
203 if (mandatory && !
loader_->hasFixing(indexName, d)) {
204 string fixingErr =
"";
208 if(fxInd->fixingCalendar().isBusinessDay(d))
211 }
catch (
const std::exception& e) {
224 const std::vector<QuantLib::ext::shared_ptr<ore::data::TodaysMarketParameters>>& todaysMarketParameters,
225 const std::set<QuantLib::Date>& loaderDates) {
229 loader_ = QuantLib::ext::make_shared<InMemoryLoader>();
234 QL_REQUIRE(!
inputs_->curveConfigs().empty(),
"Need at least one curve configuration to populate loader.");
235 QL_REQUIRE(todaysMarketParameters.size() > 0,
"No todaysMarketParams provided to populate market data loader.");
238 std::map<std::string, std::string> equities;
239 for (
const auto& tmp : todaysMarketParameters) {
240 if (tmp->hasMarketObject(MarketObject::EquityCurve)) {
242 for (
auto eq : eqMap) {
243 if (
inputs_->refDataManager() &&
inputs_->refDataManager()->hasData(
"Equity", eq.first)) {
244 auto refData = QuantLib::ext::dynamic_pointer_cast<EquityReferenceDatum>(
245 inputs_->refDataManager()->getData(
"Equity", eq.first));
246 auto erData = refData->equityData();
247 equities[eq.first] = erData.equityId;
249 equities[eq.first] = eq.first;
253 if (equities.size() > 0)
254 impl()->loadCorporateActionData(
loader_, equities);
261 LOG(
"Adding the loaded fixings to the IndexManager");
265 LOG(
"Generating market datum set");
267 for (
const auto& tmp : todaysMarketParameters) {
269 std::set<std::string> configurations;
270 for (
auto c : tmp->configurations())
271 configurations.insert(c.first);
273 for (
const auto& [_,curveConfig] :
inputs_->curveConfigs().curveConfigurations()) {
274 auto qs = curveConfig->quotes(tmp, configurations);
275 quotes.insert(qs.begin(), qs.end());
279 for (
const auto& d : loaderDates) {
283 LOG(
"CurveConfigs require " <<
quotes.size() <<
" quotes");
290 LOG(
"Got market data");
virtual void populateFixings(const std::vector< QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > > &todaysMarketParameters, const std::set< QuantLib::Date > &loaderDates={})
QuantLib::ext::shared_ptr< MarketDataLoaderImpl > impl_
void populateLoader(const std::vector< QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > > &todaysMarketParameters, const std::set< QuantLib::Date > &loaderDates)
virtual void addRelevantFixings(const std::pair< std::string, RequiredFixings::FixingDates > &fixing, std::map< std::pair< std::string, QuantLib::Date >, std::set< QuantLib::Date > > &lastAvailableFixingLookupMap)
QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > loader_
QuantLib::ext::shared_ptr< InputParameters > inputs_
const QuantLib::ext::shared_ptr< MarketDataLoaderImpl > & impl() const
Utility class for Structured Fixing warnings.
static const string defaultConfiguration
const map< string, string > & mapping(const MarketObject o, const string &configuration) const
bool hasMarketObject(const MarketObject &o) const
QuantLib::ext::shared_ptr< FxIndex > parseFxIndex(const string &s, const Handle< Quote > &fxSpot=Handle< Quote >(), const Handle< YieldTermStructure > &sourceYts=Handle< YieldTermStructure >(), const Handle< YieldTermStructure > &targetYts=Handle< YieldTermStructure >(), const bool useConventions=false)
bool isCommodityIndex(const std::string &indexName)
void applyDividends(const std::set< Dividend > ÷nds)
std::map< std::string, RequiredFixings::FixingDates > FixingMap
void additional_fx_fixings(const string &fixingId, const RequiredFixings::FixingDates &fixingDates, FixingMap &relevantFixings)
std::map< QuantLib::Date, std::set< std::string > > QuoteMap
void additional_equity_fixings(map< string, RequiredFixings::FixingDates > &fixings, const TodaysMarketParameters &mktParams, const QuantLib::ext::shared_ptr< ReferenceDataManager > refData, const QuantLib::ext::shared_ptr< CurveConfigurations > &curveConfigs)
void additional_commodity_fixings(const string &fixingId, const RequiredFixings::FixingDates &fixingDates, FixingMap &fixings, map< pair< string, Date >, set< Date > > &commodityMap)
bool isFxIndex(const std::string &indexName)
void amendInflationFixingDates(std::map< std::string, RequiredFixings::FixingDates > &fixings)
QuantLib::ext::shared_ptr< CurrencyHedgedEquityIndexDecomposition > loadCurrencyHedgedIndexDecomposition(const std::string &name, const QuantLib::ext::shared_ptr< ReferenceDataManager > &refDataMgr, const QuantLib::ext::shared_ptr< CurveConfigurations > &curveConfigs)
void addMarketFixingDates(const Date &asof, map< string, RequiredFixings::FixingDates > &fixings, const TodaysMarketParameters &mktParams, const Period &iborLookback, const Period &oisLookback, const Period &bmaLookback, const Period &inflationLookback)
std::string to_string(const LocationInfo &l)
QuantLib::ext::shared_ptr< QuantExt::CommodityIndex > parseCommodityIndex(const string &name, bool hasPrefix, const Handle< PriceTermStructure > &ts, const Calendar &cal, const bool enforceFutureIndex)
void applyFixings(const std::set< Fixing > &fixings)
vector< string > curveConfigs