QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
fdblackscholesvanillaengine.hpp
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) 2008 Andreas Gaida
5 Copyright (C) 2008 Ralph Schreyer
6 Copyright (C) 2008, 2009 Klaus Spanderen
7
8 This file is part of QuantLib, a free-software/open-source library
9 for financial quantitative analysts and developers - http://quantlib.org/
10
11 QuantLib is free software: you can redistribute it and/or modify it
12 under the terms of the QuantLib license. You should have received a
13 copy of the license along with this program; if not, please email
14 <quantlib-dev@lists.sf.net>. The license is also available online at
15 <http://quantlib.org/license.shtml>.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the license for more details.
20*/
21
22/*! \file fdblackscholesvanillaengine.hpp
23 \brief Finite-differences Black Scholes vanilla option engine
24*/
25
26#ifndef quantlib_fd_black_scholes_vanilla_engine_hpp
27#define quantlib_fd_black_scholes_vanilla_engine_hpp
28
29#include <ql/pricingengine.hpp>
32
33namespace QuantLib {
34
35 class FdmQuantoHelper;
36 class GeneralizedBlackScholesProcess;
37
38 //! Finite-differences Black Scholes vanilla option engine
39 /*! \ingroup vanillaengines
40
41 \test the correctness of the returned value is tested by
42 reproducing results available in web/literature
43 and comparison with Black pricing.
44 */
46 public:
48
50 ext::shared_ptr<GeneralizedBlackScholesProcess>,
51 Size tGrid = 100,
52 Size xGrid = 100,
53 Size dampingSteps = 0,
54 const FdmSchemeDesc& schemeDesc = FdmSchemeDesc::Douglas(),
55 bool localVol = false,
56 Real illegalLocalVolOverwrite = -Null<Real>(),
57 CashDividendModel cashDividendModel = Spot);
58
60 ext::shared_ptr<GeneralizedBlackScholesProcess>,
61 DividendSchedule dividends,
62 Size tGrid = 100,
63 Size xGrid = 100,
64 Size dampingSteps = 0,
65 const FdmSchemeDesc& schemeDesc = FdmSchemeDesc::Douglas(),
66 bool localVol = false,
67 Real illegalLocalVolOverwrite = -Null<Real>(),
68 CashDividendModel cashDividendModel = Spot);
69
71 ext::shared_ptr<GeneralizedBlackScholesProcess>,
72 ext::shared_ptr<FdmQuantoHelper> quantoHelper,
73 Size tGrid = 100,
74 Size xGrid = 100,
75 Size dampingSteps = 0,
76 const FdmSchemeDesc& schemeDesc = FdmSchemeDesc::Douglas(),
77 bool localVol = false,
78 Real illegalLocalVolOverwrite = -Null<Real>(),
79 CashDividendModel cashDividendModel = Spot);
80
82 ext::shared_ptr<GeneralizedBlackScholesProcess>,
83 DividendSchedule dividends,
84 ext::shared_ptr<FdmQuantoHelper> quantoHelper,
85 Size tGrid = 100,
86 Size xGrid = 100,
87 Size dampingSteps = 0,
88 const FdmSchemeDesc& schemeDesc = FdmSchemeDesc::Douglas(),
89 bool localVol = false,
90 Real illegalLocalVolOverwrite = -Null<Real>(),
91 CashDividendModel cashDividendModel = Spot);
92
93 void calculate() const override;
94
95 private:
96 ext::shared_ptr<GeneralizedBlackScholesProcess> process_;
102 ext::shared_ptr<FdmQuantoHelper> quantoHelper_;
104 };
105
106
108 public:
110 ext::shared_ptr<GeneralizedBlackScholesProcess> process);
111
113 const ext::shared_ptr<FdmQuantoHelper>& quantoHelper);
114
118 Size dampingSteps);
119
121 const FdmSchemeDesc& schemeDesc);
122
125 Real illegalLocalVolOverwrite);
126
128 const std::vector<Date>& dividendDates,
129 const std::vector<Real>& dividendAmounts);
130
133
134 operator ext::shared_ptr<PricingEngine>() const;
135 private:
136 ext::shared_ptr<GeneralizedBlackScholesProcess> process_;
138 Size tGrid_ = 100, xGrid_ = 100, dampingSteps_ = 0;
139 ext::shared_ptr<FdmSchemeDesc> schemeDesc_;
140 bool localVol_ = false;
142 ext::shared_ptr<FdmQuantoHelper> quantoHelper_;
144 };
145
146}
147
148#endif
Finite-differences Black Scholes vanilla option engine.
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
ext::shared_ptr< FdmQuantoHelper > quantoHelper_
MakeFdBlackScholesVanillaEngine & withIllegalLocalVolOverwrite(Real illegalLocalVolOverwrite)
MakeFdBlackScholesVanillaEngine & withLocalVol(bool localVol)
MakeFdBlackScholesVanillaEngine & withCashDividendModel(FdBlackScholesVanillaEngine::CashDividendModel cashDividendModel)
MakeFdBlackScholesVanillaEngine & withTGrid(Size tGrid)
FdBlackScholesVanillaEngine::CashDividendModel cashDividendModel_
MakeFdBlackScholesVanillaEngine & withDampingSteps(Size dampingSteps)
MakeFdBlackScholesVanillaEngine & withQuantoHelper(const ext::shared_ptr< FdmQuantoHelper > &quantoHelper)
MakeFdBlackScholesVanillaEngine & withXGrid(Size xGrid)
MakeFdBlackScholesVanillaEngine & withCashDividends(const std::vector< Date > &dividendDates, const std::vector< Real > &dividendAmounts)
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
MakeFdBlackScholesVanillaEngine & withFdmSchemeDesc(const FdmSchemeDesc &schemeDesc)
template class providing a null value for a given type.
Definition: null.hpp:76
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
std::vector< ext::shared_ptr< Dividend > > DividendSchedule
Base class for pricing engines.
static FdmSchemeDesc Douglas()
Vanilla option on a single asset.