Skip to content

Commit d7015de

Browse files
committed
Cleanup and remove unecessary if check
1 parent aea67aa commit d7015de

1 file changed

Lines changed: 26 additions & 30 deletions

File tree

OREData/ored/marketdata/yieldcurve.cpp

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -908,47 +908,43 @@ void YieldCurve::buildDiscountCurve() {
908908
} else {
909909
std::ostringstream ss;
910910
ss << MarketDatum::InstrumentType::DISCOUNT << "/" << MarketDatum::QuoteType::RATE << "/" << currency_ << "/*";
911-
// valuta / curve namn
912911
Wildcard w(ss.str());
913912
marketData = loader_.get(w, asofDate_);
914913
}
915914

916915
for (const auto& marketQuote : marketData) {
917-
if (marketQuote) {
918-
QL_REQUIRE(marketQuote->instrumentType() == MarketDatum::InstrumentType::DISCOUNT,
919-
"Market quote not of type Discount.");
920-
boost::shared_ptr<DiscountQuote> discountQuote = boost::dynamic_pointer_cast<DiscountQuote>(marketQuote);
921-
922-
// filtering
923-
if (!wildcard) {
924-
vector<string>::const_iterator it = find(quotes.begin(), quotes.end(), discountQuote->name());
925-
if (it == quotes.end())
926-
continue;
927-
}
928-
916+
QL_REQUIRE(marketQuote->instrumentType() == MarketDatum::InstrumentType::DISCOUNT,
917+
"Market quote not of type Discount.");
918+
boost::shared_ptr<DiscountQuote> discountQuote = boost::dynamic_pointer_cast<DiscountQuote>(marketQuote);
919+
920+
// filtering
921+
if (!wildcard) {
922+
vector<string>::const_iterator it = find(quotes.begin(), quotes.end(), discountQuote->name());
923+
if (it == quotes.end())
924+
continue;
925+
}
929926

930-
if (discountQuote->date() != Date()) {
927+
if (discountQuote->date() != Date()) {
931928

932-
data[discountQuote->date()] = discountQuote->quote()->value();
929+
data[discountQuote->date()] = discountQuote->quote()->value();
933930

934-
} else if (discountQuote->tenor() != Period()) {
931+
} else if (discountQuote->tenor() != Period()) {
935932

936-
if (!convention)
937-
convention = conventions->get(discountCurveSegment->conventionsID());
938-
boost::shared_ptr<ZeroRateConvention> zeroConvention =
939-
boost::dynamic_pointer_cast<ZeroRateConvention>(convention);
940-
QL_REQUIRE(zeroConvention, "could not cast to ZeroRateConvention");
933+
if (!convention)
934+
convention = conventions->get(discountCurveSegment->conventionsID());
935+
boost::shared_ptr<ZeroRateConvention> zeroConvention =
936+
boost::dynamic_pointer_cast<ZeroRateConvention>(convention);
937+
QL_REQUIRE(zeroConvention, "could not cast to ZeroRateConvention");
941938

942-
Calendar cal = zeroConvention->tenorCalendar();
943-
BusinessDayConvention rollConvention = zeroConvention->rollConvention();
944-
Date date = cal.adjust(cal.adjust(asofDate_, rollConvention) + discountQuote->tenor(), rollConvention);
945-
DLOG("YieldCurve::buildDiscountCurve - tenor " << discountQuote->tenor() << " to date "
946-
<< io::iso_date(date));
947-
data[date] = discountQuote->quote()->value();
939+
Calendar cal = zeroConvention->tenorCalendar();
940+
BusinessDayConvention rollConvention = zeroConvention->rollConvention();
941+
Date date = cal.adjust(cal.adjust(asofDate_, rollConvention) + discountQuote->tenor(), rollConvention);
942+
DLOG("YieldCurve::buildDiscountCurve - tenor " << discountQuote->tenor() << " to date "
943+
<< io::iso_date(date));
944+
data[date] = discountQuote->quote()->value();
948945

949-
} else {
950-
QL_FAIL("YieldCurve::buildDiscountCurve - neither date nor tenor recognised");
951-
}
946+
} else {
947+
QL_FAIL("YieldCurve::buildDiscountCurve - neither date nor tenor recognised");
952948
}
953949
}
954950

0 commit comments

Comments
 (0)