Skip to content

Commit

Permalink
Automated fixes by clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored and lballabio committed Jul 29, 2024
1 parent 9d01e03 commit 3d45b9a
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 32 deletions.
6 changes: 3 additions & 3 deletions ql/experimental/commodities/commoditycurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ namespace QuantLib {

dates_.clear();
data_.clear();
for (auto i = prices.begin(); i != prices.end(); ++i) {
dates_.push_back(i->first);
data_.push_back(i->second);
for (auto & price : prices) {
dates_.push_back(price.first);
data_.push_back(price.second);
}

times_.resize(dates_.size());
Expand Down
6 changes: 2 additions & 4 deletions ql/experimental/commodities/energybasisswap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,8 @@ namespace QuantLib {

QL_REQUIRE(!paymentCashFlows_.empty(), "no cashflows");

for (auto i =
secondaryCostAmounts_.begin();
i != secondaryCostAmounts_.end(); ++i) {
Real amount = i->second.value();
for (auto & secondaryCostAmount : secondaryCostAmounts_) {
Real amount = secondaryCostAmount.second.value();
NPV_ -= amount;
}

Expand Down
15 changes: 7 additions & 8 deletions ql/experimental/commodities/energycommodity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,22 @@ namespace QuantLib {
const Currency& baseCurrency =
CommoditySettings::instance().currency();
try {
for (auto i = secondaryCosts_->begin();
i != secondaryCosts_->end(); ++i) {
if (ext::any_cast<CommodityUnitCost>(&i->second) != nullptr) {
for (auto & i : *secondaryCosts_) {
if (ext::any_cast<CommodityUnitCost>(&i.second) != nullptr) {
Real value =
calculateUnitCost(
commodityType,
ext::any_cast<CommodityUnitCost>(i->second),
ext::any_cast<CommodityUnitCost>(i.second),
evaluationDate) * totalQuantityValue;
secondaryCostAmounts_[i->first] =
secondaryCostAmounts_[i.first] =
Money(baseCurrency, value);
} else if (ext::any_cast<Money>(&i->second) != nullptr) {
const Money& amount = ext::any_cast<Money>(i->second);
} else if (ext::any_cast<Money>(&i.second) != nullptr) {
const Money& amount = ext::any_cast<Money>(i.second);
Real fxConversionFactor =
calculateFxConversionFactor(amount.currency(),
baseCurrency,
evaluationDate);
secondaryCostAmounts_[i->first] =
secondaryCostAmounts_[i.first] =
Money(baseCurrency,
amount.value() * fxConversionFactor);
}
Expand Down
4 changes: 2 additions & 2 deletions ql/experimental/commodities/energyfuture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ namespace QuantLib {

calculateSecondaryCostAmounts(quantity_.commodityType(),
quantity_.amount(), evaluationDate);
for (auto i = secondaryCostAmounts_.begin(); i != secondaryCostAmounts_.end(); ++i) {
Real amount = i->second.value();
for (auto & secondaryCostAmount : secondaryCostAmounts_) {
Real amount = secondaryCostAmount.second.value();
NPV_ -= amount;
}

Expand Down
6 changes: 2 additions & 4 deletions ql/experimental/commodities/energyvanillaswap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,8 @@ namespace QuantLib {

QL_REQUIRE(!paymentCashFlows_.empty(), "no cashflows");

for (auto i =
secondaryCostAmounts_.begin();
i != secondaryCostAmounts_.end(); ++i) {
Real amount = i->second.value();
for (auto & secondaryCostAmount : secondaryCostAmounts_) {
Real amount = secondaryCostAmount.second.value();
NPV_ -= amount;
}

Expand Down
8 changes: 4 additions & 4 deletions ql/experimental/variancegamma/fftengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ namespace QuantLib {
std::complex<Real> i1(0, 1);
Real alpha = 1.25;

for (auto payIt = payoffMap.begin(); payIt != payoffMap.end(); ++payIt)
for (auto & payIt : payoffMap)
{
Date expiryDate = payIt->first;
Date expiryDate = payIt.first;

// Calculate n large enough for maximum strike, and round up to a power of 2
Real maxStrike = 0.0;
for (const auto& payoff : payIt->second) {
for (const auto& payoff : payIt.second) {
if (payoff->strike() > maxStrike)
maxStrike = payoff->strike();
}
Expand Down Expand Up @@ -159,7 +159,7 @@ namespace QuantLib {
strikes[i] = std::exp(k_u);
}

for (const auto& payoff : payIt->second) {
for (const auto& payoff : payIt.second) {
Real callPrice = LinearInterpolation(strikes.begin(), strikes.end(),
prices.begin())(payoff->strike());
switch (payoff->optionType())
Expand Down
4 changes: 2 additions & 2 deletions ql/instruments/compositeinstrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ namespace QuantLib {
}

void CompositeInstrument::deepUpdate() {
for (auto i=components_.begin(); i!=components_.end(); ++i) {
i->first->deepUpdate();
for (auto & component : components_) {
component.first->deepUpdate();
}
update();
}
Expand Down
4 changes: 2 additions & 2 deletions test-suite/defaultprobabilitycurves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,9 @@ BOOST_AUTO_TEST_CASE(testIterativeBootstrapRetries) {

// Create the CDS spread helpers.
vector<ext::shared_ptr<DefaultProbabilityHelper> > instruments;
for (auto it = cdsSpreads.begin(); it != cdsSpreads.end(); ++it) {
for (auto & cdsSpread : cdsSpreads) {
instruments.push_back(ext::make_shared<SpreadCdsHelper>(
it->second, it->first, settlementDays, calendar,
cdsSpread.second, cdsSpread.first, settlementDays, calendar,
frequency, paymentConvention, rule, dayCounter, recoveryRate, usdYts, true, true, Date(),
lastPeriodDayCounter));
}
Expand Down
6 changes: 3 additions & 3 deletions test-suite/piecewiseyieldcurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1434,9 +1434,9 @@ BOOST_AUTO_TEST_CASE(testIterativeBootstrapRetries) {

// Create the FX swap rate helpers for the ARS in USD curve.
vector<ext::shared_ptr<RateHelper> > instruments;
for (auto it = arsFwdPoints.begin(); it != arsFwdPoints.end(); ++it) {
Handle<Quote> arsFwd(ext::make_shared<SimpleQuote>(it->second));
instruments.push_back(ext::make_shared<FxSwapRateHelper>(arsFwd, arsSpot, it->first, 2,
for (auto & arsFwdPoint : arsFwdPoints) {
Handle<Quote> arsFwd(ext::make_shared<SimpleQuote>(arsFwdPoint.second));
instruments.push_back(ext::make_shared<FxSwapRateHelper>(arsFwd, arsSpot, arsFwdPoint.first, 2,
UnitedStates(UnitedStates::GovernmentBond), Following, false, true, usdYts));
}

Expand Down

0 comments on commit 3d45b9a

Please sign in to comment.