|
From: R S <raj...@ho...> - 2019-04-26 15:11:41
|
Ok - thanks for that. Is that the only “rule” or do you think there is some sort of mapping between the Interpolator’s and the Trait’s? (or is it a question of trial and error?) Regards -RS On 26 Apr 2019, 16:09 +0100, Luigi Ballabio <lui...@gm...>, wrote: Ok, I checked. Log interpolation is indeed not usable with forward or zero rates. Luigi On Fri, Apr 26, 2019 at 4:04 PM R S <raj...@ho...<mailto:raj...@ho...>> wrote: I am using the very old version - nothing negative there BusinessDayConvention depoBizDayConv = ModifiedFollowing; DayCounter depoDCC = Actual360(); vector<Rate> rates; rates.push_back(0.0382); rates.push_back(0.0372); rates.push_back(0.0363); rates.push_back(0.0353); rates.push_back(0.0348); rates.push_back(0.0345); /** * Derfine deposit ladder */ vector<Period> qlperiods; qlperiods.push_back(1 * Weeks); qlperiods.push_back(1 * Months); qlperiods.push_back(3 * Months); qlperiods.push_back(6 * Months); qlperiods.push_back(9 * Months); qlperiods.push_back(1 * Years); /** * Populate Deposit Helpers */ rateUtility.depoHelpers(rates, qlperiods, calendar, fixingDays, true, depoDCC, depoBizDayConv, helper); /** * Define swap rates */ Frequency swapFixedLegFrequency = Annual; BusinessDayConvention swapFixedLegConvention = Unadjusted; DayCounter swFixedLegDCC = Thirty360(Thirty360::European); boost::shared_ptr<IborIndex> swapFloatingLegIndex(new Euribor6M); rates.clear(); rates.push_back(0.037125); rates.push_back(0.0398); rates.push_back(0.0443); rates.push_back(0.05165); rates.push_back(0.055175); /** * define swap ladder */ qlperiods.clear(); qlperiods.push_back(2 * Years); qlperiods.push_back(3 * Years); qlperiods.push_back(5 * Years); qlperiods.push_back(10 * Years); qlperiods.push_back(15 * Years); /** * Populate Swap Helpers */ rateUtility.swapRateHelpers(rates, qlperiods, calendar, swapFixedLegFrequency, swapFixedLegConvention, swFixedLegDCC, swapFloatingLegIndex, helper); Regards -RS On 26 Apr 2019, 14:34 +0100, Luigi Ballabio <lui...@gm...<mailto:lui...@gm...>>, wrote: What version of the examples? In the most recent one, a few of the input rates are negatives and log-linear interpolation can't handle them. Luigi On Tue, Apr 9, 2019 at 9:31 AM R S <raj...@ho...<mailto:raj...@ho...>> wrote: Yes - I get an error on certain combinations of Trait and. Interpolator For example, with a declaration of PiecewiseYieldCurve<ForwardRate, BackwardFlat>, I can get a dump of dates and rates from the curve However, if I. change the declaration to PiecewiseYieldCurve<ForwardRate, LogLinear>, I get this error: terminate called after throwing an instance of 'QuantLib::Error' what(): 1st iteration: failed at 1st alive instrument, pillar September 29th, 2004, maturity September 29th, 2004, reference date September 22nd, 2004: invalid value (-1) at index 0 Process finished with exit code 134 (interrupted by signal 6: SIGABRT) The data is based on the DepoSwap example from the Quantlib Examples Regards -RS On 8 Apr 2019, 16:42 +0100, Luigi Ballabio <lui...@gm...<mailto:lui...@gm...>>, wrote: Yes, the bootstrap is done when the curve is first used. That would be when it's first asked for rates or discounts during swap valuation. What do you mean when you say that some combinations don't work? Do you get a compile-time error, or does the bootstrap fail at run-time? Luigi On Wed, Mar 27, 2019 at 10:18 PM R S <raj...@ho...<mailto:raj...@ho...>> wrote: Thanks for this tip on this serialisation. I attach the results of running Swap pricing with PiecewiseYieldCurve<Discount,LogLinear> versus InterpolatedDiscount<LogLinear> curve (I get similar results when I compare PiecewiseYieldCurve<ForwardRate,BackwardFlat> with InterpolatedDiscount<BackwardFlat>) As you can see, the curve generation time remains unchanged but the swap valuation time is halved (all times in nanoseconds) Is this because the bootstrapping occurs only when NPV on the swap is called? Also, I noticed that certain Trait’s work only with certain interpolators. For example, ForwardRate trait only works with BackwardFlat. Are the valid combinations documented somewhere? |