|
77 | 77 | #include <ored/utilities/marketdata.hpp> |
78 | 78 | #include <ored/utilities/parsers.hpp> |
79 | 79 | #include <ored/utilities/to_string.hpp> |
| 80 | +#include <ored/utilities/wildcard.hpp> |
80 | 81 |
|
81 | 82 | using namespace QuantLib; |
82 | 83 | using namespace QuantExt; |
@@ -1007,15 +1008,43 @@ void YieldCurve::buildZeroCurve(const std::size_t index) { |
1007 | 1008 | QuantLib::ext::dynamic_pointer_cast<DirectYieldCurveSegment>(curveSegments_[index][0]); |
1008 | 1009 | auto zeroQuoteIDs = zeroCurveSegment->quotes(); |
1009 | 1010 |
|
1010 | | - for (Size i = 0; i < zeroQuoteIDs.size(); ++i) { |
1011 | | - QuantLib::ext::shared_ptr<MarketDatum> marketQuote = loader_.get(zeroQuoteIDs[i], asofDate_); |
1012 | | - if (marketQuote) { |
1013 | | - QL_REQUIRE(marketQuote->instrumentType() == MarketDatum::InstrumentType::ZERO, |
1014 | | - "Market quote not of type zero."); |
1015 | | - QuantLib::ext::shared_ptr<ZeroQuote> zeroQuote = |
1016 | | - QuantLib::ext::dynamic_pointer_cast<ZeroQuote>(marketQuote); |
1017 | | - zeroQuotes.push_back(zeroQuote); |
| 1011 | + // Extract quote strings for wildcard check |
| 1012 | + vector<string> quotes; |
| 1013 | + quotes.reserve(zeroQuoteIDs.size()); |
| 1014 | + std::transform(zeroQuoteIDs.begin(), zeroQuoteIDs.end(), |
| 1015 | + std::back_inserter(quotes), |
| 1016 | + [](const std::pair<string, bool>& pair) { |
| 1017 | + return pair.first; |
| 1018 | + }); |
| 1019 | + // Check for wildcard pattern |
| 1020 | + auto wildcard = getUniqueWildcard(quotes); |
| 1021 | + // Get market data using wildcard or traditional path |
| 1022 | + std::set<QuantLib::ext::shared_ptr<MarketDatum>> marketData; |
| 1023 | + if (wildcard) { |
| 1024 | + marketData = loader_.get(*wildcard, asofDate_); |
| 1025 | + } else { |
| 1026 | + for (Size i = 0; i < zeroQuoteIDs.size(); ++i) { |
| 1027 | + ext::shared_ptr<MarketDatum> marketQuote = loader_.get(zeroQuoteIDs[i], asofDate_); |
| 1028 | + if (marketQuote) |
| 1029 | + marketData.insert(marketQuote); |
| 1030 | + } |
| 1031 | + } |
| 1032 | + // Process market data into zero quotes |
| 1033 | + for (const auto& marketQuote : marketData) { |
| 1034 | + QL_REQUIRE(marketQuote->instrumentType() == MarketDatum::InstrumentType::ZERO, |
| 1035 | + "Market quote not of type zero."); |
| 1036 | + QuantLib::ext::shared_ptr<ZeroQuote> zeroQuote = |
| 1037 | + QuantLib::ext::dynamic_pointer_cast<ZeroQuote>(marketQuote); |
| 1038 | + // If not using wildcard, verify quote is in config list |
| 1039 | + if (!wildcard) { |
| 1040 | + auto it = std::find_if(zeroQuoteIDs.begin(), zeroQuoteIDs.end(), |
| 1041 | + [&](const std::pair<string, bool>& p) { |
| 1042 | + return p.first == marketQuote->name(); |
| 1043 | + }); |
| 1044 | + if (it == zeroQuoteIDs.end()) |
| 1045 | + continue; |
1018 | 1046 | } |
| 1047 | + zeroQuotes.push_back(zeroQuote); |
1019 | 1048 | } |
1020 | 1049 |
|
1021 | 1050 | // Create the (date, zero) pairs. |
@@ -1289,7 +1318,15 @@ void YieldCurve::buildDiscountCurve(const std::size_t index) { |
1289 | 1318 | "Market quote not of type Discount."); |
1290 | 1319 | QuantLib::ext::shared_ptr<DiscountQuote> discountQuote = |
1291 | 1320 | QuantLib::ext::dynamic_pointer_cast<DiscountQuote>(marketQuote); |
1292 | | - |
| 1321 | + // If not using wildcard, verify quote is in config list |
| 1322 | + if (!wildcard) { |
| 1323 | + auto it = std::find_if(discountQuoteIDs.begin(), discountQuoteIDs.end(), |
| 1324 | + [&](const std::pair<string, bool>& p) { |
| 1325 | + return p.first == marketQuote->name(); |
| 1326 | + }); |
| 1327 | + if (it == discountQuoteIDs.end()) |
| 1328 | + continue; |
| 1329 | + } |
1293 | 1330 | if (discountQuote->date() != Date()) { |
1294 | 1331 |
|
1295 | 1332 | data[discountQuote->date()] = discountQuote->quote()->value(); |
|
0 commit comments