Negative price with Forward Rates
Posted by v17 on Jan 20, 2014; 7:12am
URL: http://quantlib.414.s1.nabble.com/Negative-price-with-Forward-Rates-tp14868.html
Hi Everyone,
I have following piece of code which gives Exception "negative time (-0.5) given"
vector <Real> &forwardRates;
const int size = liborRates.size();
vector<Date> liborDates(liborTenors.size());
for (int i = 0; i < size; i++)
{
curDate = ycDef.cal.advance(ycDef.evalDate, liborTenors[i]);
liborDates[i] = curDate;
}
yieldCurve = shared_ptr<YieldTermStructure>(new InterpolatedForwardCurve<LogLinear>(liborDates, liborRates, ycDef.dc, ycDef.cal));
yieldCurve->enableExtrapolation();
size = liborTenors.size();
forwardRates.clear();
forwardRates.resize(size);
try
{
forwardRates[i] = yieldCurve->forwardRate(ycDef.evalDate, ycDef.evalDate + liborTenors[i] , ycDef.dc, Compounded, Annual);
}
catch(QuantLib::Error& e)
{
cout << e.what() << endl;
throw;
}
liborDates has below values -
July 20th, 2014
January 20th, 2015
January 20th, 2016
January 20th, 2017
January 20th, 2018
January 20th, 2019
January 20th, 2020
January 20th, 2021
January 20th, 2022
January 20th, 2023
January 20th, 2024
January 20th, 2029
while liborRates is
8.53854
8.40083
8.39311
8.44955
8.56089
8.65359
8.68869
8.80096
8.9133
8.74109
8.66277
8.98536
eval date is January 20th, 2014
What is causing negative time exception?
Thanks,
Varun