Skip to content

Commit

Permalink
Merge b4c21a2 into 7cbc755
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio committed Feb 11, 2021
2 parents 7cbc755 + b4c21a2 commit af2e4bb
Show file tree
Hide file tree
Showing 946 changed files with 9,386 additions and 10,044 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,modernize-use-override,modernize-use-auto,modernize-use-nullptr,modernize-use-default-member-init,modernize-use-equals-default,modernize-use-equals-delete,-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-branch-clone,-misc-non-private-member-variables-in-classes,-misc-unused-parameters'
Checks: '-*,readability-*,bugprone-*,misc-*,performance-*,modernize-redundant-void-arg,modernize-deprecated-headers,modernize-use-override,modernize-use-auto,modernize-use-nullptr,modernize-use-default-member-init,modernize-use-equals-default,modernize-use-equals-delete,modernize-pass-by-value,-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-branch-clone,-misc-non-private-member-variables-in-classes,-misc-unused-parameters'
WarningsAsErrors: ''
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
Expand Down
12 changes: 6 additions & 6 deletions Examples/GlobalOptimizer/GlobalOptimizer.cpp
Expand Up @@ -21,17 +21,16 @@
#ifdef BOOST_MSVC
# include <ql/auto_link.hpp>
#endif
#include <ql/math/optimization/differentialevolution.hpp>
#include <ql/math/optimization/simulatedannealing.hpp>
#include <ql/experimental/math/fireflyalgorithm.hpp>
#include <ql/experimental/math/hybridsimulatedannealing.hpp>
#include <ql/experimental/math/particleswarmoptimization.hpp>
#include <ql/functional.hpp>


#include <ql/math/optimization/differentialevolution.hpp>
#include <ql/math/optimization/simulatedannealing.hpp>
#include <ql/tuple.hpp>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <utility>

using namespace QuantLib;

Expand Down Expand Up @@ -143,7 +142,8 @@ class TestFunction : public CostFunction {
public:
typedef ext::function<Real(const Array&)> RealFunc;
typedef ext::function<Disposable<Array>(const Array&)> ArrayFunc;
explicit TestFunction(const RealFunc & f, const ArrayFunc & fs = ArrayFunc()) : f_(f), fs_(fs) {}
explicit TestFunction(RealFunc f, ArrayFunc fs = ArrayFunc())
: f_(std::move(f)), fs_(std::move(fs)) {}
explicit TestFunction(Real (*f)(const Array&), Disposable<Array> (*fs)(const Array&) = nullptr)
: f_(f), fs_(fs) {}
~TestFunction() override = default;
Expand Down
7 changes: 3 additions & 4 deletions ql/cashflows/averagebmacoupon.cpp
Expand Up @@ -21,6 +21,7 @@
#include <ql/cashflows/averagebmacoupon.hpp>
#include <ql/cashflows/couponpricer.hpp>
#include <ql/utilities/vectors.hpp>
#include <utility>

namespace QuantLib {

Expand Down Expand Up @@ -161,10 +162,8 @@ namespace QuantLib {
}



AverageBMALeg::AverageBMALeg(const Schedule& schedule,
const ext::shared_ptr<BMAIndex>& index)
: schedule_(schedule), index_(index), paymentAdjustment_(Following) {}
AverageBMALeg::AverageBMALeg(Schedule schedule, ext::shared_ptr<BMAIndex> index)
: schedule_(std::move(schedule)), index_(std::move(index)), paymentAdjustment_(Following) {}

AverageBMALeg& AverageBMALeg::withNotionals(Real notional) {
notionals_ = std::vector<Real>(1,notional);
Expand Down
3 changes: 1 addition & 2 deletions ql/cashflows/averagebmacoupon.hpp
Expand Up @@ -82,8 +82,7 @@ namespace QuantLib {
//! helper class building a sequence of average BMA coupons
class AverageBMALeg {
public:
AverageBMALeg(const Schedule& schedule,
const ext::shared_ptr<BMAIndex>& index);
AverageBMALeg(Schedule schedule, ext::shared_ptr<BMAIndex> index);
AverageBMALeg& withNotionals(Real notional);
AverageBMALeg& withNotionals(const std::vector<Real>& notionals);
AverageBMALeg& withPaymentDayCounter(const DayCounter&);
Expand Down
15 changes: 7 additions & 8 deletions ql/cashflows/cashflows.cpp
Expand Up @@ -22,13 +22,14 @@

#include <ql/cashflows/cashflows.hpp>
#include <ql/cashflows/coupon.hpp>
#include <ql/termstructures/yield/flatforward.hpp>
#include <ql/cashflows/couponpricer.hpp>
#include <ql/math/solvers1d/brent.hpp>
#include <ql/math/solvers1d/newtonsafe.hpp>
#include <ql/cashflows/couponpricer.hpp>
#include <ql/patterns/visitor.hpp>
#include <ql/quotes/simplequote.hpp>
#include <ql/termstructures/yield/flatforward.hpp>
#include <ql/termstructures/yield/zerospreadedtermstructure.hpp>
#include <utility>

namespace QuantLib {

Expand Down Expand Up @@ -728,17 +729,15 @@ namespace QuantLib {

CashFlows::IrrFinder::IrrFinder(const Leg& leg,
Real npv,
const DayCounter& dayCounter,
DayCounter dayCounter,
Compounding comp,
Frequency freq,
bool includeSettlementDateFlows,
Date settlementDate,
Date npvDate)
: leg_(leg), npv_(npv),
dayCounter_(dayCounter), compounding_(comp), frequency_(freq),
includeSettlementDateFlows_(includeSettlementDateFlows),
settlementDate_(settlementDate),
npvDate_(npvDate) {
: leg_(leg), npv_(npv), dayCounter_(std::move(dayCounter)), compounding_(comp),
frequency_(freq), includeSettlementDateFlows_(includeSettlementDateFlows),
settlementDate_(settlementDate), npvDate_(npvDate) {

if (settlementDate_ == Date())
settlementDate_ = Settings::instance().evaluationDate();
Expand Down
2 changes: 1 addition & 1 deletion ql/cashflows/cashflows.hpp
Expand Up @@ -47,7 +47,7 @@ namespace QuantLib {
public:
IrrFinder(const Leg& leg,
Real npv,
const DayCounter& dayCounter,
DayCounter dayCounter,
Compounding comp,
Frequency freq,
bool includeSettlementDateFlows,
Expand Down
14 changes: 6 additions & 8 deletions ql/cashflows/cmscoupon.cpp
Expand Up @@ -18,10 +18,11 @@
or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
*/

#include <ql/cashflows/cmscoupon.hpp>
#include <ql/cashflows/cashflowvectors.hpp>
#include <ql/cashflows/capflooredcoupon.hpp>
#include <ql/cashflows/cashflowvectors.hpp>
#include <ql/cashflows/cmscoupon.hpp>
#include <ql/indexes/swapindex.hpp>
#include <utility>

namespace QuantLib {

Expand Down Expand Up @@ -53,12 +54,9 @@ namespace QuantLib {
}



CmsLeg::CmsLeg(const Schedule& schedule,
const ext::shared_ptr<SwapIndex>& swapIndex)
: schedule_(schedule), swapIndex_(swapIndex),
paymentAdjustment_(Following),
inArrears_(false), zeroPayments_(false) {}
CmsLeg::CmsLeg(Schedule schedule, ext::shared_ptr<SwapIndex> swapIndex)
: schedule_(std::move(schedule)), swapIndex_(std::move(swapIndex)),
paymentAdjustment_(Following), inArrears_(false), zeroPayments_(false) {}

CmsLeg& CmsLeg::withNotionals(Real notional) {
notionals_ = std::vector<Real>(1, notional);
Expand Down
3 changes: 1 addition & 2 deletions ql/cashflows/cmscoupon.hpp
Expand Up @@ -69,8 +69,7 @@ namespace QuantLib {
//! helper class building a sequence of capped/floored cms-rate coupons
class CmsLeg {
public:
CmsLeg(const Schedule& schedule,
const ext::shared_ptr<SwapIndex>& swapIndex);
CmsLeg(Schedule schedule, ext::shared_ptr<SwapIndex> swapIndex);
CmsLeg& withNotionals(Real notional);
CmsLeg& withNotionals(const std::vector<Real>& notionals);
CmsLeg& withPaymentDayCounter(const DayCounter&);
Expand Down
54 changes: 25 additions & 29 deletions ql/cashflows/conundrumpricer.cpp
Expand Up @@ -21,20 +21,21 @@
\brief
*/

#include <ql/cashflows/cmscoupon.hpp>
#include <ql/cashflows/conundrumpricer.hpp>
#include <ql/math/integrals/kronrodintegral.hpp>
#include <ql/functional.hpp>
#include <ql/indexes/interestrateindex.hpp>
#include <ql/indexes/swapindex.hpp>
#include <ql/instruments/vanillaswap.hpp>
#include <ql/math/distributions/normaldistribution.hpp>
#include <ql/pricingengines/blackformula.hpp>
#include <ql/math/integrals/kronrodintegral.hpp>
#include <ql/math/solvers1d/newton.hpp>
#include <ql/pricingengines/blackformula.hpp>
#include <ql/quotes/simplequote.hpp>
#include <ql/termstructures/volatility/smilesection.hpp>
#include <ql/cashflows/cmscoupon.hpp>
#include <ql/termstructures/yieldtermstructure.hpp>
#include <ql/quotes/simplequote.hpp>
#include <ql/indexes/swapindex.hpp>
#include <ql/indexes/interestrateindex.hpp>
#include <ql/time/schedule.hpp>
#include <ql/instruments/vanillaswap.hpp>
#include <ql/functional.hpp>
#include <utility>

namespace QuantLib {

Expand Down Expand Up @@ -67,15 +68,12 @@ namespace QuantLib {
//===========================================================================//
// HaganPricer //
//===========================================================================//
HaganPricer::HaganPricer(
const Handle<SwaptionVolatilityStructure>& swaptionVol,
GFunctionFactory::YieldCurveModel modelOfYieldCurve,
const Handle<Quote>& meanReversion)
: CmsCouponPricer(swaptionVol),
modelOfYieldCurve_(modelOfYieldCurve),
cutoffForCaplet_(2), cutoffForFloorlet_(0),
meanReversion_(meanReversion) {
registerWith(meanReversion_);
HaganPricer::HaganPricer(const Handle<SwaptionVolatilityStructure>& swaptionVol,
GFunctionFactory::YieldCurveModel modelOfYieldCurve,
Handle<Quote> meanReversion)
: CmsCouponPricer(swaptionVol), modelOfYieldCurve_(modelOfYieldCurve), cutoffForCaplet_(2),
cutoffForFloorlet_(0), meanReversion_(std::move(meanReversion)) {
registerWith(meanReversion_);
}

void HaganPricer::initialize(const FloatingRateCoupon& coupon){
Expand Down Expand Up @@ -226,7 +224,7 @@ namespace QuantLib {

class Spy {
public:
explicit Spy(const ext::function<Real(Real)>& f) : f_(f) {}
explicit Spy(ext::function<Real(Real)> f) : f_(std::move(f)) {}
Real value(Real x){
abscissas.push_back(x);
Real value = f_(x);
Expand Down Expand Up @@ -394,19 +392,18 @@ namespace QuantLib {
//===========================================================================//

NumericHaganPricer::ConundrumIntegrand::ConundrumIntegrand(
const ext::shared_ptr<VanillaOptionPricer>& o,
ext::shared_ptr<VanillaOptionPricer> o,
const ext::shared_ptr<YieldTermStructure>&,
const ext::shared_ptr<GFunction>& gFunction,
ext::shared_ptr<GFunction> gFunction,
Date fixingDate,
Date paymentDate,
Real annuity,
Real forwardValue,
Real strike,
Option::Type optionType)
: vanillaOptionPricer_(o), forwardValue_(forwardValue), annuity_(annuity),
fixingDate_(fixingDate), paymentDate_(paymentDate), strike_(strike),
optionType_(optionType),
gFunction_(gFunction) {}
: vanillaOptionPricer_(std::move(o)), forwardValue_(forwardValue), annuity_(annuity),
fixingDate_(fixingDate), paymentDate_(paymentDate), strike_(strike), optionType_(optionType),
gFunction_(std::move(gFunction)) {}

void NumericHaganPricer::ConundrumIntegrand::setStrike(Real strike) {
strike_ = strike;
Expand Down Expand Up @@ -668,11 +665,10 @@ namespace QuantLib {
// GFunctionWithShifts //
//===========================================================================//

GFunctionFactory::GFunctionWithShifts::GFunctionWithShifts(
const CmsCoupon& coupon,
const Handle<Quote>& meanReversion)
: meanReversion_(meanReversion), calibratedShift_(0.03),
tmpRs_(10000000.0), accuracy_( 1.0e-14) {
GFunctionFactory::GFunctionWithShifts::GFunctionWithShifts(const CmsCoupon& coupon,
Handle<Quote> meanReversion)
: meanReversion_(std::move(meanReversion)), calibratedShift_(0.03), tmpRs_(10000000.0),
accuracy_(1.0e-14) {

const ext::shared_ptr<SwapIndex>& swapIndex = coupon.swapIndex();
const ext::shared_ptr<VanillaSwap>& swap = swapIndex->underlyingSwap(coupon.fixingDate());
Expand Down
29 changes: 13 additions & 16 deletions ql/cashflows/conundrumpricer.hpp
Expand Up @@ -165,8 +165,7 @@ namespace QuantLib {

ext::shared_ptr<ObjectiveFunction> objectiveFunction_;
public:
GFunctionWithShifts(const CmsCoupon& coupon,
const Handle<Quote>& meanReversion);
GFunctionWithShifts(const CmsCoupon& coupon, Handle<Quote> meanReversion);
Real operator()(Real x) override;
Real firstDerivative(Real x) override;
Real secondDerivative(Real x) override;
Expand Down Expand Up @@ -213,10 +212,9 @@ namespace QuantLib {
};

protected:
HaganPricer(
const Handle<SwaptionVolatilityStructure>& swaptionVol,
GFunctionFactory::YieldCurveModel modelOfYieldCurve,
const Handle<Quote>& meanReversion);
HaganPricer(const Handle<SwaptionVolatilityStructure>& swaptionVol,
GFunctionFactory::YieldCurveModel modelOfYieldCurve,
Handle<Quote> meanReversion);
void initialize(const FloatingRateCoupon& coupon) override;

virtual Real optionletPrice(Option::Type optionType,
Expand Down Expand Up @@ -271,16 +269,15 @@ namespace QuantLib {
class ConundrumIntegrand : public Function {
friend class NumericHaganPricer;
public:
ConundrumIntegrand(
const ext::shared_ptr<VanillaOptionPricer>& o,
const ext::shared_ptr<YieldTermStructure>& rateCurve,
const ext::shared_ptr<GFunction>& gFunction,
Date fixingDate,
Date paymentDate,
Real annuity,
Real forwardValue,
Real strike,
Option::Type optionType);
ConundrumIntegrand(ext::shared_ptr<VanillaOptionPricer> o,
const ext::shared_ptr<YieldTermStructure>& rateCurve,
ext::shared_ptr<GFunction> gFunction,
Date fixingDate,
Date paymentDate,
Real annuity,
Real forwardValue,
Real strike,
Option::Type optionType);
Real operator()(Real x) const override;

protected:
Expand Down
16 changes: 8 additions & 8 deletions ql/cashflows/couponpricer.cpp
Expand Up @@ -20,17 +20,18 @@
FOR A PARTICULAR PURPOSE. See the license for more details.
*/

#include <ql/cashflows/couponpricer.hpp>
#include <ql/cashflows/capflooredcoupon.hpp>
#include <ql/cashflows/digitalcoupon.hpp>
#include <ql/cashflows/couponpricer.hpp>
#include <ql/cashflows/digitalcmscoupon.hpp>
#include <ql/cashflows/digitalcoupon.hpp>
#include <ql/cashflows/digitaliborcoupon.hpp>
#include <ql/cashflows/rangeaccrual.hpp>
#include <ql/experimental/coupons/subperiodcoupons.hpp> /* internal */
#include <ql/experimental/coupons/cmsspreadcoupon.hpp> /* internal */
#include <ql/experimental/coupons/digitalcmsspreadcoupon.hpp> /* internal */
#include <ql/experimental/coupons/cmsspreadcoupon.hpp> /* internal */
#include <ql/experimental/coupons/digitalcmsspreadcoupon.hpp> /* internal */
#include <ql/experimental/coupons/subperiodcoupons.hpp> /* internal */
#include <ql/pricingengines/blackformula.hpp>
#include <ql/termstructures/yieldtermstructure.hpp>
#include <utility>

namespace QuantLib {

Expand Down Expand Up @@ -188,9 +189,8 @@ namespace QuantLib {
private:
ext::shared_ptr<FloatingRateCouponPricer> pricer_;
public:
explicit PricerSetter(
const ext::shared_ptr<FloatingRateCouponPricer>& pricer)
: pricer_(pricer) {}
explicit PricerSetter(ext::shared_ptr<FloatingRateCouponPricer> pricer)
: pricer_(std::move(pricer)) {}

void visit(CashFlow& c) override;
void visit(Coupon& c) override;
Expand Down
23 changes: 11 additions & 12 deletions ql/cashflows/couponpricer.hpp
Expand Up @@ -27,12 +27,13 @@
#ifndef quantlib_coupon_pricer_hpp
#define quantlib_coupon_pricer_hpp

#include <ql/termstructures/volatility/optionlet/optionletvolatilitystructure.hpp>
#include <ql/termstructures/volatility/swaption/swaptionvolstructure.hpp>
#include <ql/indexes/iborindex.hpp>
#include <ql/cashflow.hpp>
#include <ql/indexes/iborindex.hpp>
#include <ql/option.hpp>
#include <ql/quotes/simplequote.hpp>
#include <ql/termstructures/volatility/optionlet/optionletvolatilitystructure.hpp>
#include <ql/termstructures/volatility/swaption/swaptionvolstructure.hpp>
#include <utility>

namespace QuantLib {

Expand Down Expand Up @@ -64,9 +65,8 @@ namespace QuantLib {
class IborCouponPricer : public FloatingRateCouponPricer {
public:
explicit IborCouponPricer(
const Handle<OptionletVolatilityStructure>& v =
Handle<OptionletVolatilityStructure>())
: capletVol_(v) {
Handle<OptionletVolatilityStructure> v = Handle<OptionletVolatilityStructure>())
: capletVol_(std::move(v)) {
registerWith(capletVol_);
}

Expand Down Expand Up @@ -96,9 +96,9 @@ namespace QuantLib {
BlackIborCouponPricer(
const Handle<OptionletVolatilityStructure>& v = Handle<OptionletVolatilityStructure>(),
const TimingAdjustment timingAdjustment = Black76,
const Handle<Quote>& correlation =
Handle<Quote>(ext::shared_ptr<Quote>(new SimpleQuote(1.0))))
: IborCouponPricer(v), timingAdjustment_(timingAdjustment), correlation_(correlation) {
Handle<Quote> correlation = Handle<Quote>(ext::shared_ptr<Quote>(new SimpleQuote(1.0))))
: IborCouponPricer(v), timingAdjustment_(timingAdjustment),
correlation_(std::move(correlation)) {
{ // this additional scope seems required to avoid a misleading-indentation warning
QL_REQUIRE(timingAdjustment_ == Black76 || timingAdjustment_ == BivariateLognormal,
"unknown timing adjustment (code " << timingAdjustment_ << ")");
Expand Down Expand Up @@ -137,9 +137,8 @@ namespace QuantLib {
class CmsCouponPricer : public FloatingRateCouponPricer {
public:
explicit CmsCouponPricer(
const Handle<SwaptionVolatilityStructure>& v =
Handle<SwaptionVolatilityStructure>())
: swaptionVol_(v) {
Handle<SwaptionVolatilityStructure> v = Handle<SwaptionVolatilityStructure>())
: swaptionVol_(std::move(v)) {
registerWith(swaptionVol_);
}

Expand Down

0 comments on commit af2e4bb

Please sign in to comment.