Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
commoditydigitaloption.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2022 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/portfolio/commoditydigitaloption.hpp
20 \brief Commodity digital option representation as call spread
21 \ingroup tradedata
22*/
23
24#pragma once
25
28
29namespace ore {
30namespace data {
31
32//! Commodity digital option trade representation as call spread
33/*! \ingroup tradedata
34 */
36public:
37 //! Default constructor
39
40 //! Detailed constructor
41 CommodityDigitalOption(const Envelope& env, const OptionData& optionData, const std::string& commodityName,
42 const std::string& currency, QuantLib::Real strike, QuantLib::Real payoff,
43 const boost::optional<bool>& isFuturePrice = boost::none,
44 const QuantLib::Date& futureExpiryDate = QuantLib::Date());
45
46 //! Build underlying instrument and link pricing engine
47 void build(const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory) override;
48
49 //! Add underlying Commodity names
50 std::map<AssetClass, std::set<std::string>>
51 underlyingIndices(const QuantLib::ext::shared_ptr<ReferenceDataManager>& referenceDataManager = nullptr) const override;
52
53 //! \name Serialisation
54 //@{
55 virtual void fromXML(XMLNode* node) override;
56 virtual XMLNode* toXML(XMLDocument& doc) const override;
57 //@}
58
59 //! \name Trade
60 //@{
61 bool hasCashflows() const override { return false; }
62 //@}
63
64 //! \name Inspectors
65 //@{
66 const boost::optional<bool>& isFuturePrice() const { return isFuturePrice_; }
67 const QuantLib::Date& futureExpiryDate() const { return futureExpiryDate_; }
68 //@}
69
70private:
72 std::string name_;
73 string currency_;
74 Real strike_;
75 Real payoff_;
76
77 /*! Indicates if the option underlying is a commodity future settlement price, \c true, or a spot price \c false.
78 If not explicitly set, it is assumed to be \c true.
79 */
80 boost::optional<bool> isFuturePrice_;
81
82 /*! An explicit expiry date for the underlying future contract. This can be used if the option trade references a
83 future contract settlement price and the option's expiry date does not match the future contract expiry date.
84 */
85 QuantLib::Date futureExpiryDate_;
86
87 //! An index is needed if the option is to be automatically exercised on expiry.
88 QuantLib::ext::shared_ptr<QuantLib::Index> index_;
89
90 //! Hold the external index name if needed e.g. in the case of an FX index.
91 std::string indexName_;
92
93 //! Store the option expiry date.
94 QuantLib::Date expiryDate_;
95
97};
98
99} // namespace data
100} // namespace ore
Commodity digital option trade representation as call spread.
const boost::optional< bool > & isFuturePrice() const
std::map< AssetClass, std::set< std::string > > underlyingIndices(const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const override
Add underlying Commodity names.
CommodityDigitalOption(const Envelope &env, const OptionData &optionData, const std::string &commodityName, const std::string &currency, QuantLib::Real strike, QuantLib::Real payoff, const boost::optional< bool > &isFuturePrice=boost::none, const QuantLib::Date &futureExpiryDate=QuantLib::Date())
Detailed constructor.
QuantLib::Date expiryDate_
Store the option expiry date.
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
void build(const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory) override
Build underlying instrument and link pricing engine.
const QuantLib::Date & futureExpiryDate() const
std::string indexName_
Hold the external index name if needed e.g. in the case of an FX index.
QuantLib::ext::shared_ptr< QuantLib::Index > index_
An index is needed if the option is to be automatically exercised on expiry.
Serializable object holding generic trade data, reporting dimensions.
Definition: envelope.hpp:51
Serializable object holding option data.
Definition: optiondata.hpp:42
Trade base class.
Definition: trade.hpp:55
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
trade option data model and serialization
vanilla option representation