|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Floating rate Bond_ Bootstrapping errorHi I am trying to test the Floating rate Bond, however ended up with the following error; " could not bootstrap the 1st instrument, maturity date April 28,2008. error message: negative time <-0.00273224> given " Is the error related to bond Settlement date/dated date?? Also , I would like to know what is "Gearing" & "DatedDate" in Floating Rate Bond constructor given is the test code I tried; .............................................................................................. Integer settlementDays = 3; Integer length = 5; Calendar calendar = TARGET(); Date today = calendar.adjust(Date::todaysDate()); Settings::instance().evaluationDate() = today; Date settlementDate = calendar.advance(today, settlementDays, Days); Date exerciseDate = calendar.advance(settlementDate, length, Years); Date issueDate = calendar.advance(exerciseDate, -length, Years); Real faceAmount_=100; BusinessDayConvention businessDayConvention_=Following; DayCounter dayCount_ = Actual365Fixed(); Date stub_; bool fromEnd_=true; std::vector<Rate> coupons_(1); coupons_[0]=0.07875; Date maturityDate_ = exerciseDate ; Date datedDate_ = settlementDate; Frequency frequency_ = Semiannual; Real redemption_ = 100.0; bool longFinal_= false; BusinessDayConvention accrualConvention_ = Following; //FLOATING RATE BOND: std::vector< Real > Gearings(1, 1.0); std::vector< Spread > Spreads(1, 0.0); Integer fixingDays = 2; // deposits Rate d1wQuote=0.0382; Rate d1mQuote=0.0372; Rate d3mQuote=0.0363; Rate d6mQuote=0.0353; Rate d9mQuote=0.0348; Rate d1yQuote=0.0345; // swaps Rate s2yQuote=0.037125; Rate s3yQuote=0.0398; Rate s5yQuote=0.0443; Rate s10yQuote=0.05165; Rate s15yQuote=0.055175; // Market data setup in QUOTES // deposits boost::shared_ptr<Quote> d1wRate(new SimpleQuote(d1wQuote)); boost::shared_ptr<Quote> d1mRate(new SimpleQuote(d1mQuote)); boost::shared_ptr<Quote> d3mRate(new SimpleQuote(d3mQuote)); boost::shared_ptr<Quote> d6mRate(new SimpleQuote(d6mQuote)); boost::shared_ptr<Quote> d9mRate(new SimpleQuote(d9mQuote)); boost::shared_ptr<Quote> d1yRate(new SimpleQuote(d1yQuote)); // swaps boost::shared_ptr<Quote> s2yRate(new SimpleQuote(s2yQuote)); boost::shared_ptr<Quote> s3yRate(new SimpleQuote(s3yQuote)); boost::shared_ptr<Quote> s5yRate(new SimpleQuote(s5yQuote)); boost::shared_ptr<Quote> s10yRate(new SimpleQuote(s10yQuote)); boost::shared_ptr<Quote> s15yRate(new SimpleQuote(s15yQuote)); DayCounter depositDayCounter = Actual360(); //RATE HELPER CLASS //set DEPOSITS boost::shared_ptr<RateHelper> d1w(new DepositRateHelper( Handle<Quote>(d1wRate), 1*Weeks, fixingDays, calendar, ModifiedFollowing, true, fixingDays, depositDayCounter)); boost::shared_ptr<RateHelper> d1m(new DepositRateHelper( Handle<Quote>(d1mRate), 1*Months, fixingDays, calendar, ModifiedFollowing, true, fixingDays, depositDayCounter)); boost::shared_ptr<RateHelper> d3m(new DepositRateHelper( Handle<Quote>(d3mRate), 3*Months, fixingDays, calendar, ModifiedFollowing, true, fixingDays, depositDayCounter)); boost::shared_ptr<RateHelper> d6m(new DepositRateHelper( Handle<Quote>(d6mRate), 6*Months, fixingDays, calendar, ModifiedFollowing, true, fixingDays, depositDayCounter)); boost::shared_ptr<RateHelper> d9m(new DepositRateHelper( Handle<Quote>(d9mRate), 9*Months, fixingDays, calendar, ModifiedFollowing, true, fixingDays, depositDayCounter)); boost::shared_ptr<RateHelper> d1y(new DepositRateHelper( Handle<Quote>(d1yRate), 1*Years, fixingDays, calendar, ModifiedFollowing, true, fixingDays, depositDayCounter)); // setup SWAPS Frequency swFixedLegFrequency = Annual; BusinessDayConvention swFixedLegConvention = Unadjusted; DayCounter swFixedLegDayCounter = Thirty360(Thirty360::European); boost::shared_ptr<IborIndex> swFloatingLegIndex(new Euribor6M); boost::shared_ptr<RateHelper> s2y(new SwapRateHelper( Handle<Quote>(s2yRate), 2*Years, fixingDays, calendar, swFixedLegFrequency, swFixedLegConvention, swFixedLegDayCounter, swFloatingLegIndex)); boost::shared_ptr<RateHelper> s3y(new SwapRateHelper( Handle<Quote>(s3yRate), 3*Years, fixingDays, calendar, swFixedLegFrequency, swFixedLegConvention, swFixedLegDayCounter, swFloatingLegIndex)); boost::shared_ptr<RateHelper> s5y(new SwapRateHelper( Handle<Quote>(s5yRate), 5*Years, fixingDays, calendar, swFixedLegFrequency, swFixedLegConvention, swFixedLegDayCounter, swFloatingLegIndex)); boost::shared_ptr<RateHelper> s10y(new SwapRateHelper( Handle<Quote>(s10yRate), 10*Years, fixingDays, calendar, swFixedLegFrequency, swFixedLegConvention, swFixedLegDayCounter, swFloatingLegIndex)); boost::shared_ptr<RateHelper> s15y(new SwapRateHelper( Handle<Quote>(s15yRate), 15*Years, fixingDays, calendar, swFixedLegFrequency, swFixedLegConvention, swFixedLegDayCounter, swFloatingLegIndex)); DayCounter termStructureDayCounter = ActualActual(ActualActual::ISDA); double tolerance = 1.0e-15; //Instrument vector creation // A depo-swap curve std::vector<boost::shared_ptr<RateHelper> > depoSwapInstruments; depoSwapInstruments.push_back(d1w); depoSwapInstruments.push_back(d1m); depoSwapInstruments.push_back(d3m); depoSwapInstruments.push_back(d6m); depoSwapInstruments.push_back(d9m); depoSwapInstruments.push_back(d1y); depoSwapInstruments.push_back(s2y); depoSwapInstruments.push_back(s3y); depoSwapInstruments.push_back(s5y); depoSwapInstruments.push_back(s10y); depoSwapInstruments.push_back(s15y); boost::shared_ptr<YieldTermStructure> depoSwapTermStructure( new PiecewiseYieldCurve<Discount,LogLinear>( settlementDate, depoSwapInstruments,termStructureDayCounter, tolerance)); Handle<YieldTermStructure> forecastingTermStructure; forecastingTermStructure.linkTo(depoSwapTermStructure); boost::shared_ptr<IborIndex> euriborIndex( new Euribor6M(forecastingTermStructure)); /* FloatingRateBond CONSTRUCTOR: FloatingRateBond FLOATINGbond(faceAmount_,issueDate,datedDate_,maturityDate_,settlementDays,euriborIndex,fixingDays,Gearings,Spreads,frequency_,calendar,dayCount_,accrualConvention_,businessDayConvention_,redemption_,forecastingTermStructure,stub_,fromEnd_); Real dirtypriceBondF = FLOATINGbond.dirtyPrice(); std::cout<<"DIRTY PRICE"<<" "<<dirtypriceBondF<<std::endl; Compounding comp_=Compounded; Real YIELDF = FLOATINGbond.yield(comp_); std::cout<<"YIELD"<<" "<<YIELDF<<std::endl; ......................................................................................................................... Thanks Amit ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ QuantLib-users mailing list QuantLib-users@... https://lists.sourceforge.net/lists/listinfo/quantlib-users |
|
|
|
|
|
|
| Free Forum Powered by Nabble | Forum Help |