QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
quantovanillaoption.cpp
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) 2002, 2003 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
22
23namespace QuantLib {
24
26 const ext::shared_ptr<StrikedTypePayoff>& payoff,
27 const ext::shared_ptr<Exercise>& exercise)
28 : OneAssetOption(payoff, exercise) {}
29
31 calculate();
33 "exchange rate vega calculation failed");
34 return qvega_;
35 }
36
38 calculate();
40 "foreign interest rate rho calculation failed");
41 return qrho_;
42 }
43
45 calculate();
47 "quanto correlation sensitivity calculation failed");
48 return qlambda_;
49 }
50
53 qvega_ = qrho_ = qlambda_ = 0.0;
54 }
55
57 const PricingEngine::results* r) const {
59 const auto* quantoResults = dynamic_cast<const QuantoVanillaOption::results*>(r);
60 QL_ENSURE(quantoResults != nullptr, "no quanto results returned from pricing engine");
61 qrho_ = quantoResults->qrho;
62 qvega_ = quantoResults->qvega;
63 qlambda_ = quantoResults->qlambda;
64 }
65
66}
67
void calculate() const override
Definition: instrument.hpp:129
template class providing a null value for a given type.
Definition: null.hpp:76
Base class for options on a single asset.
void setupExpired() const override
void fetchResults(const PricingEngine::results *) const override
Results from quanto option calculation
QuantoVanillaOption(const ext::shared_ptr< StrikedTypePayoff > &, const ext::shared_ptr< Exercise > &)
void setupExpired() const override
void fetchResults(const PricingEngine::results *) const override
#define QL_ENSURE(condition, message)
throw an error if the given post-condition is not verified
Definition: errors.hpp:130
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
QL_REAL Real
real number
Definition: types.hpp:50
ext::shared_ptr< QuantLib::Payoff > payoff
Definition: any.hpp:35
ext::shared_ptr< YieldTermStructure > r
Quanto version of a vanilla option.