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 qle/instruments/pairwisevarianceswap.hpp
20 \brief Pirwise Variance swap
21*/
22
23#pragma once
24
26#include <ql/option.hpp>
27#include <ql/position.hpp>
28#include <ql/time/schedule.hpp>
29
30namespace QuantExt {
31using namespace QuantLib;
32
33//! Pairwise Variance swap
34/*! \ingroup instruments
35 */
36class PairwiseVarianceSwap : public Instrument {
37public:
38 class arguments;
39 class results;
40 class engine;
41 PairwiseVarianceSwap(const Position::Type position, const Real strike1, const Real strike2, const Real basketStrike,
42 const Real notional1, const Real notional2, const Real basketNotional, const Real cap,
43 const Real floor, const Real payoffLimit, const int accrualLag,
44 const Schedule valuationSchedule, const Schedule laggedValuationSchedule,
45 const Date settlementDate);
46 //! \name Instrument interface
47 //@{
48 bool isExpired() const override;
49 //@}
50 //! \name Additional interface
51 //@{
52 // inspectors
53 Position::Type position() const;
54 Real strike1() const;
55 Real strike2() const;
56 Real basketStrike() const;
57 Real notional1() const;
58 Real notional2() const;
59 Real basketNotional() const;
60 Real cap() const;
61 Real floor() const;
62 Real payoffLimit() const;
63 int accrualLag() const;
64 Schedule valuationSchedule() const;
65 Schedule laggedValuationSchedule() const;
66 Date settlementDate() const;
67 // results
68 Real variance1() const;
69 Real variance2() const;
70 Real basketVariance() const;
71 //@}
72 // other
73 void setupArguments(PricingEngine::arguments* args) const override;
74 void fetchResults(const PricingEngine::results*) const override;
75
76protected:
77 void setupExpired() const override;
78 // data members
79 Position::Type position_;
86 Real cap_;
87 Real floor_;
92 // results
93 mutable Real variance1_;
94 mutable Real finalVariance1_;
95 mutable Real variance2_;
96 mutable Real finalVariance2_;
97 mutable Real basketVariance_;
99};
100
101//! %Arguments
103public:
105 : strike1(Null<Real>()), strike2(Null<Real>()), basketStrike(Null<Real>()), notional1(Null<Real>()),
106 notional2(Null<Real>()), basketNotional(Null<Real>()), cap(Null<Real>()), floor(Null<Real>()),
107 payoffLimit(Null<Real>()), accrualLag(Null<int>()) {}
108 void validate() const override;
109 Position::Type position;
116 Real cap;
117 Real floor;
123};
124
125//! %Results from pairwise variance-swap calculation
127public:
135 void reset() override {
136 Instrument::results::reset();
137 variance1 = Null<Real>();
138 variance2 = Null<Real>();
139 basketVariance = Null<Real>();
140 finalVariance1 = Null<Real>();
141 finalVariance2 = Null<Real>();
142 finalBasketVariance = Null<Real>();
143 finalVariance1 = Null<Real>();
144 equityAmount1 = Null<Real>();
145 equityAmount2 = Null<Real>();
146 equityAmountBasket = Null<Real>();
147 pairwiseEquityAmount = Null<Real>();
148 finalEquityAmount = Null<Real>();
149 }
150};
151
152//! base class for pairwise variance-swap engines
154 : public GenericEngine<QuantExt::PairwiseVarianceSwap::arguments, QuantExt::PairwiseVarianceSwap::results> {};
155
156// inline definitions
157
158inline Position::Type PairwiseVarianceSwap::position() const { return position_; }
159
160inline Real PairwiseVarianceSwap::strike1() const { return strike1_; }
161
162inline Real PairwiseVarianceSwap::strike2() const { return strike2_; }
163
165
166inline Real PairwiseVarianceSwap::notional1() const { return notional1_; }
167
168inline Real PairwiseVarianceSwap::notional2() const { return notional2_; }
169
171
172inline Real PairwiseVarianceSwap::cap() const { return cap_; }
173
174inline Real PairwiseVarianceSwap::floor() const { return floor_; }
175
176inline Real PairwiseVarianceSwap::payoffLimit() const { return payoffLimit_; }
177
178inline int PairwiseVarianceSwap::accrualLag() const { return accrualLag_; }
179
181
183
185
186} // namespace QuantExt
base class for pairwise variance-swap engines
Results from pairwise variance-swap calculation
void setupArguments(PricingEngine::arguments *args) const override
void fetchResults(const PricingEngine::results *) const override
Pirwise Variance swap.