What does this forward curve primitive function do?
Posted by
Student T on
Mar 16, 2017; 1:42pm
URL: http://quantlib.414.s1.nabble.com/What-does-this-forward-curve-primitive-function-do-tp18145.html
I have an object for InterpolatedForwardCurve and I try to calculate implied discount rate. The implementation calls InterpolatedForwardCurve<T>::zeroYieldImpl.
The source code for
InterpolatedForwardCurve<T>::zeroYieldImpl:
template <class T>
Rate InterpolatedForwardCurve<T>::zeroYieldImpl(Time t) const {
if (t == 0.0)
return forwardImpl(0.0);
Real integral;
if (t <= this->times_.back()) {
integral = this->interpolation_.primitive(t, true);
} else {
// flat fwd extrapolation
integral = this->interpolation_.primitive(this->times_.back(), true)
+ this->data_.back()*(t - this->times_.back());
}
return integral/t;
}
My code runs into integral = this->interpolation_.primitive(t, true);
The implementation for the primitive function is:
Real primitive(Real x) const {
Size i = this->locate(x);
Real dx = x-this->xBegin_[i];
return primitiveConst_[i] +
dx*(this->yBegin_[i] + 0.5*dx*s_[i]);
}
Let's say my curve defines for {t1, t2, t3, t4}. I try to calculate discount rate at t2.
Q1: I think the code is trying to do numerical integration from t2 to t3. Am I correct?
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org!
http://sdm.link/slashdot_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users