QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
quantodoublebarrieroption.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2015 Thema Consulting SA
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
20#include <ql/experimental/barrieroption/quantodoublebarrieroption.hpp>
21
22namespace QuantLib {
23
25 DoubleBarrier::Type barrierType,
26 Real barrier_lo,
27 Real barrier_hi,
28 Real rebate,
29 const ext::shared_ptr<StrikedTypePayoff>& payoff,
30 const ext::shared_ptr<Exercise>& exercise)
31 : DoubleBarrierOption(barrierType, barrier_lo, barrier_hi, rebate, payoff, exercise) {}
32
34 calculate();
35 QL_REQUIRE(qvega_ != Null<Real>(),
36 "exchange rate vega calculation failed");
37 return qvega_;
38 }
39
41 calculate();
42 QL_REQUIRE(qrho_ != Null<Real>(),
43 "foreign interest rate rho calculation failed");
44 return qrho_;
45 }
46
48 calculate();
49 QL_REQUIRE(qlambda_ != Null<Real>(),
50 "quanto correlation sensitivity calculation failed");
51 return qlambda_;
52 }
53
56 qvega_ = qrho_ = qlambda_ = 0.0;
57 }
58
60 const PricingEngine::results* r) const {
62 const auto* quantoResults = dynamic_cast<const QuantoDoubleBarrierOption::results*>(r);
63 QL_ENSURE(quantoResults != nullptr, "no quanto results returned from pricing engine");
64 qrho_ = quantoResults->qrho;
65 qvega_ = quantoResults->qvega;
66 qlambda_ = quantoResults->qlambda;
67 }
68
69}
70
Double 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
void fetchResults(const PricingEngine::results *) const override
QuantoDoubleBarrierOption(DoubleBarrier::Type barrierType, Real barrier_lo, Real barrier_hi, Real rebate, const ext::shared_ptr< StrikedTypePayoff > &payoff, const ext::shared_ptr< Exercise > &exercise)
Results from quanto option calculation
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35