Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
blackscholesmodelbuilderbase.hpp
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
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 ored/model/blackscholesmodelbuilderbase.hpp
20 \brief builder for an array of black scholes processes
21 \ingroup utilities
22*/
23
24#pragma once
25
27
30
32
33#include <ql/processes/blackscholesprocess.hpp>
34
35namespace ore {
36namespace data {
37
38using namespace QuantExt;
39using namespace QuantLib;
40
42public:
43 BlackScholesModelBuilderBase(const std::vector<Handle<YieldTermStructure>>& curves,
44 const std::vector<QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess>>& processes,
45 const std::set<Date>& simulationDates, const std::set<Date>& addDates,
46 const Size timeStepsPerYear);
47 BlackScholesModelBuilderBase(const Handle<YieldTermStructure>& curve,
48 const QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess>& process,
49 const std::set<Date>& simulationDates, const std::set<Date>& addDates,
50 const Size timeStepsPerYear);
51
52 Handle<BlackScholesModelWrapper> model() const;
53
54 //! \name ModelBuilder interface
55 //@{
56 void forceRecalculate() override;
57 bool requiresRecalibration() const override;
58 //@}
59
60protected:
61 // generic ctor, you should override setupDateAndTimes() if using this one
62 BlackScholesModelBuilderBase(const Handle<YieldTermStructure>& curve,
63 const QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess>& process);
64
65 virtual void setupDatesAndTimes() const;
66
67 virtual std::vector<QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess>> getCalibratedProcesses() const = 0;
68 virtual std::vector<std::vector<Real>> getCurveTimes() const = 0;
69 virtual std::vector<std::vector<std::pair<Real, Real>>> getVolTimesStrikes() const = 0;
70
71
72 void performCalculations() const override;
73 bool calibrationPointsChanged(const bool updateCache) const;
74
75 const std::vector<Handle<YieldTermStructure>> curves_;
76 const std::vector<QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess>> processes_;
77 const std::set<Date> simulationDates_, addDates_;
79
80 mutable std::set<Date> effectiveSimulationDates_; // the dates effectively simulated (including today)
81 mutable TimeGrid discretisationTimeGrid_; // the (possibly refined) time grid for the simulation
82
83 mutable RelinkableHandle<BlackScholesModelWrapper> model_;
84
85 bool forceCalibration_ = false;
86 QuantLib::ext::shared_ptr<MarketObserver> marketObserver_;
87
88 std::vector<Handle<BlackVolTermStructure>> vols_;
89 std::vector<Handle<YieldTermStructure>> allCurves_;
91};
92
93} // namespace data
94} // namespace ore
cache for relevant points on curve / vol surfaces
virtual std::vector< std::vector< Real > > getCurveTimes() const =0
std::vector< Handle< YieldTermStructure > > allCurves_
virtual std::vector< QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > > getCalibratedProcesses() const =0
std::vector< Handle< BlackVolTermStructure > > vols_
bool calibrationPointsChanged(const bool updateCache) const
virtual std::vector< std::vector< std::pair< Real, Real > > > getVolTimesStrikes() const =0
Handle< BlackScholesModelWrapper > model() const
QuantLib::ext::shared_ptr< MarketObserver > marketObserver_
RelinkableHandle< BlackScholesModelWrapper > model_
const std::vector< QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > > processes_
const std::vector< Handle< YieldTermStructure > > curves_
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23