1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2009 Ferdinando Ametrano
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20/*! \file ecb.hpp
21 \brief European Central Bank reserve maintenance date functions
22*/
23
24#ifndef quantlib_ecb_hpp
25#define quantlib_ecb_hpp
26
27#include <ql/time/date.hpp>
28#include <set>
29#include <vector>
30
31namespace QuantLib {
32
33 //! European Central Bank reserve maintenance dates
34 struct ECB {
35
36 static const std::set<Date>& knownDates();
37 static void addDate(const Date& d);
38 static void removeDate(const Date& d);
39
40 //! maintenance period start date in the given month/year
41 static Date date(Month m,
42 Year y) { return nextDate(d: Date(1, m, y) - 1); }
43
44 /*! returns the ECB date for the given ECB code
45 (e.g. March xxth, 2013 for MAR10).
46
47 \warning It raises an exception if the input
48 string is not an ECB code
49 */
50 static Date date(const std::string& ecbCode,
51 const Date& referenceDate = Date());
52
53 /*! returns the ECB code for the given date
54 (e.g. MAR10 for March xxth, 2010).
55
56 \warning It raises an exception if the input
57 date is not an ECB date
58 */
59 static std::string code(const Date& ecbDate);
60
61 //! next maintenance period start date following the given date
62 static Date nextDate(const Date& d = Date());
63
64 //! next maintenance period start date following the given ECB code
65 static Date nextDate(const std::string& ecbCode,
66 const Date& referenceDate = Date()) {
67 return nextDate(d: date(ecbCode, referenceDate));
68 }
69
70 //! next maintenance period start dates following the given date
71 static std::vector<Date> nextDates(const Date& d = Date());
72
73 //! next maintenance period start dates following the given code
74 static std::vector<Date> nextDates(const std::string& ecbCode,
75 const Date& referenceDate = Date()) {
76 return nextDates(d: date(ecbCode, referenceDate));
77 }
78
79 /*! returns whether or not the given date is
80 a maintenance period start date */
81 static bool isECBdate(const Date& d) {
82 Date date = nextDate(d: d-1);
83 return d==date;
84 }
85
86 //! returns whether or not the given string is an ECB code
87 static bool isECBcode(const std::string& in);
88
89 //! next ECB code following the given date
90 static std::string nextCode(const Date& d = Date()) {
91 return code(ecbDate: nextDate(d));
92 }
93
94 //! next ECB code following the given code
95 static std::string nextCode(const std::string& ecbCode);
96
97 };
98
99}
100
101#endif
102

source code of quantlib/ql/time/ecb.hpp