Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
fxdoublebarrieroption.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 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 ORE is free software: you can redistribute it and/or modify it
8 under the terms of the Modified BSD License. You should have received a
9 copy of the license along with this program.
10 The license is also available online at <http://opensourcerisk.org>
11 This program is distributed on the basis that it will form a useful
12 contribution to risk analytics and model standardisation, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
15*/
16
17/*! \file ored/portfolio/builders/fxdoublebarrieroption.hpp
18 \brief
19 \ingroup portfolio
20*/
21
22#pragma once
23
24#include <boost/make_shared.hpp>
29#include <ql/pricingengines/barrier/fdblackscholesbarrierengine.hpp>
30#include <ql/processes/blackscholesprocess.hpp>
34
35namespace ore {
36namespace data {
37using namespace std;
38using namespace QuantLib;
39
40//! Engine Builder for European FX Double Barrier Options
41/*! Pricing engines are cached by currency pair
42
43 \ingroup portfolio
44 */
46 : public ore::data::CachingPricingEngineBuilder<string, const Currency&, const Currency&, const Date&> {
47
48protected:
49 FxDoubleBarrierOptionEngineBuilder(const string& model, const string& engine)
50 : CachingEngineBuilder(model, engine, {"FxDoubleBarrierOption"}) {}
51
52 virtual string keyImpl(const Currency& forCcy, const Currency& domCcy, const Date& paymentDate) override {
53 return forCcy.code() + domCcy.code() + ore::data::to_string(paymentDate);
54 }
55
56 QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess>
57 getBlackScholesProcess(const Currency& forCcy, const Currency& domCcy, const std::vector<Time>& timePoints = {}) {
58 const string pair = forCcy.code() + domCcy.code();
59 Handle<BlackVolTermStructure> vol = market_->fxVol(pair, configuration(ore::data::MarketContext::pricing));
60 if (!timePoints.empty()) {
61 vol = Handle<BlackVolTermStructure>(
62 QuantLib::ext::make_shared<QuantExt::BlackMonotoneVarVolTermStructure>(vol, timePoints));
63 vol->enableExtrapolation();
64 }
65 return QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(
67 market_->discountCurve(forCcy.code(),
68 configuration(ore::data::MarketContext::pricing)), // dividend yield ~ foreign yield
69 market_->discountCurve(domCcy.code(), configuration(ore::data::MarketContext::pricing)), vol);
70 }
71};
72
73//! Analytical Engine Builder for FX Double Barrier Options
74/*! Pricing engines are cached by currency pair
75
76 \ingroup portfolio
77 */
79public:
81 : FxDoubleBarrierOptionEngineBuilder("GarmanKohlhagen", "AnalyticDoubleBarrierEngine") {}
82
83protected:
84 virtual QuantLib::ext::shared_ptr<PricingEngine> engineImpl(const Currency& forCcy, const Currency& domCcy, const Date& paymentDate) override {
85 QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess> gbsp = getBlackScholesProcess(forCcy, domCcy);
86 return QuantLib::ext::make_shared<QuantExt::AnalyticDoubleBarrierEngine>(gbsp, paymentDate);
87 }
88};
89
90} // namespace data
91} // namespace oreplus
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.
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
Analytical Engine Builder for FX Double Barrier Options.
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const Currency &forCcy, const Currency &domCcy, const Date &paymentDate) override
Engine Builder for European FX Double Barrier Options.
FxDoubleBarrierOptionEngineBuilder(const string &model, const string &engine)
QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > getBlackScholesProcess(const Currency &forCcy, const Currency &domCcy, const std::vector< Time > &timePoints={})
virtual string keyImpl(const Currency &forCcy, const Currency &domCcy, const Date &paymentDate) override
Pricing Engine Factory.
@ data
Definition: log.hpp:77
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Map text representations to QuantLib/QuantExt types.
string conversion utilities