Skip to content

Commit

Permalink
Merge d3985b9 into d06527e
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio committed Jul 21, 2020
2 parents d06527e + d3985b9 commit 770fb90
Show file tree
Hide file tree
Showing 151 changed files with 665 additions and 766 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
@@ -1,5 +1,5 @@
---
Checks: '-*,readability-*,bugprone-*,misc-*,performance-*,modernize-redundant-void-arg,modernize-deprecated-headers,-readability-else-after-return,-readability-named-parameter,-readability-braces-around-statements,-readability-inconsistent-declaration-parameter-name,-misc-macro-parentheses,-misc-incorrect-roundings,-misc-unused-parameters'
Checks: '-*,readability-*,bugprone-*,misc-*,performance-*,modernize-redundant-void-arg,modernize-deprecated-headers,-readability-else-after-return,-readability-named-parameter,-readability-braces-around-statements,-readability-inconsistent-declaration-parameter-name,-readability-isolate-declaration,-readability-magic-numbers,-readability-convert-member-functions-to-static,-bugprone-macro-parentheses,-bugprone-narrowing-conversions,-bugprone-incorrect-roundings,-bugprone-branch-clone,-misc-non-private-member-variables-in-classes,-misc-unused-parameters'
WarningsAsErrors: ''
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tidy.yml
Expand Up @@ -5,7 +5,7 @@ on:
- '**'
jobs:
check:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup
Expand Down
11 changes: 11 additions & 0 deletions Examples/MultidimIntegral/MultidimIntegral.cpp
Expand Up @@ -52,6 +52,9 @@ struct integrand {
};

int main() {

try {

std::cout << std::endl;

/*
Expand Down Expand Up @@ -94,4 +97,12 @@ int main() {
<< endl;

return 0;

} catch (std::exception& e) {
std::cerr << e.what() << std::endl;
return 1;
} catch (...) {
std::cerr << "unknown error" << std::endl;
return 1;
}
}
4 changes: 2 additions & 2 deletions ql/cashflows/capflooredcoupon.hpp
Expand Up @@ -88,9 +88,9 @@ namespace QuantLib {
void setPricer(
const ext::shared_ptr<FloatingRateCouponPricer>& pricer);

const ext::shared_ptr<FloatingRateCoupon> underlying() { return underlying_; }
ext::shared_ptr<FloatingRateCoupon> underlying() { return underlying_; }

protected:
protected:
// data
ext::shared_ptr<FloatingRateCoupon> underlying_;
bool isCapped_, isFloored_;
Expand Down
6 changes: 3 additions & 3 deletions ql/cashflows/conundrumpricer.hpp
Expand Up @@ -257,10 +257,10 @@ namespace QuantLib {
Real precision = 1.0e-6,
Real hardUpperLimit = QL_MAX_REAL);

Real upperLimit() { return upperLimit_; }
Real stdDeviations() { return stdDeviationsForUpperLimit_; }
Real upperLimit() const { return upperLimit_; }
Real stdDeviations() const { return stdDeviationsForUpperLimit_; }

//private:
// private:
class Function {
public:
typedef Real argument_type;
Expand Down
4 changes: 1 addition & 3 deletions ql/cashflows/rangeaccrual.hpp
Expand Up @@ -68,9 +68,7 @@ namespace QuantLib {
const std::vector<Real>& observationTimes() const {
return observationTimes_;
}
const ext::shared_ptr<Schedule> observationsSchedule() const {
return observationsSchedule_;
}
ext::shared_ptr<Schedule> observationsSchedule() const { return observationsSchedule_; }

Real priceWithoutOptionality(
const Handle<YieldTermStructure>& discountCurve) const;
Expand Down
2 changes: 1 addition & 1 deletion ql/currencies/exchangeratemanager.cpp
Expand Up @@ -30,7 +30,7 @@ namespace QuantLib {
struct valid_at {
Date d;
explicit valid_at(const Date& d) : d(d) {}
bool operator()(const ExchangeRateManager::Entry& e) {
bool operator()(const ExchangeRateManager::Entry& e) const {
return d >= e.startDate && d <= e.endDate;
}
};
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/averageois/arithmeticaverageois.hpp
Expand Up @@ -73,7 +73,7 @@ namespace QuantLib {
const DayCounter& fixedDayCount() { return fixedDC_; }

const ext::shared_ptr<OvernightIndex>& overnightIndex() { return overnightIndex_; }
Spread spread() { return spread_; }
Spread spread() const { return spread_; }

const Leg& fixedLeg() const { return legs_[0]; }
const Leg& overnightLeg() const { return legs_[1]; }
Expand Down
Expand Up @@ -337,13 +337,12 @@ namespace QuantLib {
Real inPrice;

//adapt Vanilla delta
if(adaptVanDelta_ == true){
if (adaptVanDelta_) {
outPrice += lambda*(bsPriceWithSmile_ - vanillaOption);
//capfloored by (0, vanilla)
outPrice = std::max(0.0, std::min(bsPriceWithSmile_, outPrice));
inPrice = bsPriceWithSmile_ - outPrice;
}
else{
} else {
//capfloored by (0, vanilla)
outPrice = std::max(0.0, std::min(vanillaOption, outPrice));
inPrice = vanillaOption - outPrice;
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/basismodels/swaptioncfs.hpp
Expand Up @@ -81,7 +81,7 @@ namespace QuantLib {
bool contTenorSpread = true);
SwaptionCashFlows(){}; // allow default constructor which does nothing
// inspectors
inline const ext::shared_ptr<Swaption> swaption() const { return swaption_; }
inline ext::shared_ptr<Swaption> swaption() const { return swaption_; }
inline const std::vector<Real>& exerciseTimes() const { return exerciseTimes_; }
};

Expand Down
3 changes: 2 additions & 1 deletion ql/experimental/callablebonds/callablebond.cpp
Expand Up @@ -426,7 +426,8 @@ namespace QuantLib {
void CallableFixedRateBond::setupArguments(
PricingEngine::arguments* args) const {

Bond::setupArguments(args);
CallableBond::setupArguments(args);

CallableBond::arguments* arguments =
dynamic_cast<CallableBond::arguments*>(args);

Expand Down
3 changes: 1 addition & 2 deletions ql/experimental/callablebonds/callablebond.hpp
Expand Up @@ -123,7 +123,6 @@ namespace QuantLib {
Frequency frequency,
Real bump=2e-4);
//@}
virtual void setupArguments(PricingEngine::arguments*) const {}

protected:
CallableBond(Natural settlementDays,
Expand Down Expand Up @@ -221,7 +220,7 @@ namespace QuantLib {
const CallabilitySchedule& putCallSchedule
= CallabilitySchedule());

virtual void setupArguments(PricingEngine::arguments* args) const;
void setupArguments(PricingEngine::arguments* args) const;

private:
//! accrued interest used internally, where includeToday = false
Expand Down
9 changes: 5 additions & 4 deletions ql/experimental/catbonds/catbond.hpp
Expand Up @@ -50,10 +50,11 @@ namespace QuantLib {
virtual void setupArguments(PricingEngine::arguments*) const;
virtual void fetchResults(const PricingEngine::results*) const;

Real lossProbability() { return lossProbability_; }
Real expectedLoss() { return expectedLoss_; }
Real exhaustionProbability() { return exhaustionProbability_; }
protected:
Real lossProbability() const { return lossProbability_; }
Real expectedLoss() const { return expectedLoss_; }
Real exhaustionProbability() const { return exhaustionProbability_; }

protected:
ext::shared_ptr<NotionalRisk> notionalRisk_;

mutable Real lossProbability_;
Expand Down
4 changes: 2 additions & 2 deletions ql/experimental/commodities/commodityindex.hpp
Expand Up @@ -78,7 +78,7 @@ namespace QuantLib {
IndexManager::instance().setHistory(tag, quotes_);
}

void clearQuotes();
void clearQuotes() const;
//! returns TRUE if the quote date is valid
bool isValidQuoteDate(const Date& quoteDate) const;
bool empty() const;
Expand Down Expand Up @@ -192,7 +192,7 @@ namespace QuantLib {
IndexManager::instance().setHistory(tag, quotes_);
}

inline void CommodityIndex::clearQuotes() {
inline void CommodityIndex::clearQuotes() const {
IndexManager::instance().clearHistory(name());
}

Expand Down
3 changes: 2 additions & 1 deletion ql/experimental/commodities/energyfuture.hpp
Expand Up @@ -42,7 +42,8 @@ namespace QuantLib {
//Integer buySell{} const { return buySell_; }
Quantity quantity() const { return quantity_; }
const CommodityUnitCost& tradePrice() const { return tradePrice_; }
const ext::shared_ptr<CommodityIndex> index() const { return index_; }
ext::shared_ptr<CommodityIndex> index() const { return index_; }

protected:
void performCalculations() const;
Integer buySell_;
Expand Down
4 changes: 2 additions & 2 deletions ql/experimental/coupons/strippedcapflooredcoupon.hpp
Expand Up @@ -58,9 +58,9 @@ namespace QuantLib {

void setPricer(const ext::shared_ptr<FloatingRateCouponPricer>& pricer);

const ext::shared_ptr<CappedFlooredCoupon> underlying() { return underlying_; }
ext::shared_ptr<CappedFlooredCoupon> underlying() { return underlying_; }

protected:
protected:
ext::shared_ptr<CappedFlooredCoupon> underlying_;

};
Expand Down
4 changes: 1 addition & 3 deletions ql/experimental/coupons/subperiodcoupons.hpp
Expand Up @@ -72,9 +72,7 @@ namespace QuantLib {
return observationTimes_;
}

const ext::shared_ptr<Schedule> observationsSchedule() const {
return observationsSchedule_;
}
ext::shared_ptr<Schedule> observationsSchedule() const { return observationsSchedule_; }

//! \name Visitability
//@{
Expand Down
4 changes: 2 additions & 2 deletions ql/experimental/coupons/swapspreadindex.hpp
Expand Up @@ -49,8 +49,8 @@ namespace QuantLib {
//@{
ext::shared_ptr<SwapIndex> swapIndex1() { return swapIndex1_; }
ext::shared_ptr<SwapIndex> swapIndex2() { return swapIndex2_; }
Real gearing1() { return gearing1_; }
Real gearing2() { return gearing2_; }
Real gearing1() const { return gearing1_; }
Real gearing2() const { return gearing2_; }
//@}


Expand Down
4 changes: 2 additions & 2 deletions ql/experimental/credit/binomiallossmodel.hpp
Expand Up @@ -111,7 +111,7 @@ namespace QuantLib {
Real percentile(const Date& d, Real percentile) const;
Real expectedShortfall(const Date&d, Real percentile) const;
Real expectedTrancheLoss(const Date& d) const;
protected:

// Model internal workings ----------------
//! Average loss per credit.
Real averageLoss(const Date&, const std::vector<Real>& reminingNots,
Expand Down Expand Up @@ -143,7 +143,7 @@ namespace QuantLib {
const std::vector<Real>& bsktNots,
const std::vector<Real>& uncondDefProbInv,
const std::vector<Real>& mktFactor) const;
protected:

const ext::shared_ptr<LLM> copula_;

// cached arguments:
Expand Down
8 changes: 4 additions & 4 deletions ql/experimental/credit/cdo.hpp
Expand Up @@ -133,10 +133,10 @@ namespace QuantLib {
Size nBuckets,
const Period& integrationStep = Period(10, Years));

Real nominal() { return nominal_; }
Real lgd() { return lgd_; }
Real attachment () { return attachment_; }
Real detachment () { return detachment_; }
Real nominal() const { return nominal_; }
Real lgd() const { return lgd_; }
Real attachment() const { return attachment_; }
Real detachment() const { return detachment_; }
std::vector<Real> nominals() { return nominals_; }
Size size() { return basket_.size(); }

Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/credit/defaultevent.hpp
Expand Up @@ -109,7 +109,7 @@ namespace QuantLib {
// Settlement information:
const Date& settleDate = Null<Date>(),
Real recoveryRate = 0.4);
public:

Date date() const;
bool isRestructuring() const { return eventType_.isRestructuring(); }
bool isDefault() const { return !isRestructuring();}
Expand Down
7 changes: 4 additions & 3 deletions ql/experimental/credit/defaultprobabilitylatentmodel.hpp
Expand Up @@ -94,13 +94,13 @@ namespace QuantLib {
/* To interface with loss models. It is possible to change the basket
since there are no cached magnitudes.
*/
void resetBasket(const ext::shared_ptr<Basket> basket) const {
void resetBasket(const ext::shared_ptr<Basket>& basket) const {
basket_ = basket;
// in the future change 'size' to 'liveSize'
QL_REQUIRE(basket_->size() == factorWeights_.size(),
"Incompatible new basket and model sizes.");
}
public:

/*! Returns the probability of default of a given name conditional on
the realization of a given set of values of the model independent
factors. The date at which the probability is given is implicit in the
Expand Down Expand Up @@ -129,7 +129,8 @@ namespace QuantLib {
}
protected:
void update() {
if(basket_) basket_->notifyObservers();
if (basket_ != 0)
basket_->notifyObservers();
LatentModel<copulaPolicy>::update();
}
public:// open since users access it for performance on joint integrations.
Expand Down

0 comments on commit 770fb90

Please sign in to comment.