Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
equitydoublebarrieroption.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 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
20
21namespace ore {
22namespace data {
23
25 QL_REQUIRE(barrier().levels().size() == 2, "Invalid number of barrier levels. Must have two.");
26 QL_REQUIRE(barrier().style().empty() || barrier().style() == "American", "Only American barrier style supported");
27}
28
29QuantLib::ext::shared_ptr<QuantLib::PricingEngine>
30EquityDoubleBarrierOption::vanillaPricingEngine(const QuantLib::ext::shared_ptr<EngineFactory>& ef,
31 const QuantLib::Date& expiryDate, const QuantLib::Date& paymentDate) {
32
33 QuantLib::ext::shared_ptr<EngineBuilder> builder = ef->builder("EquityOption");
34 QL_REQUIRE(builder, "No builder found for EquityOption");
35
36 QuantLib::ext::shared_ptr<EquityEuropeanOptionEngineBuilder> eqOptBuilder =
37 QuantLib::ext::dynamic_pointer_cast<EquityEuropeanOptionEngineBuilder>(builder);
38 QL_REQUIRE(eqOptBuilder, "No eqOptBuilder found");
39
40 setSensitivityTemplate(*eqOptBuilder);
41
42 return eqOptBuilder->engine(equityName(), tradeCurrency(), expiryDate);
43}
44
45QuantLib::ext::shared_ptr<QuantLib::PricingEngine>
46EquityDoubleBarrierOption::barrierPricingEngine(const QuantLib::ext::shared_ptr<EngineFactory>& ef,
47 const QuantLib::Date& expiryDate, const QuantLib::Date& paymentDate) {
48
49 QuantLib::ext::shared_ptr<EngineBuilder> builder = ef->builder(tradeType_);
50 QL_REQUIRE(builder, "No builder found for " << tradeType_);
51
52 QuantLib::ext::shared_ptr<EquityDoubleBarrierOptionEngineBuilder> eqBarrierOptBuilder =
53 QuantLib::ext::dynamic_pointer_cast<EquityDoubleBarrierOptionEngineBuilder>(builder);
54 QL_REQUIRE(eqBarrierOptBuilder, "No eqBarrierOptBuilder found");
55
56 setSensitivityTemplate(*eqBarrierOptBuilder);
57
58 return eqBarrierOptBuilder->engine(equityName(), tradeCurrency(), expiryDate);
59}
60
61} // namespace data
62} // namespace oreplus
Engine builder for equity options.
const BarrierData & barrier() const
QuantLib::ext::shared_ptr< QuantLib::PricingEngine > vanillaPricingEngine(const QuantLib::ext::shared_ptr< EngineFactory > &ef, const QuantLib::Date &expiryDate, const QuantLib::Date &paymentDate=QuantLib::Date()) override
create the pricing engines
QuantLib::ext::shared_ptr< QuantLib::PricingEngine > barrierPricingEngine(const QuantLib::ext::shared_ptr< EngineFactory > &ef, const QuantLib::Date &expiryDate, const QuantLib::Date &paymentDate=Date()) override
void checkBarriers() override
check validity of barriers
void setSensitivityTemplate(const EngineBuilder &builder)
Definition: trade.cpp:295
string tradeType_
Definition: trade.hpp:196
Equity Double Barrier Option data model and serialization.
@ data
Definition: log.hpp:77
Size size(const ValueType &v)
Definition: value.cpp:145
Serializable Credit Default Swap.
Definition: namespaces.docs:23