Skip to content

Commit

Permalink
Added Warsaw Stock Exchange Calendar (Poland) (#2063)
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio committed Aug 20, 2024
2 parents fc4210f + ed3c9c9 commit d8e0f1c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ql/indexes/ibor/wibor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace QuantLib {
Wibor(const Period& tenor,
const Handle<YieldTermStructure>& h = {})
: IborIndex("WIBOR", tenor, (tenor == 1 * Days ? 0 : 2), PLNCurrency(),
Poland(), ModifiedFollowing, false,
Poland(Poland::Settlement), ModifiedFollowing, false,
Actual365Fixed(), h) {}
};

Expand Down
34 changes: 30 additions & 4 deletions 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 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

0 comments on commit d8e0f1c

Please sign in to comment.