Skip to content

Commit

Permalink
Synchronised with QL 1.36 release candidate, rolled micro version
Browse files Browse the repository at this point in the history
  • Loading branch information
eddelbuettel committed Oct 7, 2024
1 parent 04121c9 commit c5f327c
Show file tree
Hide file tree
Showing 17 changed files with 108 additions and 128 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2024-10-07 Dirk Eddelbuettel <[email protected]>

* DESCRIPTION (Version, Date): Roll micro version and date

* src/ql/time/calendars/poland.?pp: Updated from QuantLib 1.36 (rc)
* src/ql/time/calendars/southkorea.cpp: Idem

* src/ql/*: Small updates from 1.36 (rc) to nine more files

2024-09-03 Dirk Eddelbuettel <[email protected]>

* DESCRIPTION (Authors@R): Added
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: qlcal
Type: Package
Title: R Bindings to the Calendaring Functionality of 'QuantLib'
Version: 0.0.12
Date: 2024-07-23
Version: 0.0.12.1
Date: 2024-10-07
Authors@R: c(person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "[email protected]",
comment = c(ORCID = "0000-0001-6419-907X")),
person("QuantLib Authors", role = "aut"))
Expand Down
1 change: 0 additions & 1 deletion src/Makevars.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ SOURCES = \
ql/utilities/dataformatters.cpp \
ql/utilities/dataparsers.cpp \
ql/errors.cpp \
ql/optional.cpp \
ql/settings.cpp \
calendars.cpp \
dates.cpp \
Expand Down
1 change: 0 additions & 1 deletion src/Makevars.win.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ SOURCES = \
ql/utilities/dataformatters.cpp \
ql/utilities/dataparsers.cpp \
ql/errors.cpp \
ql/optional.cpp \
ql/settings.cpp \
calendars.cpp \
dates.cpp \
Expand Down
2 changes: 1 addition & 1 deletion src/ql/errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace {

#if defined(_MSC_VER) || defined(__BORLANDC__)
#if defined(_MSC_VER)
// allow Visual Studio integration
std::string format(
#ifdef QL_ERROR_LINES
Expand Down
33 changes: 0 additions & 33 deletions src/ql/optional.cpp

This file was deleted.

10 changes: 2 additions & 8 deletions src/ql/optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,16 @@
#include <boost/optional.hpp>
#endif

namespace QuantLib {

namespace ext {
namespace QuantLib::ext {

#if defined(QL_USE_STD_OPTIONAL)
using std::optional; // NOLINT(misc-unused-using-decls)
// here we can assume C++17
inline constexpr const std::nullopt_t& nullopt = std::nullopt;
#else
using boost::optional; // NOLINT(misc-unused-using-decls)
// here we can't
extern const boost::none_t& nullopt;
inline constexpr const boost::none_t& nullopt = boost::none;
#endif

}

}

#endif
4 changes: 1 addition & 3 deletions src/ql/patterns/observable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace QuantLib {
friend class ObservableSettings;
public:
// constructors, assignment, destructor
Observable();
Observable() = default;
Observable(const Observable&);
Observable& operator=(const Observable&);
// delete the move operations because the semantics are not yet clear
Expand Down Expand Up @@ -158,8 +158,6 @@ namespace QuantLib {

// inline definitions

inline Observable::Observable() = default;

inline void ObservableSettings::registerDeferredObservers(const Observable::set_type& observers) {
if (updatesDeferred()) {
deferredObservers_.insert(observers.begin(), observers.end());
Expand Down
16 changes: 0 additions & 16 deletions src/ql/patterns/singleton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,6 @@ namespace QuantLib {

#endif

// backwards compatibility

#if defined(QL_THREAD_KEY)
/*! \deprecated This typedef is obsolete. Do not use it.
Deprecated in version 1.29.
*/
QL_DEPRECATED
typedef QL_THREAD_KEY ThreadKey;
#else
/*! \deprecated This typedef is obsolete. Do not use it.
Deprecated in version 1.29.
*/
QL_DEPRECATED
typedef Integer ThreadKey;
#endif

}

#endif
6 changes: 1 addition & 5 deletions src/ql/shared_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
#include <boost/enable_shared_from_this.hpp>
#endif

namespace QuantLib {

namespace ext {
namespace QuantLib::ext {

#if defined(QL_USE_STD_SHARED_PTR)
using std::shared_ptr; // NOLINT(misc-unused-using-decls)
Expand All @@ -56,8 +54,6 @@ namespace QuantLib {

}

}


#endif

16 changes: 15 additions & 1 deletion src/ql/time/calendar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ namespace QuantLib {
weekend for the given market.
*/
bool isWeekend(Weekday w) const;
/*! Returns <tt>true</tt> iff in the given market, the date is on
or before the first business day for that month.
*/
bool isStartOfMonth(const Date& d) const;
//! first business day of the month to which the given date belongs
Date startOfMonth(const Date& d) const;
/*! Returns <tt>true</tt> iff in the given market, the date is on
or after the last business day for that month.
*/
Expand Down Expand Up @@ -240,8 +246,16 @@ namespace QuantLib {
return impl_->isBusinessDay(_d);
}

inline bool Calendar::isStartOfMonth(const Date& d) const {
return d <= startOfMonth(d);
}

inline Date Calendar::startOfMonth(const Date& d) const {
return adjust(Date::startOfMonth(d), Following);
}

inline bool Calendar::isEndOfMonth(const Date& d) const {
return (d.month() != adjust(d+1).month());
return d >= endOfMonth(d);
}

inline Date Calendar::endOfMonth(const Date& d) const {
Expand Down
34 changes: 30 additions & 4 deletions src/ql/time/calendars/poland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,27 @@
*/

#include <ql/time/calendars/poland.hpp>
#include <ql/errors.hpp>

namespace QuantLib {

Poland::Poland() {
Poland::Poland(Poland::Market market) {
// all calendar instances share the same implementation instance
static ext::shared_ptr<Calendar::Impl> impl(new Poland::Impl);
impl_ = impl;
static auto settlementImpl = ext::make_shared<Poland::SettlementImpl>();
static auto wseImpl = ext::make_shared<Poland::WseImpl>();
switch (market) {
case Settlement:
impl_ = settlementImpl;
break;
case WSE:
impl_ = wseImpl;
break;
default:
QL_FAIL("unknown market");
}
}

bool Poland::Impl::isBusinessDay(const Date& date) const {
bool Poland::SettlementImpl::isBusinessDay(const Date& date) const {
Weekday w = date.weekday();
Day d = date.dayOfMonth(), dd = date.dayOfYear();
Month m = date.month();
Expand Down Expand Up @@ -60,5 +71,20 @@ namespace QuantLib {
return true;
}


bool Poland::WseImpl::isBusinessDay(const Date& date) const {
// Additional holidays for Warsaw Stock Exchange
// see https://www.gpw.pl/session-details
Day d = date.dayOfMonth();
Month m = date.month();

if (
(d == 24 && m == December)
|| (d == 31 && m == December)
) return false; // NOLINT(readability-simplify-boolean-expr)

return SettlementImpl::isBusinessDay(date);
}

}

16 changes: 13 additions & 3 deletions src/ql/time/calendars/poland.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,23 @@ namespace QuantLib {
*/
class Poland : public Calendar {
private:
class Impl final : public Calendar::WesternImpl {
class SettlementImpl : public Calendar::WesternImpl {
public:
std::string name() const override { return "Poland"; }
std::string name() const override { return "Poland Settlement"; }
bool isBusinessDay(const Date&) const override;
};
class WseImpl final : public SettlementImpl {
public:
std::string name() const override { return "Warsaw stock exchange"; }
bool isBusinessDay(const Date&) const override;
};
public:
Poland();
//! PL calendars
enum Market { Settlement, //!< Settlement calendar
WSE, //!< Warsaw stock exchange calendar
};

explicit Poland(Market market = Settlement);
};

}
Expand Down
1 change: 1 addition & 0 deletions src/ql/time/calendars/southkorea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ namespace QuantLib {
// Special temporary holiday
|| (d == 17 && m == August && y == 2020)
|| (d == 2 && m == October && y == 2023)
|| (d == 1 && m == October && y == 2024)

// Harvest Moon Day
|| ((d == 27 || d == 28 || d == 29) && m == September && y == 2004)
Expand Down
32 changes: 14 additions & 18 deletions src/ql/time/date.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ namespace QuantLib {
static Date maxDate();
//! whether the given year is a leap one
static bool isLeap(Year y);
//! first day of the month to which the given date belongs
static Date startOfMonth(const Date& d);
//! whether a date is the first day of its month
static bool isStartOfMonth(const Date& d);
//! last day of the month to which the given date belongs
static Date endOfMonth(const Date& d);
//! whether a date is the last day of its month
Expand Down Expand Up @@ -291,7 +295,7 @@ namespace QuantLib {
#include <unordered_set>
std::unordered_set<Date> set;
Date d = Date(1, Jan, 2020);
Date d = Date(1, Jan, 2020);
set.insert(d);
assert(set.count(d)); // 'd' was added to 'set'
Expand Down Expand Up @@ -370,28 +374,20 @@ namespace QuantLib {

}

#ifdef QL_NULL_AS_FUNCTIONS

//! specialization of Null template for the Date class
template <>
inline Date Null<Date>() {
return {};
}

#else
// inline definitions

template <>
class Null<Date> {
public:
Null() = default;
operator Date() const { return {}; }
};
inline Date Date::startOfMonth(const Date& d) {
Month m = d.month();
Year y = d.year();
return Date(1, m, y);
}

#endif
inline bool Date::isStartOfMonth(const Date& d) {
return (d.dayOfMonth() == 1);
}

#ifndef QL_HIGH_RESOLUTION_DATE
// inline definitions

inline Weekday Date::weekday() const {
Integer w = serialNumber_ % 7;
return Weekday(w == 0 ? 7 : w);
Expand Down
6 changes: 1 addition & 5 deletions src/ql/utilities/dataformatters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
#include <ql/utilities/dataformatters.hpp>
#include <ostream>

namespace QuantLib {

namespace detail {
namespace QuantLib::detail {

std::ostream& operator<<(std::ostream& out,
const ordinal_holder& holder) {
Expand Down Expand Up @@ -58,5 +56,3 @@ namespace QuantLib {

}

}

Loading

0 comments on commit c5f327c

Please sign in to comment.