Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
outperformanceoption.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
21
22#include <ql/exercise.hpp>
23#include <ql/instruments/payoffs.hpp>
24#include <ql/math/distributions/normaldistribution.hpp>
25#include <ql/math/solvers1d/brent.hpp>
26#include <ql/quotes/simplequote.hpp>
27#include <ql/termstructures/volatility/equityfx/blackconstantvol.hpp>
28#include <ql/termstructures/yieldtermstructure.hpp>
29
30#include <boost/make_shared.hpp>
31
32namespace QuantExt {
33
34 OutperformanceOption::OutperformanceOption( const QuantLib::ext::shared_ptr<Exercise>& exercise, const Option::Type optionType,
35 const Real strikeReturn, const Real initialValue1, const Real initialValue2, const Real notional, const Real knockInPrice, const Real knockOutPrice, QuantLib::ext::shared_ptr<QuantExt::FxIndex> fxIndex1, QuantLib::ext::shared_ptr<QuantExt::FxIndex> fxIndex2 )
36 : exercise_(exercise), optionType_(optionType), strikeReturn_(strikeReturn), initialValue1_(initialValue1), initialValue2_(initialValue2), notional_(notional),
37 knockInPrice_(knockInPrice), knockOutPrice_(knockOutPrice), fxIndex1_(fxIndex1), fxIndex2_(fxIndex2) {}
38
40 return detail::simple_event(exercise_->dates().back()).hasOccurred();
41 }
42
44 NPV_ = 0.0;
45 }
46
48 PricingEngine::arguments* args) const {
49
51 dynamic_cast<OutperformanceOption::arguments*>(args);
52
53 QL_REQUIRE(arguments != 0, "wrong argument type");
54
66
67 }
68
70 QL_REQUIRE(exercise, "exercise not set");
71 }
72
73 void OutperformanceOption::fetchResults(const PricingEngine::results* r) const {
74 Instrument::fetchResults(r);
76 dynamic_cast<const OutperformanceOption::results*>(r);
77
78 QL_ENSURE(results != 0,
79 "wrong result type");
80 }
81} // namespace QuantExt
Analytic European engine for outperformance options.
Arguments for Outperformance option calculation
QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndex2
QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndex1
QuantLib::ext::shared_ptr< Exercise > exercise
Results from Outperformance option calculation
void setupArguments(PricingEngine::arguments *) const override
OutperformanceOption(const QuantLib::ext::shared_ptr< Exercise > &exercise, const Option::Type optionType, const Real strikeReturn, const Real initialValue1, const Real initialValue2, const Real notional, const Real knockInPrice=Null< Real >(), const Real knockOutPrice=Null< Real >(), QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndex1=nullptr, QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndex2=nullptr)
QuantLib::ext::shared_ptr< Exercise > exercise_
QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndex1_
QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndex2_
void fetchResults(const PricingEngine::results *) const override