Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
conventionsbasedfutureexpiry.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 ored/utilities/conventionsbasedfutureexpiry.hpp
20 \brief Base class for classes that perform date calculations for future contracts
21 \ingroup utilities
22*/
23
24#pragma once
25
28
29namespace ore {
30namespace data {
31
32//! Perform date calculations for future contracts based on conventions
34public:
35 ConventionsBasedFutureExpiry(const std::string& commName, QuantLib::Size maxIterations = 10);
36 ConventionsBasedFutureExpiry(const CommodityFutureConvention& convention, QuantLib::Size maxIterations = 10);
37
38 QuantLib::Date nextExpiry(bool includeExpiry = true, const QuantLib::Date& referenceDate = QuantLib::Date(),
39 QuantLib::Natural offset = 0, bool forOption = false) override;
40
41 QuantLib::Date priorExpiry(bool includeExpiry = true, const QuantLib::Date& referenceDate = QuantLib::Date(),
42 bool forOption = false) override;
43
44 QuantLib::Date expiryDate(const QuantLib::Date& contractDate, QuantLib::Natural monthOffset = 0,
45 bool forOption = false) override;
46
47 QuantLib::Date contractDate(const QuantLib::Date& expiryDate) override;
48
49 QuantLib::Date applyFutureMonthOffset(const QuantLib::Date& contractDate, Natural futureMonthOffset) override;
50
51 //! \name Inspectors
52 //@{
53 //! Return the commodity future convention.
55
56 //! Return the maximum iterations parameter.
57 QuantLib::Size maxIterations() const;
58 //@}
59
60private:
62 QuantLib::Size maxIterations_;
63
64 //! Given a \p contractMonth, a \p contractYear and \p conventions, calculate the contract expiry date
65 QuantLib::Date expiry(QuantLib::Day dayOfMonth, QuantLib::Month contractMonth, QuantLib::Year contractYear,
66 QuantLib::Natural monthOffset, bool forOption) const;
67
68 //! Do the next expiry work
69 QuantLib::Date nextExpiry(const QuantLib::Date& referenceDate, bool forOption) const;
70
71 //! Account for prohibited expiries
72 QuantLib::Date avoidProhibited(const QuantLib::Date& expiry, bool forOption) const;
73};
74
75} // namespace data
76} // namespace ore
Perform date calculations for future contracts based on conventions.
QuantLib::Date nextExpiry(const QuantLib::Date &referenceDate, bool forOption) const
Do the next expiry work.
QuantLib::Date nextExpiry(bool includeExpiry=true, const QuantLib::Date &referenceDate=QuantLib::Date(), QuantLib::Natural offset=0, bool forOption=false) override
QuantLib::Date avoidProhibited(const QuantLib::Date &expiry, bool forOption) const
Account for prohibited expiries.
QuantLib::Date expiry(QuantLib::Day dayOfMonth, QuantLib::Month contractMonth, QuantLib::Year contractYear, QuantLib::Natural monthOffset, bool forOption) const
Given a contractMonth, a contractYear and conventions, calculate the contract expiry date.
ConventionsBasedFutureExpiry(const std::string &commName, QuantLib::Size maxIterations=10)
QuantLib::Date priorExpiry(bool includeExpiry=true, const QuantLib::Date &referenceDate=QuantLib::Date(), bool forOption=false) override
QuantLib::Date applyFutureMonthOffset(const QuantLib::Date &contractDate, Natural futureMonthOffset) override
QuantLib::Date expiryDate(const QuantLib::Date &contractDate, QuantLib::Natural monthOffset=0, bool forOption=false) override
QuantLib::Size maxIterations() const
Return the maximum iterations parameter.
QuantLib::Date contractDate(const QuantLib::Date &expiryDate) override
const CommodityFutureConvention & commodityFutureConvention() const
Return the commodity future convention.
Currency and instrument specific conventions/defaults.
@ data
Definition: log.hpp:77
Date referenceDate
Definition: utilities.cpp:442
Serializable Credit Default Swap.
Definition: namespaces.docs:23