QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
fftengine.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4Copyright (C) 2010 Adrian O' Neill
5
6This file is part of QuantLib, a free-software/open-source library
7for financial quantitative analysts and developers - http://quantlib.org/
8
9QuantLib is free software: you can redistribute it and/or modify it
10under the terms of the QuantLib license. You should have received a
11copy 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
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
24#ifndef quantlib_fft_engine_hpp
25#define quantlib_fft_engine_hpp
26
27#include <ql/instruments/vanillaoption.hpp>
28#include <ql/stochasticprocess.hpp>
29#include <complex>
30
31namespace QuantLib {
32
34
47 class FFTEngine :
48 public VanillaOption::engine {
49 public:
50 FFTEngine(ext::shared_ptr<StochasticProcess1D> process, Real logStrikeSpacing);
51 void calculate() const override;
52 void update() override;
53
54 void precalculate(const std::vector<ext::shared_ptr<Instrument> >& optionList);
55 virtual std::unique_ptr<FFTEngine> clone() const = 0;
56 protected:
57 virtual void precalculateExpiry(Date d) = 0;
58 virtual std::complex<Real> complexFourierTransform(std::complex<Real> u) const = 0;
59 virtual Real discountFactor(Date d) const = 0;
60 virtual Real dividendYield(Date d) const = 0;
61 void calculateUncached(const ext::shared_ptr<StrikedTypePayoff>& payoff,
62 const ext::shared_ptr<Exercise>& exercise) const;
63
64 ext::shared_ptr<StochasticProcess1D> process_;
65 Real lambda_; // Log strike spacing
66
67 private:
68 typedef std::map<ext::shared_ptr<StrikedTypePayoff>, Real> PayoffResultMap;
69 typedef std::map<Date, PayoffResultMap> ResultMap;
71 };
72
73}
74
75
76#endif
77
Concrete date class.
Definition: date.hpp:125
Base class for FFT pricing engines for European vanilla options.
Definition: fftengine.hpp:48
virtual void precalculateExpiry(Date d)=0
void update() override
Definition: fftengine.cpp:58
void calculateUncached(const ext::shared_ptr< StrikedTypePayoff > &payoff, const ext::shared_ptr< Exercise > &exercise) const
Definition: fftengine.cpp:67
void calculate() const override
Definition: fftengine.cpp:34
ext::shared_ptr< StochasticProcess1D > process_
Definition: fftengine.hpp:64
void precalculate(const std::vector< ext::shared_ptr< Instrument > > &optionList)
Definition: fftengine.cpp:79
virtual Real dividendYield(Date d) const =0
std::map< ext::shared_ptr< StrikedTypePayoff >, Real > PayoffResultMap
Definition: fftengine.hpp:68
virtual std::complex< Real > complexFourierTransform(std::complex< Real > u) const =0
virtual Real discountFactor(Date d) const =0
ResultMap resultMap_
Definition: fftengine.hpp:70
virtual std::unique_ptr< FFTEngine > clone() const =0
std::map< Date, PayoffResultMap > ResultMap
Definition: fftengine.hpp:69
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35