25#ifndef quantlib_quanto_engine_hpp
26#define quantlib_quanto_engine_hpp
48 template <
class Instr,
class Engine>
51 QuantoOptionResults<typename Instr::results> > {
53 QuantoEngine(ext::shared_ptr<GeneralizedBlackScholesProcess>,
60 ext::shared_ptr<GeneralizedBlackScholesProcess>
process_;
69 template <
class Instr,
class Engine>
71 ext::shared_ptr<GeneralizedBlackScholesProcess> process,
75 : process_(
std::move(process)), foreignRiskFreeRate_(
std::move(foreignRiskFreeRate)),
76 exchangeRateVolatility_(
std::move(exchangeRateVolatility)),
84 template <
class Instr,
class Engine>
88 Real exchangeRateATMlevel = 1.0;
91 ext::shared_ptr<StrikedTypePayoff>
payoff =
92 ext::dynamic_pointer_cast<StrikedTypePayoff>(
93 this->arguments_.payoff);
98 QL_REQUIRE(spot->value() > 0.0,
"negative or null underlying");
102 ext::shared_ptr<YieldTermStructure>(
104 process_->riskFreeRate(),
105 foreignRiskFreeRate_,
106 process_->blackVolatility(),
108 exchangeRateVolatility_,
109 exchangeRateATMlevel,
113 ext::shared_ptr<GeneralizedBlackScholesProcess> quantoProcess(
115 riskFreeRate, blackVol));
117 ext::shared_ptr<Engine> originalEngine(
new Engine(quantoProcess));
118 originalEngine->reset();
119 auto* originalArguments =
120 dynamic_cast<typename Instr::arguments*
>(originalEngine->getArguments());
121 QL_REQUIRE(originalArguments,
"wrong engine type");
123 *originalArguments = this->arguments_;
125 originalArguments->validate();
126 originalEngine->calculate();
128 const auto* originalResults =
129 dynamic_cast<const typename Instr::results*
>(originalEngine->getResults());
130 QL_REQUIRE(originalResults,
"wrong engine type");
133 this->
results_.delta = originalResults->delta;
134 this->
results_.gamma = originalResults->gamma;
135 this->
results_.theta = originalResults->theta;
137 originalResults->dividendRho !=
Null<Real>()) {
138 this->
results_.rho = originalResults->rho +
139 originalResults->dividendRho;
140 this->
results_.dividendRho = originalResults->dividendRho;
145 exchangeRateVolatility_->blackVol(
146 this->arguments_.exercise->lastDate(),
147 exchangeRateATMlevel);
149 && originalResults->dividendRho !=
Null<Real>()) {
150 this->
results_.vega = originalResults->vega +
152 originalResults->dividendRho;
157 if (originalResults->dividendRho !=
Null<Real>()) {
158 Volatility volatility = process_->blackVolatility()->blackVol(
159 this->arguments_.exercise->lastDate(),
160 process_->stateVariable()->value());
162 process_->blackVolatility()->blackVol(
163 this->arguments_.exercise->lastDate(),
164 process_->stateVariable()->value()) *
165 originalResults->dividendRho;
166 this->
results_.qrho = - originalResults->dividendRho;
167 this->
results_.qlambda = exchangeRateFlatVol *
168 volatility * originalResults->dividendRho;
const Instrument::results * results_
Generalized Black-Scholes stochastic process.
template base class for option pricing engines
Shared handle to an observable.
template class providing a null value for a given type.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Handle< Quote > correlation_
Handle< YieldTermStructure > foreignRiskFreeRate_
QuantoEngine(ext::shared_ptr< GeneralizedBlackScholesProcess >, Handle< YieldTermStructure > foreignRiskFreeRate, Handle< BlackVolTermStructure > exchangeRateVolatility, Handle< Quote > correlation)
void calculate() const override
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
Handle< BlackVolTermStructure > exchangeRateVolatility_
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Real Volatility
volatility
ext::shared_ptr< QuantLib::Payoff > payoff
Payoffs for various options.
Quanto version of a vanilla option.