Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
commodityoptionstrip.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/commodityoptionstrip.hpp
20 \brief Commodity option strip data model and serialization
21 \ingroup tradedata
22*/
23
24#pragma once
25
30#include <ql/position.hpp>
31
32namespace ore {
33namespace data {
34
35/*! Serializable Commodity option strip
36 \ingroup tradedata
37*/
39public:
40 CommodityOptionStrip() : ore::data::Trade("CommodityOptionStrip") {}
41
43 const std::vector<QuantLib::Position::Type>& callPositions,
44 const std::vector<QuantLib::Real>& callStrikes,
45 const std::vector<QuantLib::Position::Type>& putPositions,
46 const std::vector<QuantLib::Real>& putStrikes, QuantLib::Real premium = 0.0,
47 const std::string& premiumCurrency = "",
48 const QuantLib::Date& premiumPayDate = QuantLib::Date(), const std::string& style = "",
49 const std::string& settlement = "", const BarrierData& callBarrierData = {},
50 const BarrierData& putBarrierData = {},
51 const std::string& fxIndex = "",
52 const bool isDigital = false,
53 Real payoffPerUnit = 0.0);
54
55 //! Implement the build method
56 void build(const QuantLib::ext::shared_ptr<ore::data::EngineFactory>& engineFactory) override;
57
58 //! Add underlying Commodity names
59 std::map<ore::data::AssetClass, std::set<std::string>>
60 underlyingIndices(const QuantLib::ext::shared_ptr<ReferenceDataManager>& referenceDataManager = nullptr) const override;
61
62 //! \name Inspectors
63 //@{
64 const ore::data::LegData& legData() const { return legData_; }
65 const std::vector<QuantLib::Position::Type>& callPositions() const { return callPositions_; }
66 const std::vector<QuantLib::Real>& callStrikes() const { return callStrikes_; }
67 const std::vector<QuantLib::Position::Type>& putPositions() const { return putPositions_; }
68 const std::vector<QuantLib::Real>& putStrikes() const { return putStrikes_; }
69 const PremiumData& premiumDate() const { return premiumData_; }
70 const std::string& style() const { return style_; }
71 const std::string& settlement() const { return settlement_; }
72 const std::string& fxIndex() const { return fxIndex_; }
73 const BarrierData& callBarrierData() const { return callBarrierData_; }
74 const BarrierData& putBarrierData() const { return putBarrierData_; }
75 const bool isDigital() const { return isDigital_; }
76 const Real payoffPerUnit() const { return unaryPayoff_; }
77 //@}
78
79 //! \name Serialisation
80 //@{
81 virtual void fromXML(ore::data::XMLNode* node) override;
82 virtual ore::data::XMLNode* toXML(ore::data::XMLDocument& doc) const override;
83 //@}
84
85 //! \name Trade
86 //@{
87 bool hasCashflows() const override { return false; }
88 //@}
89
90private:
92 std::vector<QuantLib::Position::Type> callPositions_;
93 std::vector<QuantLib::Real> callStrikes_;
94 std::vector<QuantLib::Position::Type> putPositions_;
95 std::vector<QuantLib::Real> putStrikes_;
97 std::string style_;
98 std::string settlement_;
101 std::string fxIndex_;
104
105 QuantLib::ext::shared_ptr<CommodityFloatingLegData> commLegData_;
106
107 //! Build an average price option strip
108 void buildAPOs(const QuantLib::Leg& leg, const QuantLib::ext::shared_ptr<ore::data::EngineFactory>& engineFactory);
109
110 //! Build a standard option strip
111 void buildStandardOptions(const QuantLib::Leg& leg,
112 const QuantLib::ext::shared_ptr<ore::data::EngineFactory>& engineFactory);
113
114 //! Perform checks before building
115 void check(QuantLib::Size numberPeriods) const;
116};
117
118} // namespace data
119} // namespace ore
Serializable obejct holding barrier data.
Definition: barrierdata.hpp:34
const std::string & settlement() const
const BarrierData & putBarrierData() const
std::vector< QuantLib::Real > putStrikes_
const BarrierData & callBarrierData() const
const std::vector< QuantLib::Real > & callStrikes() const
virtual void fromXML(ore::data::XMLNode *node) override
CommodityOptionStrip(const ore::data::Envelope &envelope, const ore::data::LegData &legData, const std::vector< QuantLib::Position::Type > &callPositions, const std::vector< QuantLib::Real > &callStrikes, const std::vector< QuantLib::Position::Type > &putPositions, const std::vector< QuantLib::Real > &putStrikes, QuantLib::Real premium=0.0, const std::string &premiumCurrency="", const QuantLib::Date &premiumPayDate=QuantLib::Date(), const std::string &style="", const std::string &settlement="", const BarrierData &callBarrierData={}, const BarrierData &putBarrierData={}, const std::string &fxIndex="", const bool isDigital=false, Real payoffPerUnit=0.0)
void buildAPOs(const QuantLib::Leg &leg, const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &engineFactory)
Build an average price option strip.
std::map< ore::data::AssetClass, std::set< std::string > > underlyingIndices(const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const override
Add underlying Commodity names.
void build(const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &engineFactory) override
Implement the build method.
const PremiumData & premiumDate() const
QuantLib::ext::shared_ptr< CommodityFloatingLegData > commLegData_
std::vector< QuantLib::Position::Type > callPositions_
virtual ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
const std::vector< QuantLib::Real > & putStrikes() const
const std::vector< QuantLib::Position::Type > & callPositions() const
std::vector< QuantLib::Position::Type > putPositions_
std::vector< QuantLib::Real > callStrikes_
const std::vector< QuantLib::Position::Type > & putPositions() const
const std::string & style() const
void buildStandardOptions(const QuantLib::Leg &leg, const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &engineFactory)
Build a standard option strip.
const std::string & fxIndex() const
const ore::data::LegData & legData() const
Serializable object holding generic trade data, reporting dimensions.
Definition: envelope.hpp:51
Serializable object holding leg data.
Definition: legdata.hpp:844
Serializable object holding premium data.
Definition: premiumdata.hpp:37
Trade base class.
Definition: trade.hpp:55
const Envelope & envelope() const
Definition: trade.hpp:135
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
leg data for commodity leg types
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
trade option data model and serialization
base trade data model and serialization