Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
quantlib 1.29
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Apr 28, 2023
1 parent daa458b commit c8f739c
Show file tree
Hide file tree
Showing 1,200 changed files with 23,886 additions and 17,851 deletions.
30 changes: 1 addition & 29 deletions include/ql/auto_link.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,6 @@
#include <ql/version.hpp>
#include <boost/config.hpp>

// select toolset:
#if (_MSC_VER >= 1920)
# define QL_LIB_TOOLSET "vc142"
#elif (_MSC_VER >= 1910)
# define QL_LIB_TOOLSET "vc141"
#elif (_MSC_VER >= 1900)
# define QL_LIB_TOOLSET "vc140"
#elif (_MSC_VER >= 1800)
# define QL_LIB_TOOLSET "vc120"
#elif (_MSC_VER >= 1700)
# define QL_LIB_TOOLSET "vc110"
#elif (_MSC_VER >= 1600)
# define QL_LIB_TOOLSET "vc100"
#else
# error "unsupported Microsoft compiler"
#endif

#ifdef _M_X64
# define QL_LIB_PLATFORM "-x64"
#else
Expand Down Expand Up @@ -71,22 +54,11 @@
# endif
#endif

#define QL_LIB_NAME "QuantLib-" QL_LIB_TOOLSET QL_LIB_PLATFORM QL_LIB_THREAD_OPT QL_LIB_RT_OPT ".lib"
#define QL_LIB_NAME "QuantLib" QL_LIB_PLATFORM QL_LIB_THREAD_OPT QL_LIB_RT_OPT ".lib"

#pragma comment(lib, QL_LIB_NAME)
#ifdef BOOST_LIB_DIAGNOSTIC
# pragma message("Will (need to) link to lib file: " QL_LIB_NAME)
#endif

/* Also, these Boost libraries might be needed */
#if defined(QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN) || defined(QL_ENABLE_SINGLETON_THREAD_SAFE_INIT)
# define BOOST_LIB_NAME boost_system
# include <boost/config/auto_link.hpp>
# undef BOOST_LIB_NAME
# define BOOST_LIB_NAME boost_thread
# include <boost/config/auto_link.hpp>
# undef BOOST_LIB_NAME
#endif


#endif
15 changes: 7 additions & 8 deletions include/ql/auto_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,19 @@
FOR A PARTICULAR PURPOSE. See the license for more details.
*/

/*! \file auto_ptr.hpp
\brief Facilities to switch from auto_ptr to unique_ptr
*/

#ifndef quantlib_auto_ptr_hpp
#define quantlib_auto_ptr_hpp

#include <ql/qldefines.hpp>

#if defined(QL_USE_STD_UNIQUE_PTR)
#pragma message("Warning: the deprecated QL_UNIQUE_OR_AUTO_PTR macro is no longer used. Replace it with std::unique_ptr.")
#pragma message(" For the time being, the QL_USE_STD_UNIQUE_PTR macro is set to 1. However, do not check for it, since it will disappear in a future release.")
#pragma message(" This file will also disappear in a future release; do not include it.")

/*! \deprecated Use std::unique_ptr instead.
Deprecated in version 1.27
*/
#define QL_UNIQUE_OR_AUTO_PTR std::unique_ptr
#else
#define QL_UNIQUE_OR_AUTO_PTR std::auto_ptr
#endif


#endif
Expand Down
27 changes: 20 additions & 7 deletions include/ql/cashflow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,17 @@ namespace QuantLib {
*/
class CashFlow : public Event {
public:
virtual ~CashFlow() {}
~CashFlow() override = default;
//! \name Event interface
//@{
//! \note This is inherited from the event class
virtual Date date() const = 0;
Date date() const override = 0;
//! returns true if an event has already occurred before a date
/*! overloads Event::hasOccurred in order to take
Settings::includeTodaysCashflows in account
*/
bool hasOccurred(
const Date& refDate = Date(),
boost::optional<bool> includeRefDate = boost::none) const;
bool hasOccurred(const Date& refDate = Date(),
boost::optional<bool> includeRefDate = boost::none) const override;
//@}
//! \name CashFlow interface
//@{
Expand All @@ -58,14 +57,14 @@ namespace QuantLib {
*/
virtual Real amount() const = 0;
//! returns the date that the cash flow trades exCoupon
virtual Date exCouponDate() const {return Date();};
virtual Date exCouponDate() const { return {}; };
//! returns true if the cashflow is trading ex-coupon on the refDate
bool tradingExCoupon(const Date& refDate = Date()) const;

//@}
//! \name Visitability
//@{
virtual void accept(AcyclicVisitor&);
void accept(AcyclicVisitor&) override;
//@}
};

Expand All @@ -74,8 +73,22 @@ namespace QuantLib {

template <>
struct earlier_than<CashFlow> {
/*! \deprecated Use `auto` or `decltype` instead.
Deprecated in version 1.29.
*/
QL_DEPRECATED
typedef CashFlow first_argument_type;

/*! \deprecated Use `auto` or `decltype` instead.
Deprecated in version 1.29.
*/
QL_DEPRECATED
typedef CashFlow second_argument_type;

/*! \deprecated Use `auto` or `decltype` instead.
Deprecated in version 1.29.
*/
QL_DEPRECATED
typedef bool result_type;

bool operator()(const CashFlow& c1,
Expand Down
3 changes: 3 additions & 0 deletions include/ql/cashflows/all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@
#include <ql/cashflows/lineartsrpricer.hpp>
#include <ql/cashflows/overnightindexedcoupon.hpp>
#include <ql/cashflows/rangeaccrual.hpp>
#include <ql/cashflows/rateaveraging.hpp>
#include <ql/cashflows/replication.hpp>
#include <ql/cashflows/simplecashflow.hpp>
#include <ql/cashflows/subperiodcoupon.hpp>
#include <ql/cashflows/timebasket.hpp>
#include <ql/cashflows/yoyinflationcoupon.hpp>
#include <ql/cashflows/zeroinflationcashflow.hpp>

13 changes: 6 additions & 7 deletions include/ql/cashflows/averagebmacoupon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,22 @@ namespace QuantLib {
//! \name FloatingRateCoupon interface
//@{
//! not applicable here; use fixingDates() instead
Date fixingDate() const;
Date fixingDate() const override;
//! fixing dates of the rates to be averaged
std::vector<Date> fixingDates() const;

//! not applicable here; use indexFixings() instead
Rate indexFixing() const;
Rate indexFixing() const override;
//! fixings of the underlying index to be averaged
std::vector<Rate> indexFixings() const;

//! not applicable here
Rate convexityAdjustment() const;
Rate convexityAdjustment() const override;
//@}

//! \name Visitability
//@{
void accept(AcyclicVisitor&);
void accept(AcyclicVisitor&) override;
//@}
private:
Schedule fixingSchedule_;
Expand All @@ -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 All @@ -98,7 +97,7 @@ namespace QuantLib {
ext::shared_ptr<BMAIndex> index_;
std::vector<Real> notionals_;
DayCounter paymentDayCounter_;
BusinessDayConvention paymentAdjustment_;
BusinessDayConvention paymentAdjustment_ = Following;
std::vector<Real> gearings_;
std::vector<Spread> spreads_;
};
Expand Down
41 changes: 20 additions & 21 deletions include/ql/cashflows/capflooredcoupon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ namespace QuantLib {
Rate floor = Null<Rate>());
//! \name Coupon interface
//@{
Rate rate() const;
Rate convexityAdjustment() const;
Rate rate() const override;
Rate convexityAdjustment() const override;
//@}
//! cap
Rate cap() const;
Expand All @@ -76,24 +76,23 @@ namespace QuantLib {
//@}
//! \name Observer interface
//@{
void update();
void update() override;
//@}
//! \name Visitability
//@{
virtual void accept(AcyclicVisitor&);
void accept(AcyclicVisitor&) override;

bool isCapped() const {return isCapped_;}
bool isFloored() const {return isFloored_;}

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

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_;
bool isCapped_ = false, isFloored_ = false;
Rate cap_, floor_;
};

Expand All @@ -113,16 +112,16 @@ namespace QuantLib {
const Date& refPeriodStart = Date(),
const Date& refPeriodEnd = Date(),
const DayCounter& dayCounter = DayCounter(),
bool isInArrears = false)
bool isInArrears = false,
const Date& exCouponDate = Date())
: CappedFlooredCoupon(ext::shared_ptr<FloatingRateCoupon>(new
IborCoupon(paymentDate, nominal, startDate, endDate, fixingDays,
index, gearing, spread, refPeriodStart, refPeriodEnd,
dayCounter, isInArrears)), cap, floor) {}
dayCounter, isInArrears, exCouponDate)), cap, floor) {}

virtual void accept(AcyclicVisitor& v) {
Visitor<CappedFlooredIborCoupon>* v1 =
dynamic_cast<Visitor<CappedFlooredIborCoupon>*>(&v);
if (v1 != 0)
void accept(AcyclicVisitor& v) override {
auto* v1 = dynamic_cast<Visitor<CappedFlooredIborCoupon>*>(&v);
if (v1 != nullptr)
v1->visit(*this);
else
CappedFlooredCoupon::accept(v);
Expand All @@ -145,16 +144,16 @@ namespace QuantLib {
const Date& refPeriodStart = Date(),
const Date& refPeriodEnd = Date(),
const DayCounter& dayCounter = DayCounter(),
bool isInArrears = false)
bool isInArrears = false,
const Date& exCouponDate = Date())
: CappedFlooredCoupon(ext::shared_ptr<FloatingRateCoupon>(new
CmsCoupon(paymentDate, nominal, startDate, endDate, fixingDays,
index, gearing, spread, refPeriodStart, refPeriodEnd,
dayCounter, isInArrears)), cap, floor) {}
dayCounter, isInArrears, exCouponDate)), cap, floor) {}

virtual void accept(AcyclicVisitor& v) {
Visitor<CappedFlooredCmsCoupon>* v1 =
dynamic_cast<Visitor<CappedFlooredCmsCoupon>*>(&v);
if (v1 != 0)
void accept(AcyclicVisitor& v) override {
auto* v1 = dynamic_cast<Visitor<CappedFlooredCmsCoupon>*>(&v);
if (v1 != nullptr)
v1->visit(*this);
else
CappedFlooredCoupon::accept(v);
Expand Down
9 changes: 6 additions & 3 deletions include/ql/cashflows/capflooredinflationcoupon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace QuantLib {
//! \name augmented Coupon interface
//@{
//! swap(let) rate
Rate rate() const;
Rate rate() const override;
//! cap
Rate cap() const;
//! floor
Expand All @@ -109,14 +109,17 @@ namespace QuantLib {

//! \name Observer interface
//@{
void update();
void update() override;
//@}

//! \name Visitability
//@{
virtual void accept(AcyclicVisitor& v);
void accept(AcyclicVisitor& v) override;
//@}

//! this returns the expected rate before cap and floor are applied
Rate underlyingRate() const;

bool isCapped() const { return isCapped_; }
bool isFloored() const { return isFloored_; }

Expand Down
22 changes: 16 additions & 6 deletions include/ql/cashflows/cashflows.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,11 @@ namespace QuantLib {
/*! \todo add tests */
class CashFlows {
private:
CashFlows();
CashFlows(const CashFlows&);

class IrrFinder {
public:
IrrFinder(const Leg& leg,
Real npv,
const DayCounter& dayCounter,
DayCounter dayCounter,
Compounding comp,
Frequency freq,
bool includeSettlementDateFlows,
Expand All @@ -68,6 +65,9 @@ namespace QuantLib {
Date settlementDate_, npvDate_;
};
public:
CashFlows() = delete;
CashFlows(const CashFlows&) = delete;

//! \name Date functions
//@{
static Date startDate(const Leg& leg);
Expand Down Expand Up @@ -183,11 +183,21 @@ namespace QuantLib {
Date settlementDate = Date(),
Date npvDate = Date());

//@{
//! NPV and BPS of the cash flows.
/*! The NPV and BPS of the cash flows calculated
together for performance reason
*/
static std::pair<Real, Real> npvbps(const Leg& leg,
const YieldTermStructure& discountCurve,
bool includeSettlementDateFlows,
Date settlementDate = Date(),
Date npvDate = Date());

//! NPV and BPS of the cash flows.
/*! \deprecated Use the overload returning a pair of Reals.
Deprecated in version 1.29.
*/
QL_DEPRECATED
static void npvbps(const Leg& leg,
const YieldTermStructure& discountCurve,
bool includeSettlementDateFlows,
Expand Down Expand Up @@ -257,7 +267,7 @@ namespace QuantLib {
Date npvDate = Date());
//! Implied internal rate of return.
/*! The function verifies
the theoretical existance of an IRR and numerically
the theoretical existence of an IRR and numerically
establishes the IRR to the desired precision.
*/
static Rate yield(const Leg& leg,
Expand Down
Loading

0 comments on commit c8f739c

Please sign in to comment.