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

#include <ored/scripting/models/modelimpl.hpp>

+ Inheritance diagram for ModelImpl:
+ Collaboration diagram for ModelImpl:

Public Member Functions

 ModelImpl (const DayCounter &dayCounter, const Size size, const std::vector< std::string > &currencies, const std::vector< std::pair< std::string, QuantLib::ext::shared_ptr< InterestRateIndex > > > &irIndices, const std::vector< std::pair< std::string, QuantLib::ext::shared_ptr< ZeroInflationIndex > > > &infIndices, const std::vector< std::string > &indices, const std::vector< std::string > &indexCurrencies, const std::set< Date > &simulationDates, const IborFallbackConfig &iborFallbackConfig)
 
const std::string & baseCcy () const override
 
Real dt (const Date &d1, const Date &d2) const override
 
RandomVariable pay (const RandomVariable &amount, const Date &obsdate, const Date &paydate, const std::string &currency) const override
 
RandomVariable discount (const Date &obsdate, const Date &paydate, const std::string &currency) const override
 
RandomVariable eval (const std::string &index, const Date &obsdate, const Date &fwddate, const bool returnMissingMissingAsNull=false, const bool ignoreTodaysFixing=false) const override
 
Real fxSpotT0 (const std::string &forCcy, const std::string &domCcy) const override
 
RandomVariable barrierProbability (const std::string &index, const Date &obsdate1, const Date &obsdate2, const RandomVariable &barrier, const bool above) const override
 
Real extractT0Result (const RandomVariable &value) const override
 
- Public Member Functions inherited from Model
 Model (const Size n)
 
virtual ~Model ()
 
virtual Type type () const =0
 
virtual Size size () const
 
virtual Size trainingSamples () const
 
virtual void toggleTrainingPaths () const
 
virtual const Date & referenceDate () const =0
 
virtual const std::string & baseCcy () const =0
 
virtual Real dt (const Date &d1, const Date &d2) const
 
Real timeFromReference (const Date &d) const
 
virtual RandomVariable pay (const RandomVariable &amount, const Date &obsdate, const Date &paydate, const std::string &currency) const =0
 
virtual RandomVariable discount (const Date &obsdate, const Date &paydate, const std::string &currency) const =0
 
virtual RandomVariable npv (const RandomVariable &amount, const Date &obsdate, const Filter &filter, const boost::optional< long > &memSlot, const RandomVariable &addRegressor1, const RandomVariable &addRegressor2) const =0
 
virtual RandomVariable eval (const std::string &index, const Date &obsdate, const Date &fwddate, const bool returnMissingFixingAsNull=false, const bool ignoreTodaysFixing=false) const =0
 
virtual RandomVariable fwdCompAvg (const bool isAvg, const std::string &index, const Date &obsdate, const Date &start, const Date &end, const Real spread, const Real gearing, const Integer lookback, const Natural rateCutoff, const Natural fixingDays, const bool includeSpread, const Real cap, const Real floor, const bool nakedOption, const bool localCapFloor) const =0
 
virtual RandomVariable barrierProbability (const std::string &index, const Date &obsdate1, const Date &obsdate2, const RandomVariable &barrier, const bool above) const =0
 
virtual Real fxSpotT0 (const std::string &forCcy, const std::string &domCcy) const =0
 
virtual Real extractT0Result (const RandomVariable &value) const =0
 
virtual void releaseMemory ()
 
virtual void resetNPVMem ()
 
const std::map< std::string, boost::any > & additionalResults () const
 

Protected Member Functions

virtual RandomVariable getIndexValue (const Size indexNo, const Date &d, const Date &fwd=Null< Date >()) const =0
 
virtual RandomVariable getIrIndexValue (const Size indexNo, const Date &d, const Date &fwd=Null< Date >()) const =0
 
virtual RandomVariable getInfIndexValue (const Size indexNo, const Date &d, const Date &fwd) const =0
 
virtual RandomVariable getDiscount (const Size idx, const Date &s, const Date &t) const =0
 
virtual RandomVariable getNumeraire (const Date &s) const =0
 
virtual Real getFxSpot (const Size idx) const =0
 
virtual RandomVariable getFutureBarrierProb (const std::string &index, const Date &obsdate1, const Date &obsdate2, const RandomVariable &barrier, const bool above) const =0
 
- Protected Member Functions inherited from Model
void performCalculations () const override
 

Protected Attributes

const DayCounter dayCounter_
 
const std::vector< std::string > currencies_
 
const std::vector< std::string > indexCurrencies_
 
const std::set< Date > simulationDates_
 
const IborFallbackConfig iborFallbackConfig_
 
std::vector< std::pair< IndexInfo, QuantLib::ext::shared_ptr< InterestRateIndex > > > irIndices_
 
std::vector< std::pair< IndexInfo, QuantLib::ext::shared_ptr< ZeroInflationIndex > > > infIndices_
 
std::vector< IndexInfoindices_
 
- Protected Attributes inherited from Model
std::map< std::string, boost::any > additionalResults_
 

Private Member Functions

RandomVariable getInflationIndexFixing (const bool returnMissingFixingAsNull, const std::string &indexInput, const QuantLib::ext::shared_ptr< ZeroInflationIndex > &infIndex, const Size indexNo, const Date &limDate, const Date &obsdate, const Date &fwddate, const Date &baseDate) const
 

Additional Inherited Members

- Public Types inherited from Model
enum class  Type { MC , FD }
 

Detailed Description

Definition at line 44 of file modelimpl.hpp.

Constructor & Destructor Documentation

◆ ModelImpl()

ModelImpl ( const DayCounter &  dayCounter,
const Size  size,
const std::vector< std::string > &  currencies,
const std::vector< std::pair< std::string, QuantLib::ext::shared_ptr< InterestRateIndex > > > &  irIndices,
const std::vector< std::pair< std::string, QuantLib::ext::shared_ptr< ZeroInflationIndex > > > &  infIndices,
const std::vector< std::string > &  indices,
const std::vector< std::string > &  indexCurrencies,
const std::set< Date > &  simulationDates,
const IborFallbackConfig iborFallbackConfig 
)

Definition at line 35 of file modelimpl.cpp.

40 : Model(size), dayCounter_(dayCounter), currencies_(currencies), indexCurrencies_(indexCurrencies),
41 simulationDates_(simulationDates), iborFallbackConfig_(iborFallbackConfig) {
42
43 // populate index vectors
44
45 for (auto const& str : indices) {
46 indices_.push_back(IndexInfo(str));
47 }
48
49 for (auto const& p : irIndices) {
50 irIndices_.push_back(std::make_pair(IndexInfo(p.first), p.second));
51 }
52
53 for (auto const& p : infIndices) {
54 infIndices_.push_back(std::make_pair(IndexInfo(p.first), p.second));
55 }
56
57 // check consistency of inputs
58
59 QL_REQUIRE(indexCurrencies_.size() == indices_.size(), "mismatch of indexCurrencies (" << indexCurrencies_.size()
60 << ") and indices ("
61 << indices_.size() << ")");
62
63 for (auto const& c : currencies_)
64 QL_REQUIRE(!c.empty(), "empty currency string");
65
66 // look for fx indices, check consistency with currencies and index currencies vectors
67
68 for (Size i = 0; i < indices_.size(); ++i) {
69 if (indices_[i].isFx()) {
70 QL_REQUIRE(indices_[i].fx()->targetCurrency().code() == currencies_.front(),
71 "fx index domestic currency (" << indices_[i].fx()->targetCurrency().code()
72 << ") does not match base currency (" << currencies_.front()
73 << ")");
74 QL_REQUIRE(indices_[i].fx()->sourceCurrency().code() == indexCurrencies_[i],
75 "fx index foreign currency (" << indices_[i].fx()->sourceCurrency().code()
76 << ") does not match index currency (" << indexCurrencies_[i]);
77 auto ccy = std::find(currencies_.begin(), currencies_.end(), indexCurrencies_[i]);
78 QL_REQUIRE(ccy != currencies_.end(),
79 "fx index foreign currency (" << indexCurrencies_[i] << ") not found in model currencies");
80 }
81 }
82
83 // register with observables
84
85 for (auto const& i : irIndices_)
86 registerWith(i.second);
87
88 for (auto const& i : infIndices_)
89 registerWith(i.second);
90
91 for (auto const& i : indices_) {
92 if (i.isComm()) {
93 for (auto const& d : simulationDates_)
94 registerWith(i.index(d));
95 } else
96 registerWith(i.index());
97 }
98
99} // ModelImpl ctor
Model(const Size n)
Definition: model.hpp:64
virtual Size size() const
Definition: model.hpp:71
const std::vector< std::string > currencies_
Definition: modelimpl.hpp:107
std::vector< std::pair< IndexInfo, QuantLib::ext::shared_ptr< ZeroInflationIndex > > > infIndices_
Definition: modelimpl.hpp:113
std::vector< IndexInfo > indices_
Definition: modelimpl.hpp:114
const DayCounter dayCounter_
Definition: modelimpl.hpp:106
std::vector< std::pair< IndexInfo, QuantLib::ext::shared_ptr< InterestRateIndex > > > irIndices_
Definition: modelimpl.hpp:112
const std::vector< std::string > indexCurrencies_
Definition: modelimpl.hpp:108
const IborFallbackConfig iborFallbackConfig_
Definition: modelimpl.hpp:110
const std::set< Date > simulationDates_
Definition: modelimpl.hpp:109

Member Function Documentation

◆ baseCcy()

const std::string & baseCcy ( ) const
overridevirtual

Implements Model.

Definition at line 72 of file modelimpl.hpp.

72{ return currencies_.front(); }
+ Here is the caller graph for this function:

◆ dt()

Real dt ( const Date &  d1,
const Date &  d2 
) const
overridevirtual

Reimplemented from Model.

Definition at line 73 of file modelimpl.hpp.

73{ return dayCounter_.yearFraction(d1, d2); }
+ Here is the caller graph for this function:

◆ pay()

RandomVariable pay ( const RandomVariable amount,
const Date &  obsdate,
const Date &  paydate,
const std::string &  currency 
) const
overridevirtual

Implements Model.

Definition at line 101 of file modelimpl.cpp.

102 {
103 calculate();
104
105 // result is as of max(obsdate, refDate) by definition of pay()
106
107 Date effectiveDate = std::max(obsdate, referenceDate());
108 auto c = std::find(currencies_.begin(), currencies_.end(), currency);
109 QL_REQUIRE(c != currencies_.end(), "currency " << currency << " not handled");
110 Size cidx = std::distance(currencies_.begin(), c);
111
112 // do we have a dynamic fx underlying to convert to base at the effective date?
113
114 RandomVariable fxSpot;
115 for (Size i = 0; i < indexCurrencies_.size(); ++i) {
116 if (indices_.at(i).isFx() && currency == indexCurrencies_[i]) {
117 fxSpot = getIndexValue(i, effectiveDate);
118 break;
119 }
120 }
121
122 // if no we use the zero vol fx spot at the effective date
123
124 if (!fxSpot.initialised()) {
125 if (cidx > 0)
126 fxSpot = RandomVariable(size(), getFxSpot(cidx - 1)) * getDiscount(cidx, referenceDate(), effectiveDate) /
127 getDiscount(0, referenceDate(), effectiveDate);
128 else
129 fxSpot = RandomVariable(size(), 1.0);
130 }
131
132 // discount from pay to obs date on ccy curve, convert to base ccy and divide by the numeraire
133
134 return amount * getDiscount(cidx, effectiveDate, paydate) / getNumeraire(effectiveDate) * fxSpot;
135}
virtual const Date & referenceDate() const =0
virtual Real getFxSpot(const Size idx) const =0
virtual RandomVariable getDiscount(const Size idx, const Date &s, const Date &t) const =0
virtual RandomVariable getIndexValue(const Size indexNo, const Date &d, const Date &fwd=Null< Date >()) const =0
virtual RandomVariable getNumeraire(const Date &s) const =0
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ discount()

RandomVariable discount ( const Date &  obsdate,
const Date &  paydate,
const std::string &  currency 
) const
overridevirtual

Implements Model.

Definition at line 137 of file modelimpl.cpp.

137 {
138 calculate();
139 auto c = std::find(currencies_.begin(), currencies_.end(), currency);
140 QL_REQUIRE(c != currencies_.end(), "currency " << currency << " not handled");
141 Size cidx = std::distance(currencies_.begin(), c);
142 return getDiscount(cidx, obsdate, paydate);
143}
+ Here is the call graph for this function:

◆ eval()

RandomVariable eval ( const std::string &  index,
const Date &  obsdate,
const Date &  fwddate,
const bool  returnMissingMissingAsNull = false,
const bool  ignoreTodaysFixing = false 
) const
overridevirtual

Implements Model.

Definition at line 181 of file modelimpl.cpp.

182 {
183 calculate();
184
185 std::string index = indexInput;
186 IndexInfo indexInfo(index);
187
188 // 1 handle inflation indices
189 QL_DEPRECATED_DISABLE_WARNING
190 // Remove in later version, scripts should take care of interpolation
191 if (indexInfo.isInf()) {
192 auto inf = std::find_if(infIndices_.begin(), infIndices_.end(), comp(indexInput));
193 QL_REQUIRE(inf != infIndices_.end(),
194 "ModelImpl::eval(): did not find inflation index '" << indexInput << "' in model index list.");
195 Date baseDate = inf->second->zeroInflationTermStructure()->baseDate();
196 Date effectiveFixingDate = fwddate != Null<Date>() ? fwddate : obsdate;
197 std::pair<Date, Date> lim = inflationPeriod(effectiveFixingDate, inf->second->frequency());
198 RandomVariable indexStart =
199 getInflationIndexFixing(returnMissingFixingAsNull, indexInput, inf->second,
200 std::distance(infIndices_.begin(), inf), lim.first, obsdate, fwddate, baseDate);
201 // if the index is not interpolated we are done
202 if (!indexInfo.inf()->interpolated()) {
203 return indexStart;
204 }
205 ALOG("Interpolated Inflation Indices are deprecated, adjust your script to handle interpolation there");
206 // otherwise we need to get a second value and interpolate as in ZeroInflationIndex
207 RandomVariable indexEnd = getInflationIndexFixing(returnMissingFixingAsNull, indexInput, inf->second,
208 std::distance(infIndices_.begin(), inf), lim.second + 1,
209 obsdate, fwddate, baseDate);
210 // this is not entirely correct, since we should use the days in the lagged period, but we don't know the lag
211 return indexStart +
212 (indexEnd - indexStart) * RandomVariable(size(), static_cast<Real>(effectiveFixingDate - lim.first) /
213 static_cast<Real>(lim.second + 1 - lim.first));
214 }
215 QL_DEPRECATED_ENABLE_WARNING
216 // 2 handle non-inflation indices
217
218 // 2a handle historical fixings and today's fixings (if given as a historical fixing)
219 // for fx indices try to get the fixing both from the straight and the inverse index
220
221 if (fwddate == Null<Date>()) {
222 if (obsdate < referenceDate() || (obsdate == referenceDate() && !ignoreTodaysFixing)) {
223 if (indexInfo.irIborFallback(iborFallbackConfig_, referenceDate())) {
224 // handle ibor fallback indices, they don't fit into the below treatment...
225 auto ir = std::find_if(irIndices_.begin(), irIndices_.end(), comp(indexInput));
226 if (ir != irIndices_.end()) {
227 return RandomVariable(size(),
228 ir->second->fixing(ir->second->fixingCalendar().adjust(obsdate, Preceding)));
229 } else {
230 QL_FAIL("ir (fallback ibor) index '" << indexInput
231 << "' not found in ir indices list, internal error.");
232 }
233 } else {
234 // handle all other cases than ibor fallback indices
235 QuantLib::ext::shared_ptr<Index> idx = indexInfo.index(obsdate);
236 Real fixing = Null<Real>();
237 try {
238 fixing = idx->fixing(idx->fixingCalendar().adjust(obsdate, Preceding));
239 } catch (...) {
240 }
241 if (fixing != Null<Real>())
242 return RandomVariable(size(), fixing);
243 else {
244 // for dates < refDate we are stuck now
245 if (obsdate != referenceDate()) {
246 if (returnMissingFixingAsNull)
247 return RandomVariable();
248 else {
249 QL_FAIL("missing "
250 << idx->name() << " fixing for " << QuantLib::io::iso_date(obsdate)
251 << " (adjusted fixing date = "
252 << QuantLib::io::iso_date(idx->fixingCalendar().adjust(obsdate, Preceding)) << ")");
253 }
254 }
255 }
256 }
257 }
258 } else {
259 // if fwd date is given, ensure we can project
260 QL_REQUIRE(obsdate >= referenceDate(), "if fwd date is given ("
261 << QuantLib::io::iso_date(fwddate) << "), obsdate ("
262 << QuantLib::io::iso_date(obsdate) << ") must be >= refdate ("
263 << QuantLib::io::iso_date(referenceDate()) << ")");
264 }
265
266 // 2b handle fixings >= today (and fwd fixings, in which case we know fwddate > obsdate >= refdate)
267
268 // 2b1 handle IR indices
269
270 if (indexInfo.isIr()) {
271 auto ir = std::find_if(irIndices_.begin(), irIndices_.end(), comp(indexInput));
272 if (ir != irIndices_.end()) {
273 RandomVariable res = getIrIndexValue(std::distance(irIndices_.begin(), ir), obsdate, fwddate);
274 QL_REQUIRE(res.initialised(), "internal error: could not project "
275 << ir->second->name() << " fixing for (obsdate/fwddate) = ("
276 << QuantLib::io::iso_date(obsdate) << ","
277 << QuantLib::io::iso_date(fwddate) << ")");
278 return res;
279 }
280 }
281
282 // 2b2 handle FX, EQ, COMM indices
283
284 // if we have an FX index, we "normalise" the tag by GENERIC (since it does not matter for projections)
285
286 if (indexInfo.isFx())
287 indexInfo = IndexInfo("FX-GENERIC-" + indexInfo.fx()->sourceCurrency().code() + "-" +
288 indexInfo.fx()->targetCurrency().code());
289
290 RandomVariable res;
291 auto i = std::find(indices_.begin(), indices_.end(), indexInfo);
292 if (i != indices_.end()) {
293 // we have the index directly as an underlying
294 res = getIndexValue(std::distance(indices_.begin(), i), obsdate, fwddate);
295 } else {
296 // if not, we can only try something else for FX indices
297 QL_REQUIRE(indexInfo.isFx(), "ModelImpl::eval(): index " << index << " not handled");
298 // is it a trivial fx index (CCY-CCY) or can we triangulate it?
299 RandomVariable fx1(size(), 1.0), fx2(size(), 1.0);
300 if (indexInfo.fx()->sourceCurrency() == indexInfo.fx()->targetCurrency()) {
301 res = fx1;
302 // no fwd correction required, if ccy1=ccy2 we have spot = fwd = 1
303 } else {
304 Size ind1 = Null<Size>(), ind2 = Null<Size>();
305 for (Size i = 0; i < indexCurrencies_.size(); ++i) {
306 if (indices_[i].isFx()) {
307 if (indexInfo.fx()->sourceCurrency().code() == indexCurrencies_[i])
308 ind1 = i;
309 if (indexInfo.fx()->targetCurrency().code() == indexCurrencies_[i])
310 ind2 = i;
311 }
312 }
313 if (ind1 != Null<Size>()) {
314 fx1 = getIndexValue(ind1, obsdate);
315 }
316 if (ind2 != Null<Size>()) {
317 fx2 = getIndexValue(ind2, obsdate);
318 }
319 res = fx1 / fx2;
320 if (fwddate != Null<Date>()) {
321 auto ind1 = std::find(currencies_.begin(), currencies_.end(), indexInfo.fx()->sourceCurrency().code());
322 auto ind2 = std::find(currencies_.begin(), currencies_.end(), indexInfo.fx()->targetCurrency().code());
323 QL_REQUIRE(ind1 != currencies_.end(), "currency " << indexInfo.fx()->sourceCurrency().code()
324 << " in index " << index << " not handled");
325 QL_REQUIRE(ind2 != currencies_.end(), "currency " << indexInfo.fx()->targetCurrency().code()
326 << " in index " << index << " not handled");
327 res *= getDiscount(std::distance(currencies_.begin(), ind1), obsdate, fwddate) /
328 getDiscount(std::distance(currencies_.begin(), ind2), obsdate, fwddate);
329 }
330 }
331 }
332
333 return res;
334}
RandomVariable getInflationIndexFixing(const bool returnMissingFixingAsNull, const std::string &indexInput, const QuantLib::ext::shared_ptr< ZeroInflationIndex > &infIndex, const Size indexNo, const Date &limDate, const Date &obsdate, const Date &fwddate, const Date &baseDate) const
Definition: modelimpl.cpp:155
virtual RandomVariable getIrIndexValue(const Size indexNo, const Date &d, const Date &fwd=Null< Date >()) const =0
#define ALOG(text)
Logging Macro (Level = Alert)
Definition: log.hpp:544
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fxSpotT0()

Real fxSpotT0 ( const std::string &  forCcy,
const std::string &  domCcy 
) const
overridevirtual

Implements Model.

Definition at line 336 of file modelimpl.cpp.

336 {
337 auto c1 = std::find(currencies_.begin(), currencies_.end(), forCcy);
338 auto c2 = std::find(currencies_.begin(), currencies_.end(), domCcy);
339 QL_REQUIRE(c1 != currencies_.end(), "currency " << forCcy << " not handled");
340 QL_REQUIRE(c2 != currencies_.end(), "currency " << domCcy << " not handled");
341 Size cidx1 = std::distance(currencies_.begin(), c1);
342 Size cidx2 = std::distance(currencies_.begin(), c2);
343 Real fx = 1.0;
344 if (cidx1 > 0)
345 fx *= getFxSpot(cidx1 - 1);
346 if (cidx2 > 0)
347 fx /= getFxSpot(cidx2 - 1);
348 return fx;
349}
+ Here is the call graph for this function:

◆ barrierProbability()

RandomVariable barrierProbability ( const std::string &  index,
const Date &  obsdate1,
const Date &  obsdate2,
const RandomVariable barrier,
const bool  above 
) const
overridevirtual

Implements Model.

Definition at line 351 of file modelimpl.cpp.

352 {
353
354 calculate();
355
356 // determine the fixing calendar (assume that for commodity this is the same for different futures)
357
358 IndexInfo ind(index);
359 auto qlIndex = ind.index(obsdate1);
360
361 // handle all dates < reference date here
362
363 Filter barrierHit(barrier.size(), false);
364 Date d = obsdate1;
365 while (d < std::min(referenceDate(), obsdate2)) {
366 if (qlIndex->fixingCalendar().isBusinessDay(d)) {
367 RandomVariable f = eval(index, d, Null<Date>(), true);
368 if (f.initialised()) {
369 if (above) {
370 barrierHit = barrierHit || f >= barrier;
371 } else {
372 barrierHit = barrierHit || f <= barrier;
373 }
374 } else {
375 // lax check of historical fixings, since e.g. for equity underlyings
376 // we can't expect to get the actual fixing calendar from index info
377 // TODO can we improve this by using the correct calendars?
378 TLOG("ignore missing fixing for " << qlIndex->name() << " on " << QuantLib::io::iso_date(d)
379 << " in ModelImpl::barrierProbability()");
380 }
381 }
382 ++d;
383 }
384
385 RandomVariable barrierHitAsNumber = RandomVariable(barrierHit, 1.0, 0.0);
386 if (obsdate2 < referenceDate()) {
387 return barrierHitAsNumber;
388 }
389
390 // handle future part (call into derived classes, this is model dependent)
391
392 RandomVariable res =
393 getFutureBarrierProb(index, std::max<Date>(obsdate1, referenceDate()), obsdate2, barrier, above);
394
395 // combine historical and future part and return result
396
397 return applyInverseFilter(res, barrierHit) + barrierHitAsNumber;
398}
virtual RandomVariable getFutureBarrierProb(const std::string &index, const Date &obsdate1, const Date &obsdate2, const RandomVariable &barrier, const bool above) const =0
RandomVariable eval(const std::string &index, const Date &obsdate, const Date &fwddate, const bool returnMissingMissingAsNull=false, const bool ignoreTodaysFixing=false) const override
Definition: modelimpl.cpp:181
#define TLOG(text)
Logging Macro (Level = Data)
Definition: log.hpp:556
RandomVariable applyInverseFilter(RandomVariable x, const Filter &f)
+ Here is the call graph for this function:

◆ extractT0Result()

Real extractT0Result ( const RandomVariable value) const
overridevirtual

Implements Model.

Definition at line 400 of file modelimpl.cpp.

400{ return expectation(value).at(0); }
SafeStack< ValueType > value
RandomVariable expectation(const RandomVariable &r)
Real at(const Size i) const
+ Here is the call graph for this function:

◆ getIndexValue()

virtual RandomVariable getIndexValue ( const Size  indexNo,
const Date &  d,
const Date &  fwd = Null< Date >() 
) const
protectedpure virtual

Implemented in BlackScholesBase, FdBlackScholesBase, FdGaussianCam, and GaussianCam.

+ Here is the caller graph for this function:

◆ getIrIndexValue()

virtual RandomVariable getIrIndexValue ( const Size  indexNo,
const Date &  d,
const Date &  fwd = Null< Date >() 
) const
protectedpure virtual

Implemented in BlackScholesBase, FdBlackScholesBase, FdGaussianCam, and GaussianCam.

+ Here is the caller graph for this function:

◆ getInfIndexValue()

virtual RandomVariable getInfIndexValue ( const Size  indexNo,
const Date &  d,
const Date &  fwd 
) const
protectedpure virtual

Implemented in BlackScholesBase, FdBlackScholesBase, FdGaussianCam, and GaussianCam.

+ Here is the caller graph for this function:

◆ getDiscount()

virtual RandomVariable getDiscount ( const Size  idx,
const Date &  s,
const Date &  t 
) const
protectedpure virtual

Implemented in BlackScholesBase, FdBlackScholesBase, FdGaussianCam, and GaussianCam.

+ Here is the caller graph for this function:

◆ getNumeraire()

virtual RandomVariable getNumeraire ( const Date &  s) const
protectedpure virtual

Implemented in BlackScholesBase, FdBlackScholesBase, FdGaussianCam, and GaussianCam.

+ Here is the caller graph for this function:

◆ getFxSpot()

virtual Real getFxSpot ( const Size  idx) const
protectedpure virtual

Implemented in BlackScholesBase, FdBlackScholesBase, FdGaussianCam, and GaussianCam.

+ Here is the caller graph for this function:

◆ getFutureBarrierProb()

virtual RandomVariable getFutureBarrierProb ( const std::string &  index,
const Date &  obsdate1,
const Date &  obsdate2,
const RandomVariable barrier,
const bool  above 
) const
protectedpure virtual

Implemented in BlackScholes, FdBlackScholesBase, FdGaussianCam, GaussianCam, and LocalVol.

+ Here is the caller graph for this function:

◆ getInflationIndexFixing()

RandomVariable getInflationIndexFixing ( const bool  returnMissingFixingAsNull,
const std::string &  indexInput,
const QuantLib::ext::shared_ptr< ZeroInflationIndex > &  infIndex,
const Size  indexNo,
const Date &  limDate,
const Date &  obsdate,
const Date &  fwddate,
const Date &  baseDate 
) const
private

Definition at line 155 of file modelimpl.cpp.

158 {
159 RandomVariable res(size());
160 Real f = infIndex->timeSeries()[limDate];
161 // we exclude historical fixings
162 // - which are "impossible" to know (limDate > refDate)
163 // - which have to be projected because a fwd date is given and they are later than the obsdate
164 if (f != Null<Real>() && !(limDate > referenceDate()) && (fwddate == Null<Date>() || limDate <= obsdate)) {
165 res = RandomVariable(size(), f);
166 } else {
167 Date effectiveObsDate = std::min(obsdate, limDate);
168 if (effectiveObsDate >= baseDate) {
169 res = getInfIndexValue(indexNo, effectiveObsDate, limDate);
170 } else if (returnMissingFixingAsNull) {
171 return RandomVariable();
172 } else {
173 QL_FAIL("missing " << indexInput << " fixing for " << QuantLib::io::iso_date(limDate) << " (obsdate="
174 << QuantLib::io::iso_date(obsdate) << ", fwddate=" << QuantLib::io::iso_date(fwddate)
175 << ", basedate=" << QuantLib::io::iso_date(baseDate) << ")");
176 }
177 }
178 return res;
179}
virtual RandomVariable getInfIndexValue(const Size indexNo, const Date &d, const Date &fwd) const =0
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ dayCounter_

const DayCounter dayCounter_
protected

Definition at line 106 of file modelimpl.hpp.

◆ currencies_

const std::vector<std::string> currencies_
protected

Definition at line 107 of file modelimpl.hpp.

◆ indexCurrencies_

const std::vector<std::string> indexCurrencies_
protected

Definition at line 108 of file modelimpl.hpp.

◆ simulationDates_

const std::set<Date> simulationDates_
protected

Definition at line 109 of file modelimpl.hpp.

◆ iborFallbackConfig_

const IborFallbackConfig iborFallbackConfig_
protected

Definition at line 110 of file modelimpl.hpp.

◆ irIndices_

std::vector<std::pair<IndexInfo, QuantLib::ext::shared_ptr<InterestRateIndex> > > irIndices_
protected

Definition at line 112 of file modelimpl.hpp.

◆ infIndices_

std::vector<std::pair<IndexInfo, QuantLib::ext::shared_ptr<ZeroInflationIndex> > > infIndices_
protected

Definition at line 113 of file modelimpl.hpp.

◆ indices_

std::vector<IndexInfo> indices_
protected

Definition at line 114 of file modelimpl.hpp.