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/*! \file atmsmilesection.hpp
21 \brief smile section that allows for explicit / alternate specification of
22 atm level
23*/
24
25#ifndef quantlib_atm_smile_section_hpp
26#define quantlib_atm_smile_section_hpp
27
28#include <ql/termstructures/volatility/smilesection.hpp>
29
30namespace QuantLib {
31
32 class AtmSmileSection : public SmileSection {
33
34 public:
35 AtmSmileSection(const ext::shared_ptr<SmileSection>& source, Real atm = Null<Real>());
36
37 Real minStrike() const override { return source_->minStrike(); }
38 Real maxStrike() const override { return source_->maxStrike(); }
39 Real atmLevel() const override { return f_; }
40 const Date& exerciseDate() const override { return source_->exerciseDate(); }
41 Time exerciseTime() const override { return source_->exerciseTime(); }
42 const DayCounter& dayCounter() const override { return source_->dayCounter(); }
43 const Date& referenceDate() const override { return source_->referenceDate(); }
44 VolatilityType volatilityType() const override { return source_->volatilityType(); }
45 Rate shift() const override { return source_->shift(); }
46
47 protected:
48 Volatility volatilityImpl(Rate strike) const override {
49 return source_->volatility(strike);
50 }
51 Real varianceImpl(Rate strike) const override { return source_->variance(strike); }
52
53 private:
54 ext::shared_ptr<SmileSection> source_;
55 Real f_;
56 };
57}
58
59#endif
60

source code of quantlib/ql/termstructures/volatility/atmsmilesection.hpp