Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
equityoutperformanceoption.hpp
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
19/*! \file ored/portfolio/builders/equityoutperformanceoption.hpp
20 \brief
21 \ingroup portfolio
22*/
23
24#pragma once
25
26#include <qle/pricingengines/analyticoutperformanceoptionengine.hpp>
27
28#include <boost/make_shared.hpp>
33#include <ql/processes/blackscholesprocess.hpp>
34
35namespace ore {
36namespace data {
37using namespace std;
38using namespace QuantLib;
39using namespace ore::data;
40
41//! Engine Builder for EQ Outperformance Option
42/*! Pricing engines are cached by asset names / currency
43
44 \ingroup portfolio
45 */
47 : public ore::data::CachingPricingEngineBuilder<string, const string&, const string&, const Currency&> {
48public:
50 : CachingEngineBuilder("BlackScholesMerton", "AnalyticOutperformanceOptionEngine", {"EquityOutperformanceOption"}) {}
52 : CachingEngineBuilder(model, engine, {"EquityOutperformanceOption"}) {}
53
54protected:
55 virtual string keyImpl(const string& assetName1, const string& assetName2, const Currency& ccy) override {
56 return assetName1 + assetName2 + ccy.code();
57 }
58
59 virtual QuantLib::ext::shared_ptr<PricingEngine> engineImpl(const string& assetName1, const string& assetName2, const Currency& ccy) override {
60 QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess> gbsp1 = QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(
62 market_->equityDividendCurve(assetName1, configuration(ore::data::MarketContext::pricing)),
63 market_->equityForecastCurve(assetName1, configuration(ore::data::MarketContext::pricing)),
65
66 QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess> gbsp2 = QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(
68 market_->equityDividendCurve(assetName2, configuration(ore::data::MarketContext::pricing)),
69 market_->equityForecastCurve(assetName2, configuration(ore::data::MarketContext::pricing)),
71
72 int integrationPoints = ore::data::parseInteger(engineParameter("IntegrationPoints"));
73
74 QuantLib::Handle<QuantExt::CorrelationTermStructure> corrCurve(
75 QuantLib::ext::make_shared<QuantExt::FlatCorrelation>(0, NullCalendar(), 0.0, Actual365Fixed()));
76 try {
77 corrCurve = market_->correlationCurve("EQ-" + assetName1, "EQ-" + assetName2,
79 } catch (...) {
80 WLOG("no correlation curve for EQ-" << assetName1 << ", EQ-" << assetName2
81 << " found, fall back to zero correlation.");
82 }
83
84 engine_ = "AnalyticOutperformanceOptionEngine";
85 return QuantLib::ext::make_shared<QuantExt::AnalyticOutperformanceOptionEngine>(gbsp1, gbsp2, corrCurve, integrationPoints);
86 }
87};
88
89} // namespace data
90} // namespace ore
Abstract template engine builder class.
Abstract template EngineBuilder class that can cache engines and coupon pricers.
QuantLib::ext::shared_ptr< Market > market_
const string & engine() const
Return the engine name.
const string & model() const
Return the model name.
std::string engineParameter(const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
Engine Builder for EQ Outperformance Option.
virtual string keyImpl(const string &assetName1, const string &assetName2, const Currency &ccy) override
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const string &assetName1, const string &assetName2, const Currency &ccy) override
EquityOutperformanceOptionEngineBuilder(const string &model, const string &engine)
Pricing Engine Factory.
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
Definition: parsers.cpp:136
@ data
Definition: log.hpp:77
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Map text representations to QuantLib/QuantExt types.