QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
atmadjustedsmilesection.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2013 Peter Caspers
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
20#include <ql/termstructures/volatility/atmadjustedsmilesection.hpp>
21
22namespace QuantLib {
23
24 AtmAdjustedSmileSection::AtmAdjustedSmileSection(const ext::shared_ptr<SmileSection>& source,
25 const Real atm,
26 const bool recenterSmile)
27 : SmileSection(*source), source_(source) {
28
29 f_ = atm;
30 if (f_ == Null<Real>())
31 f_ = source_->atmLevel();
32 if (recenterSmile && f_ != Null<Real>() &&
33 source_->atmLevel() != Null<Real>())
34 adjustment_ = source_->atmLevel() - f_;
35 else
36 adjustment_ = 0.0;
37
38 }
39
41 return strike + adjustment_;
42 }
43
45 return source_->variance(adjustedStrike(strike));
46 }
47
49 return source_->volatility(adjustedStrike(strike));
50 }
51
52}
AtmAdjustedSmileSection(const ext::shared_ptr< SmileSection > &source, Real atm=Null< Real >(), bool recenterSmile=false)
ext::shared_ptr< SmileSection > source_
Real varianceImpl(Rate strike) const override
Volatility volatilityImpl(Rate strike) const override
template class providing a null value for a given type.
Definition: null.hpp:76
interest rate volatility smile section
QL_REAL Real
real number
Definition: types.hpp:50
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35