Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
pairwisevarianceswap.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 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/pairwisevarianceswap.hpp
20 \brief pairwise variance swap representation
21 \ingroup tradedata
22*/
23
24#pragma once
25
27
30
31namespace ore {
32namespace data {
33using std::string;
34
35class PairwiseVarSwap : public Trade {
36public:
37 void build(const QuantLib::ext::shared_ptr<EngineFactory>&) override;
38
39 const string& longShort() { return longShort_; }
40 const vector<QuantLib::ext::shared_ptr<Underlying>>& underlyings() const { return underlyings_; }
41 const string& name(int idx) const { return underlyings_[idx]->name(); }
42 const string& currency() { return currency_; }
43 double basketStrike() { return basketStrike_; }
44 double basketNotional() { return basketNotional_; }
45 using Trade::notional;
46 double notional(int idx) { return underlyingNotionals_[idx]; };
47 double strike(int idx) { return underlyingStrikes_[idx]; };
49
50 virtual void fromXML(XMLNode* node) override;
51 virtual XMLNode* toXML(XMLDocument& doc) const override;
52
53protected:
55 : Trade("PairwiseVarianceSwap"), assetClassUnderlyings_(assetClassUnderlyings) {}
56 PairwiseVarSwap(Envelope& env, string longShort, const vector<QuantLib::ext::shared_ptr<Underlying>>& underlyings,
57 vector<double> underlyingStrikes, vector<double> underlyingNotionals, double basketNotional,
58 double basketStrike, ScheduleData valuationSchedule, string currency, string settlementDate,
59 AssetClass assetClassUnderlyings, ScheduleData laggedValuationSchedule, double payoffLimit = 0.0,
60 double cap = 0.0, double floor = 0.0, int accrualLag = 1)
62 longShort_(longShort), underlyingStrikes_(underlyingStrikes), underlyingNotionals_(underlyingNotionals),
64 floor_(floor), accrualLag_(accrualLag), settlementDate_(settlementDate), currency_(currency) {
65
66 for (const auto& u : underlyings_) {
67 indexNames_.push_back(assetClassUnderlyings_ == AssetClass::FX ? "FX-" + u->name() : u->name());
68 }
69 }
70
72
73protected:
74 vector<QuantLib::ext::shared_ptr<Underlying>> underlyings_;
75
76private:
77 string longShort_;
83
84 /*! The index name. Not sure why the index was not just used in the trade XML.
85 This is set to "FX-" + name for FX and left as name for the others for the moment.
86 */
87 vector<string> indexNames_;
88};
89
91public:
92 EqPairwiseVarSwap() : PairwiseVarSwap(AssetClass::EQ) { tradeType_ = "EquityPairwiseVarianceSwap"; }
94 const vector<QuantLib::ext::shared_ptr<Underlying>>& underlyings, vector<double> underlyingStrikes,
95 vector<double> underlyingNotionals, double basketNotional, double basketStrike,
96 ScheduleData valuationSchedule, string currency, string settlementDate,
97 ScheduleData laggedValuationSchedule, double payoffLimit = 0.0, double cap = 0.0,
98 double floor = 0.0, int accrualLag = 1)
99 : PairwiseVarSwap(env, longShort, underlyings, underlyingStrikes, underlyingNotionals, basketNotional,
100 basketStrike, valuationSchedule, currency, settlementDate, AssetClass::EQ,
101 laggedValuationSchedule, payoffLimit, cap, floor, accrualLag) {
102 Trade::tradeType_ = "EquityPairwiseVarianceSwap";
103 }
104
105 //! Add underlying Equity names
106 std::map<AssetClass, std::set<std::string>>
107 underlyingIndices(const QuantLib::ext::shared_ptr<ReferenceDataManager>& referenceDataManager = nullptr) const override;
108};
109
111public:
112 FxPairwiseVarSwap() : PairwiseVarSwap(AssetClass::FX) { tradeType_ = "FxPairwiseVarianceSwap"; }
113 FxPairwiseVarSwap(Envelope& env, string longShort, const vector<QuantLib::ext::shared_ptr<Underlying>>& underlyings,
114 vector<double> underlyingStrikes, vector<double> underlyingNotionals, double basketNotional,
115 double basketStrike, ScheduleData valuationSchedule, string currency, string settlementDate,
116 ScheduleData laggedValuationSchedule, double payoffLimit = 0.0, double cap = 0.0,
117 double floor = 0.0, int accrualLag = 1)
118 : PairwiseVarSwap(env, longShort, underlyings, underlyingStrikes, underlyingNotionals, basketNotional,
119 basketStrike, valuationSchedule, currency, settlementDate, AssetClass::FX,
120 laggedValuationSchedule, payoffLimit, cap, floor, accrualLag) {
121 Trade::tradeType_ = "FxPairwiseVarianceSwap";
122 }
123};
124
125} // namespace data
126} // namespace ore
pairwise variance swap engine builder
Serializable object holding generic trade data, reporting dimensions.
Definition: envelope.hpp:51
EqPairwiseVarSwap(ore::data::Envelope &env, string longShort, const vector< QuantLib::ext::shared_ptr< Underlying > > &underlyings, vector< double > underlyingStrikes, vector< double > underlyingNotionals, double basketNotional, double basketStrike, ScheduleData valuationSchedule, string currency, string settlementDate, ScheduleData laggedValuationSchedule, double payoffLimit=0.0, double cap=0.0, double floor=0.0, int accrualLag=1)
std::map< AssetClass, std::set< std::string > > underlyingIndices(const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const override
Add underlying Equity names.
FxPairwiseVarSwap(Envelope &env, string longShort, const vector< QuantLib::ext::shared_ptr< Underlying > > &underlyings, vector< double > underlyingStrikes, vector< double > underlyingNotionals, double basketNotional, double basketStrike, ScheduleData valuationSchedule, string currency, string settlementDate, ScheduleData laggedValuationSchedule, double payoffLimit=0.0, double cap=0.0, double floor=0.0, int accrualLag=1)
vector< QuantLib::ext::shared_ptr< Underlying > > underlyings_
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
const vector< QuantLib::ext::shared_ptr< Underlying > > & underlyings() const
PairwiseVarSwap(Envelope &env, string longShort, const vector< QuantLib::ext::shared_ptr< Underlying > > &underlyings, vector< double > underlyingStrikes, vector< double > underlyingNotionals, double basketNotional, double basketStrike, ScheduleData valuationSchedule, string currency, string settlementDate, AssetClass assetClassUnderlyings, ScheduleData laggedValuationSchedule, double payoffLimit=0.0, double cap=0.0, double floor=0.0, int accrualLag=1)
const string & name(int idx) const
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
PairwiseVarSwap(AssetClass assetClassUnderlyings)
Serializable schedule data.
Definition: schedule.hpp:202
Trade base class.
Definition: trade.hpp:55
string tradeType_
Definition: trade.hpp:196
virtual QuantLib::Real notional() const
Return the current notional in npvCurrency. See individual sub-classes for the precise definition.
Definition: trade.hpp:153
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