QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
quantobarrieroption.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) 2008 Paul Farrington
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy 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
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
21
22namespace QuantLib {
23
25 Barrier::Type barrierType,
26 Real barrier,
27 Real rebate,
28 const ext::shared_ptr<StrikedTypePayoff>& payoff,
29 const ext::shared_ptr<Exercise>& exercise)
30 : BarrierOption(barrierType, barrier, rebate, payoff, exercise) {}
31
33 calculate();
35 "exchange rate vega calculation failed");
36 return qvega_;
37 }
38
40 calculate();
42 "foreign interest rate rho calculation failed");
43 return qrho_;
44 }
45
47 calculate();
49 "quanto correlation sensitivity calculation failed");
50 return qlambda_;
51 }
52
55 qvega_ = qrho_ = qlambda_ = 0.0;
56 }
57
59 const PricingEngine::results* r) const {
61 const auto* quantoResults = dynamic_cast<const QuantoBarrierOption::results*>(r);
62 QL_ENSURE(quantoResults != nullptr, "no quanto results returned from pricing engine");
63 qrho_ = quantoResults->qrho;
64 qvega_ = quantoResults->qvega;
65 qlambda_ = quantoResults->qlambda;
66 }
67
68}
69
Barrier option on a single asset.
void calculate() const override
Definition: instrument.hpp:129
virtual void fetchResults(const PricingEngine::results *) const
Definition: instrument.hpp:155
virtual void setupExpired() const
Definition: instrument.hpp:140
template class providing a null value for a given type.
Definition: null.hpp:76
QuantoBarrierOption(Barrier::Type barrierType, Real barrier, Real rebate, const ext::shared_ptr< StrikedTypePayoff > &payoff, const ext::shared_ptr< Exercise > &exercise)
void setupExpired() const override
void fetchResults(const PricingEngine::results *) const override
Results from quanto option calculation
#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 barrier option.