Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
varianceswap.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 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/varianceswap.hpp
20 \brief variance swap representation
21 \ingroup tradedata
22*/
23
24#pragma once
25
27
30
31namespace ore {
32namespace data {
33using std::string;
34
35class VarSwap : public ore::data::Trade {
36public:
37 void build(const QuantLib::ext::shared_ptr<ore::data::EngineFactory>&) override;
38
39 const string& longShort() { return longShort_; }
40 const std::string& name() const { return underlying_->name(); }
41 const QuantLib::ext::shared_ptr<ore::data::Underlying>& underlying() const { return underlying_; }
42 const string& currency() { return currency_; }
43 double strike() { return strike_; }
44 //double notional() const override { return notional_; }
45 double notional() const override;
46 const string& startDate() { return startDate_; }
47 const string& endDate() { return endDate_; }
48 const string& calendar() { return calendar_; }
50 const string& momentType() { return momentType_; }
51 const bool addPastDividends() { return addPastDividends_; }
52
53 virtual void fromXML(XMLNode* node) override;
54 virtual XMLNode* toXML(ore::data::XMLDocument& doc) const override;
55
56protected:
59 VarSwap(ore::data::Envelope& env, string longShort, const QuantLib::ext::shared_ptr<ore::data::Underlying>& underlying,
60 string currency, double strike, double notional, string startDate, string endDate,
66 }
67
69
70protected:
71 QuantLib::ext::shared_ptr<ore::data::Underlying> underlying_;
72
73private:
74 void initIndexName();
75 string longShort_;
76 string currency_;
77 double strike_;
78 double notional_;
79 string startDate_;
80 string endDate_;
81 string calendar_;
84
85 // Store some parsed variables needed in the fixings method
86 QuantLib::Date start_;
88
89 /*! The index name. Not sure why the index was not just used in the trade XML.
90 This is set to "FX-" + name for FX and left as name for the others for the moment.
91 */
92 std::string indexName_;
93
94 // for backward compatability
95 bool oldXml_;
96};
97
98class EqVarSwap : public VarSwap {
99public:
100 EqVarSwap() : VarSwap(AssetClass::EQ) { tradeType_ = "EquityVarianceSwap"; }
101 EqVarSwap(ore::data::Envelope& env, string longShort, const QuantLib::ext::shared_ptr<ore::data::Underlying>& underlying,
102 string currency, double strike, double notional, string startDate, string endDate, string momentType,
103 bool addPastDividends)
106 Trade::tradeType_ = "EquityVarianceSwap";
107 }
108
109 //! Add underlying Equity names
110 std::map<AssetClass, std::set<std::string>>
111 underlyingIndices(const QuantLib::ext::shared_ptr<ReferenceDataManager>& referenceDataManager = nullptr) const override;
112};
113
114class FxVarSwap : public VarSwap {
115public:
116 FxVarSwap() : VarSwap(AssetClass::FX) { tradeType_ = "FxVarianceSwap"; }
117 FxVarSwap(ore::data::Envelope& env, string longShort, const QuantLib::ext::shared_ptr<ore::data::Underlying>& underlying,
118 string currency, double strike, double notional, string startDate, string endDate, string momentType,
119 bool addPastDividends)
122 Trade::tradeType_ = "FxVarianceSwap";
123 }
124};
125
126class ComVarSwap : public VarSwap {
127public:
128 ComVarSwap() : VarSwap(AssetClass::COM) { tradeType_ = "CommodityVarianceSwap"; }
129 ComVarSwap(ore::data::Envelope& env, string longShort, const QuantLib::ext::shared_ptr<ore::data::Underlying>& underlying,
130 string currency, double strike, double notional, string startDate, string endDate, string momentType,
131 bool addPastDividends)
134 Trade::tradeType_ = "CommodityVarianceSwap";
135 }
136
137 //! Add underlying Equity names
138 std::map<AssetClass, std::set<std::string>>
139 underlyingIndices(const QuantLib::ext::shared_ptr<ReferenceDataManager>& referenceDataManager = nullptr) const override;
140};
141
142} // namespace data
143} // namespace ore
variance swap engine builder
std::map< AssetClass, std::set< std::string > > underlyingIndices(const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const override
Add underlying Equity names.
ComVarSwap(ore::data::Envelope &env, string longShort, const QuantLib::ext::shared_ptr< ore::data::Underlying > &underlying, string currency, double strike, double notional, string startDate, string endDate, string momentType, bool addPastDividends)
Serializable object holding generic trade data, reporting dimensions.
Definition: envelope.hpp:51
EqVarSwap(ore::data::Envelope &env, string longShort, const QuantLib::ext::shared_ptr< ore::data::Underlying > &underlying, string currency, double strike, double notional, string startDate, string endDate, string momentType, bool addPastDividends)
std::map< AssetClass, std::set< std::string > > underlyingIndices(const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const override
Add underlying Equity names.
FxVarSwap(ore::data::Envelope &env, string longShort, const QuantLib::ext::shared_ptr< ore::data::Underlying > &underlying, string currency, double strike, double notional, string startDate, string endDate, string momentType, bool addPastDividends)
Trade base class.
Definition: trade.hpp:55
string tradeType_
Definition: trade.hpp:196
AssetClass assetClassUnderlying()
QuantLib::ext::shared_ptr< ore::data::Underlying > underlying_
const std::string & name() const
AssetClass assetClassUnderlying_
const string & endDate()
VarSwap(ore::data::Envelope &env, string longShort, const QuantLib::ext::shared_ptr< ore::data::Underlying > &underlying, string currency, double strike, double notional, string startDate, string endDate, AssetClass assetClassUnderlying, string momentType, bool addPastDividends)
QuantLib::Date start_
const string & calendar()
const string & startDate()
QuantLib::Calendar cal_
VarSwap(AssetClass assetClassUnderlying)
double notional() const override
Return the current notional in npvCurrency. See individual sub-classes for the precise definition.
const QuantLib::ext::shared_ptr< ore::data::Underlying > & underlying() const
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(ore::data::XMLDocument &doc) const override
void build(const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &) override
const string & momentType()
std::string indexName_
const string & longShort()
const string & currency()
const bool addPastDividends()
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
base trade data model and serialization
underlying data model