/src/quantlib/ql/termstructures/volatility/equityfx/andreasenhugevolatilityadapter.cpp
Line | Count | Source |
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 | | <https://www.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 | | |
20 | | #include <ql/math/functional.hpp> |
21 | | #include <ql/pricingengines/blackformula.hpp> |
22 | | #include <ql/termstructures/volatility/equityfx/andreasenhugevolatilityadapter.hpp> |
23 | | #include <ql/termstructures/volatility/equityfx/andreasenhugevolatilityinterpl.hpp> |
24 | | #include <ql/termstructures/yieldtermstructure.hpp> |
25 | | #include <utility> |
26 | | |
27 | | namespace QuantLib { |
28 | | |
29 | | AndreasenHugeVolatilityAdapter::AndreasenHugeVolatilityAdapter( |
30 | | ext::shared_ptr<AndreasenHugeVolatilityInterpl> volInterpl, Real eps) |
31 | 0 | : eps_(eps), volInterpl_(std::move(volInterpl)) {}Unexecuted instantiation: QuantLib::AndreasenHugeVolatilityAdapter::AndreasenHugeVolatilityAdapter(boost::shared_ptr<QuantLib::AndreasenHugeVolatilityInterpl>, double) Unexecuted instantiation: QuantLib::AndreasenHugeVolatilityAdapter::AndreasenHugeVolatilityAdapter(boost::shared_ptr<QuantLib::AndreasenHugeVolatilityInterpl>, double) |
32 | | |
33 | | Real AndreasenHugeVolatilityAdapter::blackVarianceImpl(Time t, Real strike) |
34 | 0 | const { |
35 | 0 | const Real fwd = volInterpl_->fwd(t); |
36 | 0 | const Option::Type optionType = |
37 | 0 | (fwd > strike)? Option::Put : Option::Call; |
38 | |
|
39 | 0 | const Real npv = volInterpl_->optionPrice(t, strike, optionType); |
40 | |
|
41 | 0 | return squared(blackFormulaImpliedStdDevLiRS( |
42 | 0 | optionType, strike, fwd, npv, |
43 | 0 | volInterpl_->riskFreeRate()->discount(t), |
44 | 0 | 0.0, Null<Real>(), 1.0, eps_, 1000)); |
45 | 0 | } |
46 | | |
47 | | |
48 | 0 | Date AndreasenHugeVolatilityAdapter::maxDate() const { |
49 | 0 | return volInterpl_->maxDate(); |
50 | 0 | } |
51 | 0 | Real AndreasenHugeVolatilityAdapter::minStrike() const { |
52 | 0 | return volInterpl_->minStrike(); |
53 | 0 | } |
54 | 0 | Real AndreasenHugeVolatilityAdapter::maxStrike() const { |
55 | 0 | return volInterpl_->maxStrike(); |
56 | 0 | } |
57 | 0 | Calendar AndreasenHugeVolatilityAdapter::calendar() const { |
58 | 0 | return volInterpl_->riskFreeRate()->calendar(); |
59 | 0 | } |
60 | 0 | DayCounter AndreasenHugeVolatilityAdapter::dayCounter() const { |
61 | 0 | return volInterpl_->riskFreeRate()->dayCounter(); |
62 | 0 | } |
63 | 0 | const Date& AndreasenHugeVolatilityAdapter::referenceDate() const { |
64 | 0 | return volInterpl_->riskFreeRate()->referenceDate(); |
65 | 0 | } |
66 | 0 | Natural AndreasenHugeVolatilityAdapter::settlementDays() const { |
67 | 0 | return volInterpl_->riskFreeRate()->settlementDays(); |
68 | 0 | } |
69 | | } |