Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
russia.cpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2021 Quaternion Risk Management Ltd
5 All rights reserved.
6
7 This file is part of ORE, a free-software/open-source library
8 for transparent pricing and risk analysis - http://opensourcerisk.org
9
10 ORE is free software: you can redistribute it and/or modify it
11 under the terms of the Modified BSD License. You should have received a
12 copy of the license along with this program.
13 The license is also available online at <http://opensourcerisk.org>
14
15 This program is distributed on the basis that it will form a useful
16 contribution to risk analytics and model standardisation, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
22#include <ql/errors.hpp>
23
24namespace QuantExt {
25
27 originalSettlementCalendar_ = Russia(Russia::Settlement);
28 }
29
31 originalSettlementCalendar_ = Russia(Russia::Settlement);
32 originalExchangeCalendar_ = Russia(Russia::MOEX);
33 }
34
35 RussiaModified::RussiaModified(Russia::Market market) {
36 // all calendar instances share the same implementation instance
37 static ext::shared_ptr<Calendar::Impl> settlementImpl(
39 static ext::shared_ptr<Calendar::Impl> exchangeImpl(
41
42 switch (market) {
43 case Russia::Settlement:
44 impl_ = settlementImpl;
45 break;
46 case Russia::MOEX:
47 impl_ = exchangeImpl;
48 break;
49 default:
50 QL_FAIL("unknown market");
51 }
52 }
53
54 bool RussiaModified::SettlementImpl::isBusinessDay(const Date& date) const {
55 return originalSettlementCalendar_.isBusinessDay(date);
56 }
57
58 bool RussiaModified::ExchangeImpl::isBusinessDay(const Date& date) const {
59 // The exchange was formally established in 2011, so data are only
60 // available from 2012 to present.
61 // We use the settlement calendar as a proxy before 2012
62 if (date.year() < 2012)
63 return originalSettlementCalendar_.isBusinessDay(date);
64 else
65 return originalExchangeCalendar_.isBusinessDay(date);
66 }
67
68}
bool isBusinessDay(const Date &) const override
Definition: russia.cpp:58
bool isBusinessDay(const Date &) const override
Definition: russia.cpp:54
RussiaModified(Russia::Market=Russia::Settlement)
Definition: russia.cpp:35
Russian calendar, modified QuantLib Russia to extend MOEX before 2012.