QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
imm.hpp
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) 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
9 This file is part of QuantLib, a free-software/open-source library
10 for financial quantitative analysts and developers - http://quantlib.org/
11
12 QuantLib is free software: you can redistribute it and/or modify it
13 under the terms of the QuantLib license. You should have received a
14 copy of the license along with this program; if not, please email
15 <quantlib-dev@lists.sf.net>. The license is also available online at
16 <http://quantlib.org/license.shtml>.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the license for more details.
21*/
22
23/*! \file imm.hpp
24 \brief IMM-related date functions
25*/
26
27#ifndef quantlib_imm_hpp
28#define quantlib_imm_hpp
29
30#include <ql/time/date.hpp>
31
32namespace QuantLib {
33
34 //! Main cycle of the International %Money Market (a.k.a. %IMM) months
35 struct IMM {
36 enum Month { F = 1, G = 2, H = 3,
37 J = 4, K = 5, M = 6,
38 N = 7, Q = 8, U = 9,
39 V = 10, X = 11, Z = 12 };
40
41 //! returns whether or not the given date is an IMM date
42 static bool isIMMdate(const Date& d,
43 bool mainCycle = true);
44
45 //! returns whether or not the given string is an IMM code
46 static bool isIMMcode(const std::string& in,
47 bool mainCycle = true);
48
49 /*! returns the IMM code for the given date
50 (e.g. H3 for March 20th, 2013).
51
52 \warning It raises an exception if the input
53 date is not an IMM date
54 */
55 static std::string code(const Date& immDate);
56
57 /*! returns the IMM date for the given IMM code
58 (e.g. March 20th, 2013 for H3).
59
60 \warning It raises an exception if the input
61 string is not an IMM code
62 */
63 static Date date(const std::string& immCode,
64 const Date& referenceDate = Date());
65
66 //! next IMM date following the given date
67 /*! returns the 1st delivery date for next contract listed in the
68 International Money Market section of the Chicago Mercantile
69 Exchange.
70 */
71 static Date nextDate(const Date& d = Date(),
72 bool mainCycle = true);
73
74 //! next IMM date following the given IMM code
75 /*! returns the 1st delivery date for next contract listed in the
76 International Money Market section of the Chicago Mercantile
77 Exchange.
78 */
79 static Date nextDate(const std::string& immCode,
80 bool mainCycle = true,
81 const Date& referenceDate = Date());
82
83 //! next IMM code following the given date
84 /*! returns the IMM code for next contract listed in the
85 International Money Market section of the Chicago Mercantile
86 Exchange.
87 */
88 static std::string nextCode(const Date& d = Date(),
89 bool mainCycle = true);
90
91 //! next IMM code following the given code
92 /*! returns the IMM code for next contract listed in the
93 International Money Market section of the Chicago Mercantile
94 Exchange.
95 */
96 static std::string nextCode(const std::string& immCode,
97 bool mainCycle = true,
98 const Date& referenceDate = Date());
99 };
100
101}
102
103#endif
Concrete date class.
Definition: date.hpp:125
date- and time-related classes, typedefs and enumerations
Date d
Definition: any.hpp:35
Main cycle of the International Money Market (a.k.a. IMM) months.
Definition: imm.hpp:35
static std::string nextCode(const Date &d=Date(), bool mainCycle=true)
next IMM code following the given date
Definition: imm.cpp:196
static bool isIMMcode(const std::string &in, bool mainCycle=true)
returns whether or not the given string is an IMM code
Definition: imm.cpp:55
static Date date(const std::string &immCode, const Date &referenceDate=Date())
Definition: imm.cpp:125
static std::string code(const Date &immDate)
Definition: imm.cpp:70
static bool isIMMdate(const Date &d, bool mainCycle=true)
returns whether or not the given date is an IMM date
Definition: imm.cpp:34
static Date nextDate(const Date &d=Date(), bool mainCycle=true)
next IMM date following the given date
Definition: imm.cpp:164