26 const Handle<YieldTermStructure>& curve,
const QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess>& process,
27 const std::set<Date>& simulationDates,
const std::set<Date>& addDates,
const Size timeStepsPerYear)
29 std::vector<QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess>>{process},
30 simulationDates, addDates, timeStepsPerYear) {}
33 const std::vector<Handle<YieldTermStructure>>& curves,
34 const std::vector<QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess>>& processes,
35 const std::set<Date>& simulationDates,
const std::set<Date>& addDates,
const Size timeStepsPerYear)
36 : curves_(curves), processes_(processes), simulationDates_(simulationDates), addDates_(addDates),
37 timeStepsPerYear_(timeStepsPerYear) {
39 QL_REQUIRE(!
curves_.empty(),
"BlackScholesModelBuilderBase: no curves given");
47 registerWith(p->blackVolatility());
48 registerWith(p->riskFreeRate());
49 registerWith(p->dividendYield());
56 alwaysForwardNotifications();
60 vols_.push_back(p->blackVolatility());
67 const Handle<YieldTermStructure>& curve,
const QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess>& process)
95 std::vector<Real> times;
97 times.push_back(
curves_.front()->timeFromReference(d));
121 model_->notifyObservers();
130 std::vector<std::vector<std::pair<Real, Real>>> volTimesStrikes =
getVolTimesStrikes();
134 std::vector<std::vector<Real>> curveData;
135 for (Size i = 0; i < curveTimes.size(); ++i) {
136 curveData.push_back(std::vector<Real>());
137 for (Size j = 0; j < curveTimes[i].size(); ++j) {
138 curveData.back().push_back(
allCurves_[i]->discount(curveTimes[i][j]));
142 std::vector<std::vector<Real>> volData;
143 for (Size i = 0; i < volTimesStrikes.size(); ++i) {
144 volData.push_back(std::vector<Real>());
145 for (Size j = 0; j < volTimesStrikes[i].size(); ++j) {
146 Real k = volTimesStrikes[i][j].second;
148 if (k == Null<Real>())
150 volTimesStrikes[i][j].first);
151 volData.back().push_back(
vols_[i]->blackVol(volTimesStrikes[i][j].first, k));
156 return cache_.
hasChanged(curveTimes, curveData, volTimesStrikes, volData, updateCache);
builder for an array of black scholes processes
virtual void forceRecalculate()
virtual std::vector< std::vector< Real > > getCurveTimes() const =0
std::vector< Handle< YieldTermStructure > > allCurves_
void forceRecalculate() override
void performCalculations() const override
CalibrationPointCache cache_
BlackScholesModelBuilderBase(const std::vector< Handle< YieldTermStructure > > &curves, const std::vector< QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > > &processes, const std::set< Date > &simulationDates, const std::set< Date > &addDates, const Size timeStepsPerYear)
virtual std::vector< QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > > getCalibratedProcesses() const =0
bool requiresRecalibration() const override
std::vector< Handle< BlackVolTermStructure > > vols_
std::set< Date > effectiveSimulationDates_
TimeGrid discretisationTimeGrid_
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 Size timeStepsPerYear_
const std::set< Date > simulationDates_
virtual void setupDatesAndTimes() const
const std::vector< Handle< YieldTermStructure > > curves_
bool hasChanged(const std::vector< std::vector< Real > > &curveTimes, const std::vector< std::vector< Real > > &curveData, const std::vector< std::vector< std::pair< Real, Real > > > &volTimesStrikes, const std::vector< std::vector< Real > > &volData, const bool updateCache)
Shared utilities for model building and calibration.
Real atmForward(const Real s0, const Handle< YieldTermStructure > &r, const Handle< YieldTermStructure > &q, const Real t)
helper function that computes the atm forward
Serializable Credit Default Swap.
std::vector< Size > steps