Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
futureexpirycalculator.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file qle/time/futureexpirycalculator.hpp
20 \brief Base class for classes that perform date calculations for future contracts
21*/
22
23#ifndef quantext_future_expiry_calculator_hpp
24#define quantext_future_expiry_calculator_hpp
25
26#include <ql/settings.hpp>
27#include <ql/time/date.hpp>
28
29namespace QuantExt {
30
31//! Base class for classes that perform date calculations for future contracts
33public:
35
36 /*! Given a reference date, \p referenceDate, return the expiry date of the next futures contract relative to
37 the reference date.
38
39 The \p includeExpiry parameter controls what happens when the \p referenceDate is equal to the next contract's
40 expiry date. If \p includeExpiry is \c true, the contract's expiry date is returned. If \p includeExpiry is
41 \c false, the next succeeding contract's expiry is returned.
42
43 If \p forOption is \c true, the next expiry for the option contract, as opposed to the future contract, is
44 returned.
45 */
46 virtual QuantLib::Date nextExpiry(bool includeExpiry = true, const QuantLib::Date& referenceDate = QuantLib::Date(),
47 QuantLib::Natural offset = 0, bool forOption = false) = 0;
48
49 /*! Given a reference date, \p referenceDate, return the expiry date of the first futures contract prior to
50 the reference date.
51
52 The \p includeExpiry parameter controls what happens when the \p referenceDate is equal to the prior contract's
53 expiry date. If \p includeExpiry is \c true, the contract's expiry date is returned. If \p includeExpiry is
54 \c false, the next preceding contract's expiry is returned.
55
56 If \p forOption is \c true, the prior expiry for the option contract, as opposed to the future contract, is
57 returned.
58 */
59 virtual QuantLib::Date priorExpiry(bool includeExpiry = true,
60 const QuantLib::Date& referenceDate = QuantLib::Date(),
61 bool forOption = false) = 0;
62
63 /*! Given a date, \p contractDate, return the future expiry date associated with that date.
64
65 If the future contract has a frequency that is less than monthly, the next available future contract expiry
66 date will be returned. If \p forOption is \c true, the next available future option expiry is returned. For
67 future contracts that have a frequency that is less than monthly, the \p monthOffset parameter is ignored.
68
69 If the future contract has a frequency that is monthly or greater, the contract's month and year is taken
70 to be the \p contractDate month and year, and the expiry date of the future contract that is \p monthOffset
71 number of months from that month's future contract is returned. If \p monthOffset is zero, the expiry date of
72 the future contract associated with that month and year is returned. If \p forOption is \c true, the expiry
73 date for the option contract, as opposed to the future contract, is returned.
74 */
75 virtual QuantLib::Date expiryDate(const QuantLib::Date& contractDate, QuantLib::Natural monthOffset = 0,
76 bool forOption = false) = 0;
77
78 /*! Given a futures (not option) expiry date, return a corresponding contract date */
79 virtual QuantLib::Date contractDate(const QuantLib::Date& expiryDate) = 0;
80
81 /*! apply a month offset to a given contract date and return the new contract date
82 if the contract frequency is daily or weekly, the input contract date is not modified */
83 virtual QuantLib::Date applyFutureMonthOffset(const QuantLib::Date& contractDate, Natural futureMonthOffset) = 0;
84};
85
86} // namespace QuantExt
87
88#endif
Base class for classes that perform date calculations for future contracts.
virtual QuantLib::Date contractDate(const QuantLib::Date &expiryDate)=0
virtual QuantLib::Date priorExpiry(bool includeExpiry=true, const QuantLib::Date &referenceDate=QuantLib::Date(), bool forOption=false)=0
virtual QuantLib::Date nextExpiry(bool includeExpiry=true, const QuantLib::Date &referenceDate=QuantLib::Date(), QuantLib::Natural offset=0, bool forOption=false)=0
virtual QuantLib::Date expiryDate(const QuantLib::Date &contractDate, QuantLib::Natural monthOffset=0, bool forOption=false)=0
virtual QuantLib::Date applyFutureMonthOffset(const QuantLib::Date &contractDate, Natural futureMonthOffset)=0