QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
forwardperformanceengine.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2002, 2003, 2004 Ferdinando Ametrano
5 Copyright (C) 2007 StatPro Italia srl
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
25#ifndef quantlib_forward_performance_engine_hpp
26#define quantlib_forward_performance_engine_hpp
27
28#include <ql/pricingengines/forward/forwardengine.hpp>
29
30namespace QuantLib {
31
33
41 template <class Engine>
43 : public ForwardVanillaEngine<Engine> {
44 public:
46 const ext::shared_ptr<GeneralizedBlackScholesProcess>&);
47 void calculate() const override;
48
49 protected:
50 void getOriginalResults() const;
51 };
52
53
54 // template definitions
55
56 template <class Engine>
58 const ext::shared_ptr<GeneralizedBlackScholesProcess>& process)
59 : ForwardVanillaEngine<Engine>(process) {}
60
61 template <class Engine>
63 this->setup();
64 this->originalEngine_->calculate();
65 getOriginalResults();
66 }
67
68 template <class Engine>
70
71 DayCounter rfdc = this->process_->riskFreeRate()->dayCounter();
72 Time resetTime = rfdc.yearFraction(
73 this->process_->riskFreeRate()->referenceDate(),
74 this->arguments_.resetDate);
75 DiscountFactor discR = this->process_->riskFreeRate()->discount(
76 this->arguments_.resetDate);
77 // it's a performance option
78 discR /= this->process_->stateVariable()->value();
79
80 Real temp = this->originalResults_->value;
81 this->results_.value = discR * temp;
82 this->results_.delta = 0.0;
83 this->results_.gamma = 0.0;
84 this->results_.theta = this->process_->riskFreeRate()->
85 zeroRate(this->arguments_.resetDate, rfdc, Continuous, NoFrequency)
86 * this->results_.value;
87 this->results_.vega = discR * this->originalResults_->vega;
88 this->results_.rho = - resetTime * this->results_.value +
89 discR * this->originalResults_->rho;
90 this->results_.dividendRho = discR * this->originalResults_->dividendRho;
91 }
92
93}
94
95
96#endif
day counter class
Definition: daycounter.hpp:44
Time yearFraction(const Date &, const Date &, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date()) const
Returns the period between two dates as a fraction of year.
Definition: daycounter.hpp:128
Forward performance engine for vanilla options
ForwardPerformanceVanillaEngine(const ext::shared_ptr< GeneralizedBlackScholesProcess > &)
Forward engine for vanilla options
@ NoFrequency
null frequency
Definition: frequency.hpp:37
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Real DiscountFactor
discount factor between dates
Definition: types.hpp:66
Definition: any.hpp:35