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 |
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 |
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 |
Yes. the curve is trying to integrate the forwards to get the
discounts, but the LogLinear interpolator doesn't provide a formula for that. You'll have to choose another interpolation. Luigi On Mon, Jan 27, 2014 at 5:50 AM, varun yadav <[hidden email]> wrote: > 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 >> > > -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> ------------------------------------------------------------------------------ WatchGuard Dimension instantly turns raw network data into actionable security intelligence. It gives you real-time visual feedback on key security issues and trends. Skip the complicated setup - simply import a virtual appliance and go from zero to informed in seconds. http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Luigi, just out of curiosity, in ForwardRateStructure there seems to
be a general purpose implementation to get the zero yield by integration over the forwards. Wouldn't the situation here be a use case for exactly this (i.e. catch the exception and invoke the base class method instead) ? best, Peter On 28 January 2014 12:37, Luigi Ballabio <[hidden email]> wrote: > Yes. the curve is trying to integrate the forwards to get the > discounts, but the LogLinear interpolator doesn't provide a formula > for that. You'll have to choose another interpolation. > > Luigi > > On Mon, Jan 27, 2014 at 5:50 AM, varun yadav <[hidden email]> wrote: >> 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 >>> >> >> > > > > -- > <https://implementingquantlib.blogspot.com> > <https://twitter.com/lballabio> > > ------------------------------------------------------------------------------ > WatchGuard Dimension instantly turns raw network data into actionable > security intelligence. It gives you real-time visual feedback on key > security issues and trends. Skip the complicated setup - simply import > a virtual appliance and go from zero to informed in seconds. > http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk > _______________________________________________ > QuantLib-dev mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-dev ------------------------------------------------------------------------------ WatchGuard Dimension instantly turns raw network data into actionable security intelligence. It gives you real-time visual feedback on key security issues and trends. Skip the complicated setup - simply import a virtual appliance and go from zero to informed in seconds. http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Yes, possibly. In that case, we'd have to make the change in
InterpolatedForwardCurve<T>::zeroYieldImpl. But since we don't have different exception types, we'd have to catch the exception and check the error message it contains to decide whether to switch to the base-class method (because if it's a different error, we'd want to let it bubble up to client code). It wouldn't look very pretty :) Another alternative would be to implement the numerical integration in the LogLinear interpolation. I'm not sure that I like a situation in which some curves are reasonably fast and others are much slower depending on the interpolation method. Sure, the current situation is that some interpolations don't work, so it might be an improvement anyway... (Oh, and a final note: while it makes sense to use log-linear with discounts, because they're given by exp(-rt), I'm not sure that it makes sense to use it with zero and forward rates.) Luigi On Tue, Jan 28, 2014 at 1:21 PM, Peter Caspers <[hidden email]> wrote: > Luigi, just out of curiosity, in ForwardRateStructure there seems to > be a general purpose implementation to get the zero yield by > integration over the forwards. Wouldn't the situation here be a use > case for exactly this (i.e. catch the exception and invoke the base > class method instead) ? > best, Peter > > On 28 January 2014 12:37, Luigi Ballabio <[hidden email]> wrote: >> Yes. the curve is trying to integrate the forwards to get the >> discounts, but the LogLinear interpolator doesn't provide a formula >> for that. You'll have to choose another interpolation. >> >> Luigi >> >> On Mon, Jan 27, 2014 at 5:50 AM, varun yadav <[hidden email]> wrote: >>> 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 >>>> >>> >>> >> >> >> >> -- >> <https://implementingquantlib.blogspot.com> >> <https://twitter.com/lballabio> >> >> ------------------------------------------------------------------------------ >> WatchGuard Dimension instantly turns raw network data into actionable >> security intelligence. It gives you real-time visual feedback on key >> security issues and trends. Skip the complicated setup - simply import >> a virtual appliance and go from zero to informed in seconds. >> http://pubads.g.doubleclick.net/gampad/clk?id=123612991&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> ------------------------------------------------------------------------------ WatchGuard Dimension instantly turns raw network data into actionable security intelligence. It gives you real-time visual feedback on key security issues and trends. Skip the complicated setup - simply import a virtual appliance and go from zero to informed in seconds. http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
thanks, yes I agree, this is more a design question than of real
practical interest. The log-linear interpolation in zeroyield is very briefly discussed in the Hagan / West paper on yield curve construction, playing in the same league as linear in zeroyield (which is yet very popular I think) or linear in discount. Log-linear in forwards is not even mentioned there, so probably we should not make that work in QuantLib either :-) On 1 February 2014 16:47, Luigi Ballabio <[hidden email]> wrote: > Yes, possibly. In that case, we'd have to make the change in > InterpolatedForwardCurve<T>::zeroYieldImpl. But since we don't have > different exception types, we'd have to catch the exception and check > the error message it contains to decide whether to switch to the > base-class method (because if it's a different error, we'd want to let > it bubble up to client code). It wouldn't look very pretty :) > Another alternative would be to implement the numerical integration in > the LogLinear interpolation. I'm not sure that I like a situation in > which some curves are reasonably fast and others are much slower > depending on the interpolation method. Sure, the current situation is > that some interpolations don't work, so it might be an improvement > anyway... > > (Oh, and a final note: while it makes sense to use log-linear with > discounts, because they're given by exp(-rt), I'm not sure that it > makes sense to use it with zero and forward rates.) > > Luigi > > > > On Tue, Jan 28, 2014 at 1:21 PM, Peter Caspers <[hidden email]> wrote: >> Luigi, just out of curiosity, in ForwardRateStructure there seems to >> be a general purpose implementation to get the zero yield by >> integration over the forwards. Wouldn't the situation here be a use >> case for exactly this (i.e. catch the exception and invoke the base >> class method instead) ? >> best, Peter >> >> On 28 January 2014 12:37, Luigi Ballabio <[hidden email]> wrote: >>> Yes. the curve is trying to integrate the forwards to get the >>> discounts, but the LogLinear interpolator doesn't provide a formula >>> for that. You'll have to choose another interpolation. >>> >>> Luigi >>> >>> On Mon, Jan 27, 2014 at 5:50 AM, varun yadav <[hidden email]> wrote: >>>> 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 >>>>> >>>> >>>> >>> >>> >>> >>> -- >>> <https://implementingquantlib.blogspot.com> >>> <https://twitter.com/lballabio> >>> >>> ------------------------------------------------------------------------------ >>> WatchGuard Dimension instantly turns raw network data into actionable >>> security intelligence. It gives you real-time visual feedback on key >>> security issues and trends. Skip the complicated setup - simply import >>> a virtual appliance and go from zero to informed in seconds. >>> http://pubads.g.doubleclick.net/gampad/clk?id=123612991&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> ------------------------------------------------------------------------------ WatchGuard Dimension instantly turns raw network data into actionable security intelligence. It gives you real-time visual feedback on key security issues and trends. Skip the complicated setup - simply import a virtual appliance and go from zero to informed in seconds. http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Free forum by Nabble | Edit this page |