Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
pairwisevarianceswap.cpp
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
20#include <ql/event.hpp>
21#include <ql/math/comparison.hpp>
22
23namespace QuantExt {
24
25PairwiseVarianceSwap::PairwiseVarianceSwap(Position::Type position, Real strike1, Real strike2, Real basketStrike,
26 Real notional1, Real notional2, Real basketNotional, Real cap, Real floor,
27 Real payoffLimit, int accrualLag, Schedule valuationSchedule,
28 Schedule laggedValuationSchedule, Date settlementDate)
29 : position_(position), strike1_(strike1), strike2_(strike2), basketStrike_(basketStrike), notional1_(notional1),
30 notional2_(notional2), basketNotional_(basketNotional), cap_(cap), floor_(floor), payoffLimit_(payoffLimit),
31 accrualLag_(accrualLag), valuationSchedule_(valuationSchedule), laggedValuationSchedule_(laggedValuationSchedule),
32 settlementDate_(settlementDate) {}
33
35 calculate();
36 QL_REQUIRE(variance1_ != Null<Real>(), "result not available");
37 return variance1_;
38}
39
41 calculate();
42 QL_REQUIRE(variance2_ != Null<Real>(), "result not available");
43 return variance2_;
44}
45
47 calculate();
48 QL_REQUIRE(basketVariance_ != Null<Real>(), "result not available");
49 return basketVariance_;
50}
51
52void PairwiseVarianceSwap::setupArguments(PricingEngine::arguments* args) const {
53 auto* arguments = dynamic_cast<PairwiseVarianceSwap::arguments*>(args);
54 QL_REQUIRE(arguments != nullptr, "wrong argument type");
55
70}
71
72void PairwiseVarianceSwap::fetchResults(const PricingEngine::results* r) const {
73 Instrument::fetchResults(r);
74 const auto* results = dynamic_cast<const PairwiseVarianceSwap::results*>(r);
78}
79
81 QL_REQUIRE(strike1 != Null<Real>(), "no strike given for first underlying");
82 QL_REQUIRE(strike1 > 0.0, "negative or null strike given for first underlying");
83 QL_REQUIRE(strike2 != Null<Real>(), "no strike given for second underlying");
84 QL_REQUIRE(strike2 > 0.0, "negative or null strike given for second underlying");
85 QL_REQUIRE(basketStrike != Null<Real>(), "no strike given for basket");
86 QL_REQUIRE(basketStrike > 0.0, "negative or null strike given for basket");
87
88 QL_REQUIRE(notional1 != Null<Real>(), "no notional given for first underlying");
89 QL_REQUIRE(notional1 > 0.0, "negative or null notional given for first underlying");
90 QL_REQUIRE(notional2 != Null<Real>(), "no notional given for second underlying");
91 QL_REQUIRE(notional2 > 0.0, "negative or null notional given for second underlying");
92 QL_REQUIRE(basketNotional != Null<Real>(), "no notional given for basket");
93 QL_REQUIRE(basketNotional > 0.0, "negative or null notional given for basket");
94
95 QL_REQUIRE(cap != Null<Real>(), "no cap given");
96 QL_REQUIRE(cap >= 0.0, "cap must be non-negative");
97 QL_REQUIRE(floor != Null<Real>(), "no floor given");
98 QL_REQUIRE(floor >= 0.0, "floor must be non-negative");
99 QL_REQUIRE(payoffLimit != Null<Real>(), "no payoff limit given");
100 QL_REQUIRE(payoffLimit > 0.0, "payoff limit must be non-negative");
101 QL_REQUIRE(accrualLag != Null<int>(), "no accrual lag given");
102
103 QL_REQUIRE(!valuationSchedule.empty(), "no valuation schedule given");
104 QL_REQUIRE(!laggedValuationSchedule.empty(), "no lagged valuation schedule given");
105 QL_REQUIRE(valuationSchedule.dates().size() == laggedValuationSchedule.dates().size(),
106 "valuation schedule and lagged valuation schedule must have the same size");
107 QL_REQUIRE(settlementDate != Date(), "null settlement date given");
108}
109
110bool PairwiseVarianceSwap::isExpired() const { return detail::simple_event(settlementDate_).hasOccurred(); }
111
113 Instrument::setupExpired();
114 variance1_ = variance2_ = basketVariance_ = Null<Real>();
115}
116
117} // namespace QuantExt
Results from pairwise variance-swap calculation
void setupArguments(PricingEngine::arguments *args) const override
void fetchResults(const PricingEngine::results *) const override
PairwiseVarianceSwap(const Position::Type position, const Real strike1, const Real strike2, const Real basketStrike, const Real notional1, const Real notional2, const Real basketNotional, const Real cap, const Real floor, const Real payoffLimit, const int accrualLag, const Schedule valuationSchedule, const Schedule laggedValuationSchedule, const Date settlementDate)
Pirwise Variance swap.