QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
localvolcurve.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2002, 2003 Ferdinando Ametrano
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
24#ifndef quantlib_localvolcurve_hpp
25#define quantlib_localvolcurve_hpp
26
27#include <ql/termstructures/volatility/equityfx/blackvariancecurve.hpp>
28#include <ql/termstructures/volatility/equityfx/localvoltermstructure.hpp>
29
30namespace QuantLib {
31
34 public:
37 curve->dayCounter()),
38 blackVarianceCurve_(curve) {
40 }
42
43 const Date& referenceDate() const override { return blackVarianceCurve_->referenceDate(); }
44 Calendar calendar() const override { return blackVarianceCurve_->calendar(); }
45 DayCounter dayCounter() const override { return blackVarianceCurve_->dayCounter(); }
46 Date maxDate() const override { return blackVarianceCurve_->maxDate(); }
48
50 Real minStrike() const override { return QL_MIN_REAL; }
51 Real maxStrike() const override { return QL_MAX_REAL; }
53
55 void accept(AcyclicVisitor&) override;
57 protected:
58 Volatility localVolImpl(Time, Real) const override;
59
60 private:
62 };
63
64
65
66 // inline definitions
67
69 auto* v1 = dynamic_cast<Visitor<LocalVolCurve>*>(&v);
70 if (v1 != nullptr)
71 v1->visit(*this);
72 else
74 }
75
89
90 Time dt = (1.0/365.0);
91 Real var1 = blackVarianceCurve_->blackVariance(t, dummy, true);
92 Real var2 = blackVarianceCurve_->blackVariance(t+dt, dummy, true);
93 Real derivative = (var2-var1)/dt;
94 return std::sqrt(derivative);
95 }
96
97}
98
99
100#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Shared handle to an observable.
Definition: handle.hpp:41
Local volatility curve derived from a Black curve.
Calendar calendar() const override
the calendar used for reference and/or option date calculation
Volatility localVolImpl(Time, Real) const override
const Date & referenceDate() const override
the date at which discount = 1.0 and/or variance = 0.0
Real minStrike() const override
the minimum strike for which the term structure can return vols
void accept(AcyclicVisitor &) override
DayCounter dayCounter() const override
the day counter used for date/time conversion
LocalVolCurve(const Handle< BlackVarianceCurve > &curve)
Date maxDate() const override
the latest date for which the curve can return values
Real maxStrike() const override
the maximum strike for which the term structure can return vols
Handle< BlackVarianceCurve > blackVarianceCurve_
virtual void accept(AcyclicVisitor &)
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
Visitor for a specific class
Definition: visitor.hpp:40
virtual void visit(T &)=0
virtual BusinessDayConvention businessDayConvention() const
the business day convention used in tenor to date conversion
#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
Real Volatility
volatility
Definition: types.hpp:78
Definition: any.hpp:35