Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
analyticdoublebarrierengine.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2022 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#include <ql/exercise.hpp>
21#include <utility>
22
23namespace QuantExt {
24
25using namespace QuantLib;
26
27AnalyticDoubleBarrierEngine::AnalyticDoubleBarrierEngine(ext::shared_ptr<GeneralizedBlackScholesProcess> process,
28 const Date& paymentDate, int series)
29 : QuantLib::AnalyticDoubleBarrierEngine(process, series), process_(std::move(process)), paymentDate_(paymentDate) {
30 registerWith(process_);
31}
32
34 QuantLib::AnalyticDoubleBarrierEngine::calculate();
35
36 // If a payDate was provided (and is greater than the expiryDate)
37 if (paymentDate_ > arguments_.exercise->lastDate()) {
38 Rate payDateDiscount = process_->riskFreeRate()->discount(paymentDate_);
39 Rate expiryDateDiscount = process_->riskFreeRate()->discount(arguments_.exercise->lastDate());
40 Rate factor = payDateDiscount / expiryDateDiscount;
41 results_.value *= factor;
42 }
43
44 if (paymentDate_ != Date())
45 results_.additionalResults["settlementDate"] = paymentDate_;
46}
47
48} // namespace QuantExt
Analytic barrier option engines.
const Instrument::results * results_
Definition: cdsoption.cpp:81
Wrapper engine for the QuantLib engine to take settlement delay into account.
AnalyticDoubleBarrierEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > process, const Date &paymentDate, int series=5)
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
Swap::arguments * arguments_