Login  Register

Re: Negative price with Forward Rates

Posted by Luigi Ballabio on Jan 23, 2014; 11:32am
URL: http://quantlib.414.s1.nabble.com/Negative-price-with-Forward-Rates-tp14868p14885.html

You should pass the evaluation date as the first date in liborDates.
You'll need a corresponding extra element in liborRates; just
replicate the first you have for constant rates from today to the
first actual Libor date.

Luigi

On Mon, Jan 20, 2014 at 8:12 AM, v17 <[hidden email]> wrote:

> 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
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/Negative-price-with-Forward-Rates-tp14868.html
> Sent from the quantlib-dev mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> CenturyLink Cloud: The Leader in Enterprise Cloud Services.
> Learn Why More Businesses Are Choosing CenturyLink Cloud For
> Critical Workloads, Development Environments & Everything In Between.
> Get a Quote or Start a Free Trial Today.
> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-dev mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-dev



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev