QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
blackconstantvol.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) 2002, 2003, 2004 Ferdinando Ametrano
5 Copyright (C) 2003, 2004, 2005, 2006, 2007 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 blackconstantvol.hpp
22 \brief Black constant volatility, no time dependence, no strike dependence
23*/
24
25#ifndef quantlib_blackconstantvol_hpp
26#define quantlib_blackconstantvol_hpp
27
31#include <utility>
32
33namespace QuantLib {
34
35 //! Constant Black volatility, no time-strike dependence
36 /*! This class implements the BlackVolatilityTermStructure
37 interface for a constant Black volatility (no time/strike
38 dependence).
39 */
41 public:
43 const Calendar&,
44 Volatility volatility,
45 const DayCounter& dayCounter);
47 const Calendar&,
48 Handle<Quote> volatility,
49 const DayCounter& dayCounter);
51 const Calendar&,
52 Volatility volatility,
53 const DayCounter& dayCounter);
55 const Calendar&,
56 Handle<Quote> volatility,
57 const DayCounter& dayCounter);
58 //! \name TermStructure interface
59 //@{
60 Date maxDate() const override;
61 //@}
62 //! \name VolatilityTermStructure interface
63 //@{
64 Real minStrike() const override;
65 Real maxStrike() const override;
66 //@}
67 //! \name Visitability
68 //@{
69 void accept(AcyclicVisitor&) override;
70 //@}
71 protected:
72 Volatility blackVolImpl(Time t, Real) const override;
73
74 private:
76 };
77
78
79 // inline definitions
80
81 inline BlackConstantVol::BlackConstantVol(const Date& referenceDate,
82 const Calendar& cal,
83 Volatility volatility,
84 const DayCounter& dc)
85 : BlackVolatilityTermStructure(referenceDate, cal, Following, dc),
86 volatility_(ext::shared_ptr<Quote>(new SimpleQuote(volatility))) {}
87
88 inline BlackConstantVol::BlackConstantVol(const Date& referenceDate,
89 const Calendar& cal,
90 Handle<Quote> volatility,
91 const DayCounter& dc)
92 : BlackVolatilityTermStructure(referenceDate, cal, Following, dc),
93 volatility_(std::move(volatility)) {
95 }
96
98 const Calendar& cal,
99 Volatility volatility,
100 const DayCounter& dc)
101 : BlackVolatilityTermStructure(settlementDays, cal, Following, dc),
102 volatility_(ext::shared_ptr<Quote>(new SimpleQuote(volatility))) {}
103
105 const Calendar& cal,
106 Handle<Quote> volatility,
107 const DayCounter& dc)
108 : BlackVolatilityTermStructure(settlementDays, cal, Following, dc),
109 volatility_(std::move(volatility)) {
111 }
112
114 return Date::maxDate();
115 }
116
118 return QL_MIN_REAL;
119 }
120
122 return QL_MAX_REAL;
123 }
124
126 auto* v1 = dynamic_cast<Visitor<BlackConstantVol>*>(&v);
127 if (v1 != nullptr)
128 v1->visit(*this);
129 else
131 }
132
134 return volatility_->value();
135 }
136
137}
138
139
140#endif
Actual/365 (Fixed) day counter.
Black volatility term structure base classes.
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Constant Black volatility, no time-strike dependence.
Real minStrike() const override
the minimum strike for which the term structure can return vols
void accept(AcyclicVisitor &) override
BlackConstantVol(const Date &referenceDate, const Calendar &, Volatility volatility, const DayCounter &dayCounter)
Date maxDate() const override
the latest date for which the curve can return values
Volatility blackVolImpl(Time t, Real) const override
Black volatility calculation.
Real maxStrike() const override
the maximum strike for which the term structure can return vols
void accept(AcyclicVisitor &) override
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
static Date maxDate()
latest allowed date
Definition: date.cpp:771
day counter class
Definition: daycounter.hpp:44
Shared handle to an observable.
Definition: handle.hpp:41
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
purely virtual base class for market observables
Definition: quote.hpp:37
market element returning a stored value
Definition: simplequote.hpp:33
virtual Natural settlementDays() const
the settlementDays used for reference date calculation
virtual const Date & referenceDate() const
the date at which discount = 1.0 and/or variance = 0.0
virtual DayCounter dayCounter() const
the day counter used for date/time conversion
Visitor for a specific class
Definition: visitor.hpp:40
virtual void visit(T &)=0
const DefaultType & t
#define QL_MAX_REAL
Definition: qldefines.hpp:176
#define QL_MIN_REAL
Definition: qldefines.hpp:175
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Volatility
volatility
Definition: types.hpp:78
Definition: any.hpp:35
STL namespace.
ext::shared_ptr< BlackVolTermStructure > v
simple quote class