QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
varianceswap.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2006 Warren Chou
5 Copyright (C) 2008 StatPro Italia srl
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
21/*! \file varianceswap.hpp
22 \brief Variance swap
23*/
24
25#ifndef quantlib_variance_swap_hpp
26#define quantlib_variance_swap_hpp
27
30#include <ql/option.hpp>
31#include <ql/position.hpp>
32
33namespace QuantLib {
34
35 //! Variance swap
36 /*! \warning This class does not manage seasoned variance swaps.
37
38 \ingroup instruments
39 */
40 class VarianceSwap : public Instrument {
41 public:
42 class arguments;
43 class results;
44 class engine;
48 const Date& startDate,
49 const Date& maturityDate);
50 //! \name Instrument interface
51 //@{
52 bool isExpired() const override;
53 //@}
54 //! \name Additional interface
55 //@{
56 // inspectors
57 Real strike() const;
59 Date startDate() const;
60 Date maturityDate() const;
61 Real notional() const;
62 // results
63 Real variance() const;
64 //@}
65 // other
66 void setupArguments(PricingEngine::arguments* args) const override;
67 void fetchResults(const PricingEngine::results*) const override;
68
69 protected:
70 void setupExpired() const override;
71 // data members
76 // results
77 mutable Real variance_;
78 };
79
80
81 //! %Arguments for forward fair-variance calculation
83 public:
85 void validate() const override;
91 };
92
93
94 //! %Results from variance-swap calculation
96 public:
98 void reset() override {
101 }
102 };
103
104 //! base class for variance-swap engines
106 public GenericEngine<VarianceSwap::arguments,
107 VarianceSwap::results> {};
108
109
110 // inline definitions
111
113 return startDate_;
114 }
115
117 return maturityDate_;
118 }
119
120 inline Real VarianceSwap::strike() const {
121 return strike_;
122 }
123
125 return notional_;
126 }
127
129 return position_;
130 }
131
132}
133
134
135#endif
Black-Scholes processes.
Concrete date class.
Definition: date.hpp:125
template base class for option pricing engines
Abstract instrument class.
Definition: instrument.hpp:44
template class providing a null value for a given type.
Definition: null.hpp:76
Arguments for forward fair-variance calculation
void validate() const override
base class for variance-swap engines
Results from variance-swap calculation
bool isExpired() const override
returns whether the instrument might have value greater than zero.
void setupArguments(PricingEngine::arguments *args) const override
Position::Type position_
Position::Type position() const
void setupExpired() const override
void fetchResults(const PricingEngine::results *) const override
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35
Base option class.
Payoffs for various options.
Short or long position.