Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
AnalyticEuropeanForwardEngine Class Reference

Pricing engine for European vanilla forward options using analytical formulae. More...

#include <qle/pricingengines/analyticeuropeanforwardengine.hpp>

+ Inheritance diagram for AnalyticEuropeanForwardEngine:
+ Collaboration diagram for AnalyticEuropeanForwardEngine:

Public Member Functions

 AnalyticEuropeanForwardEngine (const QuantLib::ext::shared_ptr< QuantLib::GeneralizedBlackScholesProcess > &)
 
 AnalyticEuropeanForwardEngine (const QuantLib::ext::shared_ptr< QuantLib::GeneralizedBlackScholesProcess > &process, const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve)
 
void calculate () const override
 

Private Attributes

QuantLib::ext::shared_ptr< QuantLib::GeneralizedBlackScholesProcess > process_
 
QuantLib::Handle< QuantLib::YieldTermStructure > discountCurve_
 

Detailed Description

Pricing engine for European vanilla forward options using analytical formulae.

Definition at line 53 of file analyticeuropeanforwardengine.hpp.

Constructor & Destructor Documentation

◆ AnalyticEuropeanForwardEngine() [1/2]

AnalyticEuropeanForwardEngine ( const QuantLib::ext::shared_ptr< QuantLib::GeneralizedBlackScholesProcess > &  process)
explicit

This constructor triggers the usual calculation, in which the risk-free rate in the given process is used for both forecasting and discounting.

Definition at line 60 of file analyticeuropeanforwardengine.cpp.

62 : process_(process) {
63 registerWith(process_);
64 }
QuantLib::ext::shared_ptr< QuantLib::GeneralizedBlackScholesProcess > process_

◆ AnalyticEuropeanForwardEngine() [2/2]

AnalyticEuropeanForwardEngine ( const QuantLib::ext::shared_ptr< QuantLib::GeneralizedBlackScholesProcess > &  process,
const QuantLib::Handle< QuantLib::YieldTermStructure > &  discountCurve 
)

This constructor allows to use a different term structure for discounting the payoff. As usual, the risk-free rate from the given process is used for forecasting the forward price.

Definition at line 66 of file analyticeuropeanforwardengine.cpp.

69 : process_(process), discountCurve_(discountCurve) {
70 registerWith(process_);
71 registerWith(discountCurve_);
72 }
QuantLib::Handle< QuantLib::YieldTermStructure > discountCurve_

Member Function Documentation

◆ calculate()

void calculate ( ) const
override

Definition at line 74 of file analyticeuropeanforwardengine.cpp.

74 {
75
76 // if the discount curve is not specified, we default to the
77 // risk free rate curve embedded within the GBM process
78 QuantLib::ext::shared_ptr<YieldTermStructure> discountPtr =
79 discountCurve_.empty() ?
80 process_->riskFreeRate().currentLink() :
81 discountCurve_.currentLink();
82
83 QL_REQUIRE(arguments_.exercise->type() == Exercise::European,
84 "not an European option");
85
86 QuantLib::ext::shared_ptr<StrikedTypePayoff> payoff =
87 QuantLib::ext::dynamic_pointer_cast<StrikedTypePayoff>(arguments_.payoff);
88 QL_REQUIRE(payoff, "non-striked payoff given");
89
90 Real variance =
91 process_->blackVolatility()->blackVariance(
92 arguments_.exercise->lastDate(),
93 payoff->strike());
94 DiscountFactor dividendDiscount =
95 process_->dividendYield()->discount(
96 arguments_.forwardDate);
97 DiscountFactor df;
98 if (arguments_.paymentDate != Date())
99 df = discountPtr->discount(arguments_.paymentDate);
100 else
101 df = discountPtr->discount(arguments_.exercise->lastDate());
102 DiscountFactor riskFreeDiscountForFwdEstimation =
103 process_->riskFreeRate()->discount(arguments_.forwardDate);
104 Real spot = process_->stateVariable()->value();
105 QL_REQUIRE(spot > 0.0, "negative or null underlying given");
106 Real forwardPrice = spot * dividendDiscount / riskFreeDiscountForFwdEstimation;
107
108 QuantLib::BlackCalculator black(payoff, forwardPrice, std::sqrt(variance),df);
109
110
111 results_.value = black.value();
112 results_.delta = black.delta(spot);
113 results_.deltaForward = black.deltaForward();
114 results_.elasticity = black.elasticity(spot);
115 results_.gamma = black.gamma(spot);
116
117 DayCounter rfdc = discountPtr->dayCounter();
118 DayCounter divdc = process_->dividendYield()->dayCounter();
119 DayCounter voldc = process_->blackVolatility()->dayCounter();
120 Time t = rfdc.yearFraction(process_->riskFreeRate()->referenceDate(),
121 arguments_.exercise->lastDate());
122 results_.rho = black.rho(t);
123
124 t = divdc.yearFraction(process_->dividendYield()->referenceDate(),
125 arguments_.exercise->lastDate());
126 results_.dividendRho = black.dividendRho(t);
127
128 t = voldc.yearFraction(process_->blackVolatility()->referenceDate(),
129 arguments_.exercise->lastDate());
130 results_.vega = black.vega(t);
131 try {
132 results_.theta = black.theta(spot, t);
133 results_.thetaPerDay =
134 black.thetaPerDay(spot, t);
135 } catch (Error&) {
136 results_.theta = Null<Real>();
137 results_.thetaPerDay = Null<Real>();
138 }
139
140 results_.strikeSensitivity = black.strikeSensitivity();
141 results_.itmCashProbability = black.itmCashProbability();
142
143 Real tte = process_->blackVolatility()->timeFromReference(arguments_.exercise->lastDate());
144 results_.additionalResults["spot"] = spot;
145 results_.additionalResults["dividendDiscount"] = dividendDiscount;
146 results_.additionalResults["riskFreeDiscount"] = riskFreeDiscountForFwdEstimation;
147 results_.additionalResults["forward"] = forwardPrice;
148 results_.additionalResults["strike"] = payoff->strike();
149 results_.additionalResults["volatility"] = std::sqrt(variance / tte);
150 results_.additionalResults["timeToExpiry"] = tte;
151 results_.additionalResults["discountFactor"] = df;
152 }
const Instrument::results * results_
Definition: cdsoption.cpp:81
RandomVariable variance(const RandomVariable &r)
RandomVariable black(const RandomVariable &omega, const RandomVariable &t, const RandomVariable &strike, const RandomVariable &forward, const RandomVariable &impliedVol)
Swap::arguments * arguments_
+ Here is the call graph for this function:

Member Data Documentation

◆ process_

QuantLib::ext::shared_ptr<QuantLib::GeneralizedBlackScholesProcess> process_
private

Definition at line 72 of file analyticeuropeanforwardengine.hpp.

◆ discountCurve_

QuantLib::Handle<QuantLib::YieldTermStructure> discountCurve_
private

Definition at line 73 of file analyticeuropeanforwardengine.hpp.