Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
fxdigitaloption.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2017 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 portfolio/builders/fxdigitaloption.hpp
20 \brief
21 \ingroup portfolio
22*/
23
24#pragma once
25
26#include <boost/make_shared.hpp>
32#include <ql/processes/blackscholesprocess.hpp>
33namespace ore {
34namespace data {
35using std::string;
36
37//! Engine Builder for European FX Digital Options
38/*! Pricing engines are cached by currency pair
39
40 \ingroup portfolio
41 */
43 : public ore::data::CachingPricingEngineBuilder<string, const Currency&, const Currency&, const bool> {
44public:
46 : CachingEngineBuilder("GarmanKohlhagen", "AnalyticEuropeanEngine", {"FxDigitalOption"}) {}
47
48protected:
49 virtual string keyImpl(const Currency& forCcy, const Currency& domCcy, const bool flipResults) override {
50 return forCcy.code() + domCcy.code() + (flipResults ? "_1" : "_0");
51 }
52
53 virtual QuantLib::ext::shared_ptr<PricingEngine> engineImpl(const Currency& forCcy, const Currency& domCcy,
54 const bool flipResults) override {
55 string pair = forCcy.code() + domCcy.code();
56
57 QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess> gbsp = QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(
59 market_->discountCurve(forCcy.code(),
60 configuration(ore::data::MarketContext::pricing)), // dividend yield ~ foreign yield
61 market_->discountCurve(domCcy.code(), configuration(ore::data::MarketContext::pricing)),
63 return QuantLib::ext::make_shared<QuantExt::AnalyticEuropeanEngine>(gbsp, flipResults);
64 }
65};
66
67//! Engine Builder for European cash-settled FX Digital Options
69 : public ore::data::CachingPricingEngineBuilder<string, const Currency&, const Currency&> {
70public:
72 : CachingEngineBuilder("GarmanKohlhagen", "AnalyticCashSettledEuropeanEngine", {"FxDigitalOptionEuropeanCS"}) {}
73
74protected:
75 virtual string keyImpl(const Currency& forCcy, const Currency& domCcy) override {
76 return forCcy.code() + domCcy.code();
77 }
78
79 virtual QuantLib::ext::shared_ptr<PricingEngine> engineImpl(const Currency& forCcy, const Currency& domCcy) override {
80 string pair = forCcy.code() + domCcy.code();
81
82 QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess> gbsp = QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(
84 market_->discountCurve(forCcy.code(),
85 configuration(ore::data::MarketContext::pricing)), // dividend yield ~ foreign yield
86 market_->discountCurve(domCcy.code(), configuration(ore::data::MarketContext::pricing)),
88
89 return QuantLib::ext::make_shared<QuantExt::AnalyticCashSettledEuropeanEngine>(gbsp);
90 }
91};
92
93} // namespace data
94} // 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 & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
Engine Builder for European cash-settled FX Digital Options.
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const Currency &forCcy, const Currency &domCcy) override
virtual string keyImpl(const Currency &forCcy, const Currency &domCcy) override
Engine Builder for European FX Digital Options.
virtual string keyImpl(const Currency &forCcy, const Currency &domCcy, const bool flipResults) override
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const Currency &forCcy, const Currency &domCcy, const bool flipResults) override
Pricing Engine Factory.
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
string conversion utilities