Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
BlackScholesModelBuilder Class Reference

#include <ored/model/blackscholesmodelbuilder.hpp>

+ Inheritance diagram for BlackScholesModelBuilder:
+ Collaboration diagram for BlackScholesModelBuilder:

Public Member Functions

 BlackScholesModelBuilder (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=0, const std::string &calibration="ATM", const std::vector< std::vector< Real > > &calibrationStrikes={})
 
 BlackScholesModelBuilder (const Handle< YieldTermStructure > &curve, const QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > &process, const std::set< Date > &simulationDates, const std::set< Date > &addDates, const Size timeStepsPerYear=0, const std::string &calibration="ATM", const std::vector< Real > &calibrationStrikes={})
 
std::vector< QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > > getCalibratedProcesses () const override
 
- Public Member Functions inherited from BlackScholesModelBuilderBase
 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)
 
 BlackScholesModelBuilderBase (const Handle< YieldTermStructure > &curve, const QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > &process, const std::set< Date > &simulationDates, const std::set< Date > &addDates, const Size timeStepsPerYear)
 
Handle< BlackScholesModelWrappermodel () const
 
void forceRecalculate () override
 
bool requiresRecalibration () const override
 
- Public Member Functions inherited from ModelBuilder
void recalibrate () const
 
virtual void forceRecalculate ()
 
virtual bool requiresRecalibration () const=0
 

Protected Member Functions

std::vector< std::vector< Real > > getCurveTimes () const override
 
std::vector< std::vector< std::pair< Real, Real > > > getVolTimesStrikes () const override
 
- Protected Member Functions inherited from BlackScholesModelBuilderBase
 BlackScholesModelBuilderBase (const Handle< YieldTermStructure > &curve, const QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > &process)
 
virtual void setupDatesAndTimes () const
 
void performCalculations () const override
 
bool calibrationPointsChanged (const bool updateCache) const
 

Private Attributes

const std::string calibration_
 
const std::vector< std::vector< Real > > calibrationStrikes_
 

Additional Inherited Members

- Protected Attributes inherited from 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_
 
std::set< Date > effectiveSimulationDates_
 
TimeGrid discretisationTimeGrid_
 
RelinkableHandle< BlackScholesModelWrappermodel_
 
bool forceCalibration_ = false
 
QuantLib::ext::shared_ptr< MarketObservermarketObserver_
 
std::vector< Handle< BlackVolTermStructure > > vols_
 
std::vector< Handle< YieldTermStructure > > allCurves_
 
CalibrationPointCache cache_
 

Detailed Description

Definition at line 34 of file blackscholesmodelbuilder.hpp.

Constructor & Destructor Documentation

◆ BlackScholesModelBuilder() [1/2]

BlackScholesModelBuilder ( 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 = 0,
const std::string &  calibration = "ATM",
const std::vector< std::vector< Real > > &  calibrationStrikes = {} 
)

Definition at line 25 of file blackscholesmodelbuilder.cpp.

30 : BlackScholesModelBuilderBase(curves, processes, simulationDates, addDates, timeStepsPerYear),
31 calibration_(calibration),
32 calibrationStrikes_(calibrationStrikes.empty() ? std::vector<std::vector<Real>>(processes.size())
33 : calibrationStrikes) {
34 QL_REQUIRE(calibrationStrikes_.size() == processes.size(),
35 "calibrationStrikes size (" << calibrationStrikes_.size() << ") must match processes size ("
36 << processes.size() << ")");
37}
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)
const std::vector< std::vector< Real > > calibrationStrikes_

◆ BlackScholesModelBuilder() [2/2]

BlackScholesModelBuilder ( const Handle< YieldTermStructure > &  curve,
const QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > &  process,
const std::set< Date > &  simulationDates,
const std::set< Date > &  addDates,
const Size  timeStepsPerYear = 0,
const std::string &  calibration = "ATM",
const std::vector< Real > &  calibrationStrikes = {} 
)

Definition at line 39 of file blackscholesmodelbuilder.cpp.

45 : BlackScholesModelBuilderBase(curve, process, simulationDates, addDates, timeStepsPerYear),
46 calibration_(calibration), calibrationStrikes_(1, calibrationStrikes) {}

Member Function Documentation

◆ getCalibratedProcesses()

std::vector< QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > > getCalibratedProcesses ( ) const
overridevirtual

Implements BlackScholesModelBuilderBase.

Definition at line 49 of file blackscholesmodelbuilder.cpp.

49 {
50 // nothing to do, return original processes
51 return processes_;
52}
const std::vector< QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > > processes_

◆ getCurveTimes()

std::vector< std::vector< Real > > getCurveTimes ( ) const
overrideprotectedvirtual

Implements BlackScholesModelBuilderBase.

Definition at line 54 of file blackscholesmodelbuilder.cpp.

54 {
55 std::vector<Real> timesExt(discretisationTimeGrid_.begin() + 1, discretisationTimeGrid_.end());
56 for (auto const& d : addDates_) {
57 if (d > curves_.front()->referenceDate()) {
58 timesExt.push_back(curves_.front()->timeFromReference(d));
59 }
60 }
61 std::sort(timesExt.begin(), timesExt.end());
62 auto it = std::unique(timesExt.begin(), timesExt.end(),
63 [](const Real x, const Real y) { return QuantLib::close_enough(x, y); });
64 timesExt.resize(std::distance(timesExt.begin(), it));
65 return std::vector<std::vector<Real>>(allCurves_.size(), timesExt);
66}
std::vector< Handle< YieldTermStructure > > allCurves_
const std::vector< Handle< YieldTermStructure > > curves_

◆ getVolTimesStrikes()

std::vector< std::vector< std::pair< Real, Real > > > getVolTimesStrikes ( ) const
overrideprotectedvirtual

Implements BlackScholesModelBuilderBase.

Definition at line 68 of file blackscholesmodelbuilder.cpp.

68 {
69 std::vector<std::vector<std::pair<Real, Real>>> volTimesStrikes;
70 for (Size i = 0; i < processes_.size(); ++i) {
71 Real strike;
72 if (calibration_ == "ATM") {
73 strike = Null<Real>();
74 } else if (calibration_ == "Deal") {
75 strike = calibrationStrikes_[i].empty() ? Null<Real>() : calibrationStrikes_[i][0];
76 } else {
77 QL_FAIL("BlackScholesModelBuilder: calibration '" << calibration_ << "' not known, expected ATM or Deal");
78 }
79 volTimesStrikes.push_back(std::vector<std::pair<Real, Real>>());
80 for (Size j = 1; j < discretisationTimeGrid_.size(); ++j) {
81 volTimesStrikes.back().push_back(std::make_pair(discretisationTimeGrid_[j], strike));
82 }
83 }
84 return volTimesStrikes;
85}

Member Data Documentation

◆ calibration_

const std::string calibration_
private

Definition at line 54 of file blackscholesmodelbuilder.hpp.

◆ calibrationStrikes_

const std::vector<std::vector<Real> > calibrationStrikes_
private

Definition at line 55 of file blackscholesmodelbuilder.hpp.