Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
commodityapo.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/portfolio/commodityapo.hpp
20 \brief Commodity Average Price Option data model and serialization
21 \ingroup tradedata
22*/
23
24#pragma once
25
31
33
34namespace ore {
35namespace data {
36
37/*! Serializable Commodity Average Price Option
38 \ingroup tradedata
39*/
41public:
42 CommodityAveragePriceOption() : ore::data::Trade("CommodityAveragePriceOption") {}
43
45 const ore::data::Envelope& envelope, const ore::data::OptionData& optionData, QuantLib::Real quantity,
46 QuantLib::Real strike, const std::string& currency, const std::string& name, CommodityPriceType priceType,
47 const std::string& startDate, const std::string& endDate, const std::string& paymentCalendar,
48 const std::string& paymentLag, const std::string& paymentConvention, const std::string& pricingCalendar,
49 const std::string& paymentDate = "", QuantLib::Real gearing = 1.0, QuantLib::Spread spread = 0.0,
50 QuantExt::CommodityQuantityFrequency commodityQuantityFrequency =
51 QuantExt::CommodityQuantityFrequency::PerCalculationPeriod,
52 CommodityPayRelativeTo commodityPayRelativeTo = CommodityPayRelativeTo::CalculationPeriodEndDate,
53 QuantLib::Natural futureMonthOffset = 0, QuantLib::Natural deliveryRollDays = 0, bool includePeriodEnd = true,
54 const BarrierData& barrierData = {}, const std::string& fxIndex = "");
55
56 void build(const QuantLib::ext::shared_ptr<ore::data::EngineFactory>& engineFactory) override;
57
58 //! Add underlying Commodity names
59 std::map<AssetClass, std::set<std::string>>
60 underlyingIndices(const QuantLib::ext::shared_ptr<ReferenceDataManager>& referenceDataManager = nullptr) const override;
61
62 //! \name Inspectors
63 //@{
66 QuantLib::Real quantity() const { return quantity_; }
67 QuantLib::Real strike() const { return strike_; }
68 const std::string& currency() const { return currency_; }
69 const std::string& name() const { return name_; }
71 const std::string& startDate() const { return startDate_; }
72 const std::string& endDate() const { return endDate_; }
73 const std::string& paymentCalendar() const { return paymentCalendar_; }
74 const std::string& paymentLag() const { return paymentLag_; }
75 const std::string& paymentConvention() const { return paymentConvention_; }
76 const std::string& pricingCalendar() const { return pricingCalendar_; }
77 const std::string& paymentDate() const { return paymentDate_; }
78 QuantLib::Real gearing() const { return gearing_; }
79 QuantLib::Spread spread() const { return spread_; }
82 QuantLib::Natural futureMonthOffset() const { return futureMonthOffset_; }
83 QuantLib::Natural deliveryRollDays() const { return deliveryRollDays_; }
84 bool includePeriodEnd() const { return includePeriodEnd_; }
85 const std::string& fxIndex() const { return fxIndex_; }
86 //@}
87
88 //! \name Serialisation
89 //@{
90 virtual void fromXML(ore::data::XMLNode* node) override;
91 virtual ore::data::XMLNode* toXML(ore::data::XMLDocument& doc) const override;
92 //@}
93
94 //! \name Trade
95 //@{
96 bool hasCashflows() const override { return false; }
97 //@}
98
99private:
102 QuantLib::Real quantity_;
103 QuantLib::Real strike_;
104 std::string currency_;
105 std::string name_;
107 std::string startDate_;
108 std::string endDate_;
109 std::string paymentCalendar_;
110 std::string paymentLag_;
112 std::string pricingCalendar_;
113 std::string paymentDate_;
114 QuantLib::Real gearing_;
115 QuantLib::Spread spread_;
118 QuantLib::Natural futureMonthOffset_;
119 QuantLib::Natural deliveryRollDays_;
121 std::string fxIndex_;
122
123 /*! Flag indicating if the commodity contract itself is averaging. This is used to decide if we build a
124 standard non-averaging commodity option or an averaging commodity option.
125 */
127
128 /*! Build a commodity floating leg to extract the single commodity averaging flow
129 */
130 QuantLib::Leg buildLeg(const QuantLib::ext::shared_ptr<ore::data::EngineFactory>& engineFactory,
131 const std::string& configuration);
132
133 //! Build a standard option
134 void buildStandardOption(const QuantLib::ext::shared_ptr<ore::data::EngineFactory>& engineFactory, const QuantLib::Leg& leg,
135 QuantLib::Date exerciseDate);
136
137 //! Build an average price option
138 void buildApo(const QuantLib::ext::shared_ptr<ore::data::EngineFactory>& engineFactory, const QuantLib::Leg& leg,
139 QuantLib::Date exerciseDate, const QuantLib::ext::shared_ptr<ore::data::EngineBuilder>& builder);
140};
141
142} // namespace data
143} // namespace ore
const boost::shared_ptr< FxIndex > & fxIndex() const
boost::shared_ptr< FxIndex > fxIndex_
Serializable obejct holding barrier data.
Definition: barrierdata.hpp:34
const std::string & currency() const
const std::string & name() const
QuantExt::CommodityQuantityFrequency commodityQuantityFrequency_
const std::string & pricingCalendar() const
const ore::data::OptionData & optionData()
QuantExt::CommodityQuantityFrequency commodityQuantityFrequency() const
const std::string & paymentCalendar() const
const std::string & paymentDate() const
void buildApo(const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &engineFactory, const QuantLib::Leg &leg, QuantLib::Date exerciseDate, const QuantLib::ext::shared_ptr< ore::data::EngineBuilder > &builder)
Build an average price option.
const ore::data::BarrierData & barrierData()
const std::string & paymentLag() const
CommodityPriceType priceType() const
const std::string & endDate() const
const std::string & paymentConvention() const
QuantLib::Natural deliveryRollDays() const
void buildStandardOption(const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &engineFactory, const QuantLib::Leg &leg, QuantLib::Date exerciseDate)
Build a standard option.
QuantLib::Natural futureMonthOffset() const
QuantLib::Leg buildLeg(const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &engineFactory, const std::string &configuration)
CommodityPayRelativeTo commodityPayRelativeTo_
const std::string & startDate() const
const std::string & fxIndex() const
CommodityPayRelativeTo commodityPayRelativeTo() const
CommodityAveragePriceOption(const ore::data::Envelope &envelope, const ore::data::OptionData &optionData, QuantLib::Real quantity, QuantLib::Real strike, const std::string &currency, const std::string &name, CommodityPriceType priceType, const std::string &startDate, const std::string &endDate, const std::string &paymentCalendar, const std::string &paymentLag, const std::string &paymentConvention, const std::string &pricingCalendar, const std::string &paymentDate="", QuantLib::Real gearing=1.0, QuantLib::Spread spread=0.0, QuantExt::CommodityQuantityFrequency commodityQuantityFrequency=QuantExt::CommodityQuantityFrequency::PerCalculationPeriod, CommodityPayRelativeTo commodityPayRelativeTo=CommodityPayRelativeTo::CalculationPeriodEndDate, QuantLib::Natural futureMonthOffset=0, QuantLib::Natural deliveryRollDays=0, bool includePeriodEnd=true, const BarrierData &barrierData={}, const std::string &fxIndex="")
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
leg data for commodity leg types
@ data
Definition: log.hpp:77
CommodityQuantityFrequency
Serializable Credit Default Swap.
Definition: namespaces.docs:23
trade option data model and serialization
string name
base trade data model and serialization
Trade Factory.