Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Warsaw Stock Exchange Calendar (Poland) #2063

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading