Login  Register

Re: Negative price with Forward Rates

Posted by v17 on Jan 27, 2014; 4:50am
URL: http://quantlib.414.s1.nabble.com/Negative-price-with-Forward-Rates-tp14868p14899.html

Hi Luigi,

I passed evaluation date as the first date in liborDates. Also added corresponding rate in liborRates. But now it gives exception - "LogInterpolation primitive not implemented"

Below are new values - 

liborDates -

January 24th, 2014
July 24th, 2014
January 24th, 2015
January 24th, 2016
January 24th, 2017
January 24th, 2018
January 24th, 2019
January 24th, 2020
January 24th, 2021
January 24th, 2022
January 24th, 2023
January 24th, 2024
January 24th, 2029

liborRates -

8.4
8.4955
8.36907
8.38416
8.47267
8.62786
8.69832
8.71107
8.85289
8.99607
8.80085
8.7099
9.00594

Is exception coming due to InterpolatedForwardCurve<LogLinear> ...?

Thanks in advance!


On Thursday, January 23, 2014 5:02 PM, Luigi Ballabio <[hidden email]> wrote:
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