QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
andreasenhugevolatilityadapter.cpp
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) 2017 Klaus Spanderen
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
25#include <utility>
26
27namespace QuantLib {
28
30 ext::shared_ptr<AndreasenHugeVolatilityInterpl> volInterpl, Real eps)
31 : eps_(eps), volInterpl_(std::move(volInterpl)) {}
32
34 const {
35 const Real fwd = volInterpl_->fwd(t);
36 const Option::Type optionType =
37 (fwd > strike)? Option::Put : Option::Call;
38
39 const Real npv = volInterpl_->optionPrice(t, strike, optionType);
40
42 optionType, strike, fwd, npv,
43 volInterpl_->riskFreeRate()->discount(t),
44 0.0, Null<Real>(), 1.0, eps_, 1000));
45 }
46
47
49 return volInterpl_->maxDate();
50 }
52 return volInterpl_->minStrike();
53 }
55 return volInterpl_->maxStrike();
56 }
58 return volInterpl_->riskFreeRate()->calendar();
59 }
61 return volInterpl_->riskFreeRate()->dayCounter();
62 }
64 return volInterpl_->riskFreeRate()->referenceDate();
65 }
67 return volInterpl_->riskFreeRate()->settlementDays();
68 }
69}
Implements the BlackVolTermStructure interface based on a Andreasen-Huge volatility interpolation.
Andreasen-Huge local volatility calibration and interpolation.
Black formula.
Calendar calendar() const override
the calendar used for reference and/or option date calculation
AndreasenHugeVolatilityAdapter(ext::shared_ptr< AndreasenHugeVolatilityInterpl > volInterpl, Real eps=1e-6)
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
const ext::shared_ptr< AndreasenHugeVolatilityInterpl > volInterpl_
Natural settlementDays() const override
the settlementDays used for reference date calculation
DayCounter dayCounter() const override
the day counter used for date/time conversion
Date maxDate() const override
the latest date for which the curve can return values
Real blackVarianceImpl(Time t, Real strike) const override
Black variance calculation.
Real maxStrike() const override
the maximum strike for which the term structure can return vols
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
template class providing a null value for a given type.
Definition: null.hpp:76
const DefaultType & t
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
functionals and combinators not included in the STL
Definition: any.hpp:35
Real blackFormulaImpliedStdDevLiRS(Option::Type optionType, Real strike, Real forward, Real blackPrice, Real discount, Real displacement, Real guess, Real w, Real accuracy, Natural maxIterations)
T squared(T x)
Definition: functional.hpp:37
STL namespace.
Interest-rate term structure.