Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
analyticbarrierengine.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
27AnalyticBarrierEngine::AnalyticBarrierEngine(ext::shared_ptr<GeneralizedBlackScholesProcess> process, const Date& paymentDate)
28 : QuantLib::AnalyticBarrierEngine(process), process_(std::move(process)), paymentDate_(paymentDate) {
29 registerWith(process_);
30}
31
33 QuantLib::AnalyticBarrierEngine::calculate();
34
35 // If a payDate was provided (and is greater than the expiryDate)
36 if (paymentDate_ > arguments_.exercise->lastDate()) {
37 Rate payDateDiscount = process_->riskFreeRate()->discount(paymentDate_);
38 Rate expiryDateDiscount = process_->riskFreeRate()->discount(arguments_.exercise->lastDate());
39 Rate factor = payDateDiscount / expiryDateDiscount;
40 results_.value *= factor;
41 }
42
43 if (paymentDate_ != Date())
44 results_.additionalResults["settlementDate"] = paymentDate_;
45}
46
47} // 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.
AnalyticBarrierEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > process, const Date &paymentDate)
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
Swap::arguments * arguments_