Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
equitybarrieroption.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 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
21
22using namespace QuantLib;
23
24namespace ore {
25namespace data {
26
28 QL_REQUIRE(barrier().levels().size() == 1, "Invalid number of barrier levels");
29 QL_REQUIRE(barrier().style().empty() || barrier().style() == "American", "Only american barrier style suppported");
30}
31
32QuantLib::ext::shared_ptr<QuantLib::PricingEngine> EquityBarrierOption::vanillaPricingEngine(const QuantLib::ext::shared_ptr<EngineFactory>& ef,
33 const QuantLib::Date& expiryDate, const QuantLib::Date& paymentDate) {
34
35 QuantLib::ext::shared_ptr<EngineBuilder> builder = ef->builder("EquityOption");
36 QL_REQUIRE(builder, "No builder found for EquityOption");
37
38 QuantLib::ext::shared_ptr<EquityEuropeanOptionEngineBuilder> eqOptBuilder =
39 QuantLib::ext::dynamic_pointer_cast<EquityEuropeanOptionEngineBuilder>(builder);
40 QL_REQUIRE(eqOptBuilder, "No eqOptBuilder found");
41
42 setSensitivityTemplate(*eqOptBuilder);
43
44 return eqOptBuilder->engine(equityName(), tradeCurrency(), expiryDate);
45}
46
47QuantLib::ext::shared_ptr<QuantLib::PricingEngine>
48EquityBarrierOption::barrierPricingEngine(const QuantLib::ext::shared_ptr<EngineFactory>& ef,
49 const QuantLib::Date& expiryDate, const QuantLib::Date& paymentDate) {
50
51 QuantLib::ext::shared_ptr<EngineBuilder> builder = ef->builder(tradeType_);
52 QL_REQUIRE(builder, "No builder found for " << tradeType_);
53
54 QuantLib::ext::shared_ptr<EquityBarrierOptionEngineBuilder> eqBarrierOptBuilder =
55 QuantLib::ext::dynamic_pointer_cast<EquityBarrierOptionEngineBuilder>(builder);
56 QL_REQUIRE(eqBarrierOptBuilder, "No eqBarrierOptBuilder found");
57
58 setSensitivityTemplate(*eqBarrierOptBuilder);
59
60 return eqBarrierOptBuilder->engine(equityName(), tradeCurrency(), expiryDate);
61}
62
63} // namespace data
64} // namespace oreplus
Engine builder for equity options.
const BarrierData & barrier() const
QuantLib::ext::shared_ptr< QuantLib::PricingEngine > barrierPricingEngine(const QuantLib::ext::shared_ptr< EngineFactory > &ef, const QuantLib::Date &expiryDate, const QuantLib::Date &paymentDate=QuantLib::Date()) override
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
void checkBarriers() override
check validity of barriers
void setSensitivityTemplate(const EngineBuilder &builder)
Definition: trade.cpp:295
string tradeType_
Definition: trade.hpp:196
Equity 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