1 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | |
3 | /* |
4 | Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl |
5 | Copyright (C) 2003, 2004, 2005, 2006, 2007 StatPro Italia srl |
6 | Copyright (C) 2004, 2005, 2006 Ferdinando Ametrano |
7 | Copyright (C) 2006 Katiuscia Manzoni |
8 | Copyright (C) 2015 Maddalena Zanzi |
9 | |
10 | This file is part of QuantLib, a free-software/open-source library |
11 | for financial quantitative analysts and developers - http://quantlib.org/ |
12 | |
13 | QuantLib is free software: you can redistribute it and/or modify it |
14 | under the terms of the QuantLib license. You should have received a |
15 | copy of the license along with this program; if not, please email |
16 | <quantlib-dev@lists.sf.net>. The license is also available online at |
17 | <http://quantlib.org/license.shtml>. |
18 | |
19 | This program is distributed in the hope that it will be useful, but WITHOUT |
20 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
21 | FOR A PARTICULAR PURPOSE. See the license for more details. |
22 | */ |
23 | |
24 | /*! \file asx.hpp |
25 | \brief ASX-related date functions |
26 | */ |
27 | |
28 | #ifndef quantlib_asx_hpp |
29 | #define quantlib_asx_hpp |
30 | |
31 | #include <ql/time/date.hpp> |
32 | |
33 | namespace QuantLib { |
34 | |
35 | //! Main cycle of the Australian Securities Exchange (a.k.a. ASX) months |
36 | struct ASX { |
37 | enum Month { F = 1, G = 2, H = 3, |
38 | J = 4, K = 5, M = 6, |
39 | N = 7, Q = 8, U = 9, |
40 | V = 10, X = 11, Z = 12 }; |
41 | |
42 | //! returns whether or not the given date is an ASX date |
43 | static bool isASXdate(const Date& d, |
44 | bool mainCycle = true); |
45 | |
46 | //! returns whether or not the given string is an ASX code |
47 | static bool isASXcode(const std::string& in, |
48 | bool mainCycle = true); |
49 | |
50 | /*! returns the ASX code for the given date |
51 | (e.g. M5 for June 12th, 2015). |
52 | |
53 | \warning It raises an exception if the input |
54 | date is not an ASX date |
55 | */ |
56 | static std::string code(const Date& asxDate); |
57 | |
58 | /*! returns the ASX date for the given ASX code |
59 | (e.g. June 12th, 2015 for M5). |
60 | |
61 | \warning It raises an exception if the input |
62 | string is not an ASX code |
63 | */ |
64 | static Date date(const std::string& asxCode, |
65 | const Date& referenceDate = Date()); |
66 | |
67 | //! next ASX date following the given date |
68 | /*! returns the 1st delivery date for next contract listed in the |
69 | Australian Securities Exchange. |
70 | */ |
71 | static Date nextDate(const Date& d = Date(), |
72 | bool mainCycle = true); |
73 | |
74 | //! next ASX date following the given ASX code |
75 | /*! returns the 1st delivery date for next contract listed in the |
76 | Australian Securities Exchange |
77 | */ |
78 | static Date nextDate(const std::string& asxCode, |
79 | bool mainCycle = true, |
80 | const Date& referenceDate = Date()); |
81 | |
82 | //! next ASX code following the given date |
83 | /*! returns the ASX code for next contract listed in the |
84 | Australian Securities Exchange |
85 | */ |
86 | static std::string nextCode(const Date& d = Date(), |
87 | bool mainCycle = true); |
88 | |
89 | //! next ASX code following the given code |
90 | /*! returns the ASX code for next contract listed in the |
91 | Australian Securities Exchange |
92 | */ |
93 | static std::string nextCode(const std::string& asxCode, |
94 | bool mainCycle = true, |
95 | const Date& referenceDate = Date()); |
96 | }; |
97 | |
98 | } |
99 | |
100 | #endif |
101 | |