Hi,
I am trying to use the Quantlib Library to price a adjustable rate bond. It is a Annual Coupon Bond. The bond coupon rate is repriced every 6 months. I am using the FloatingRateBond class for the pricing. I'm not able to understand 1) how to pass the repricing frequency as 6 months to be yield curve? 2) Im using the indexfixing. Is this right? |
On Wed, 2011-06-15 at 04:56 -0700, d0tc0mguy wrote:
> Hi, > > I am trying to use the Quantlib Library to price a adjustable rate bond. It > is a Annual Coupon Bond. The bond coupon rate is repriced every 6 months. I > am using the FloatingRateBond class for the pricing. > > I'm not able to understand > 1) how to pass the repricing frequency as 6 months to be yield curve? > 2) Im using the indexfixing. Is this right? Can you show your code so far? Luigi -- When all else fails, pour a pint of Guinness in the gas tank, advance the spark 20 degrees, cry "God Save the Queen!", and pull the starter knob. -- MG "Series MGA" Workshop Manual ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
I am passing the two fixings dates as a timeseries through addfixings()
#include <ql/quantlib.hpp> #include <boost/foreach.hpp> #include <boost/timer.hpp> #include <iostream> #include <iomanip> #include <ql/utilities/dataformatters.hpp> //#include "utilities.hpp" using namespace QuantLib; #if defined(QL_ENABLE_SESSIONS) namespace QuantLib { Integer sessionId() { return 0; } } #endif struct Datum { Integer n; TimeUnit units; Rate rate; }; int main(int, char* []) { try { boost::timer timer; std::cout << std::endl; Calendar calendar = TARGET(); Date settlementDate(21, October, 2008); Integer fixingDays = 0; Natural settlementDays = 0; Date todaysDate = calendar.advance(settlementDate, -fixingDays, Days); Settings::instance().evaluationDate() = todaysDate; Currency USD = USDCurrency(); std::cout << "Today: " << todaysDate.weekday() << ", " << todaysDate << std::endl; std::cout << "Settlement date: " << settlementDate.weekday() << ", " << settlementDate << std::endl; DayCounter termStructureDayCounter = ActualActual(ActualActual::ISDA); double tolerance = 1.0e-15;; std::vector<Date> dates; std::vector<Rate> rates; dates.push_back(settlementDate); dates.push_back(calendar.advance(settlementDate, 1, Years)); dates.push_back(calendar.advance(settlementDate, 2, Years)); dates.push_back(calendar.advance(settlementDate, 3, Years)); dates.push_back(calendar.advance(settlementDate, 4, Years)); rates.push_back(0.01); rates.push_back(0.015); rates.push_back(0.02); rates.push_back(0.025); rates.push_back(0.03); boost::shared_ptr<YieldTermStructure> bondDiscountingTermStructure( new InterpolatedZeroCurve<Linear>(dates, rates,termStructureDayCounter)); Datum depositData[] = { { 1, Months, 6.000 }, { 2, Months, 6.100 }, { 3, Months, 6.200 }, { 6, Months, 6.300 }, { 9, Months, 6.400 } }; Datum swapData[] = { { 1, Years, 6.500 }, { 5, Years, 7.000 }//, // { 10, Years, 7.500 }, // { 20, Years, 8.000 }, // { 30, Years, 9.000 } }; Size deposits = 5, swaps = 2; std::vector<boost::shared_ptr<RateHelper> > instruments( deposits+swaps); for (Size i=0; i<deposits; i++) { instruments[i] = boost::shared_ptr<RateHelper>(new DepositRateHelper(depositData[i].rate/100, depositData[i].n*depositData[i].units, settlementDays, calendar, ModifiedFollowing, true, ActualActual())); } boost::shared_ptr<IborIndex> index(new IborIndex("dummy", 3*Months, settlementDays, USD, calendar, ModifiedFollowing, false, ActualActual())); for (Size i=0; i<swaps; ++i) { instruments[i+deposits] = boost::shared_ptr<RateHelper>(new SwapRateHelper(swapData[i].rate/100, swapData[i].n*swapData[i].units, calendar, Annual, Unadjusted, ActualActual(), index)); } boost::shared_ptr<YieldTermStructure> termStructure(new PiecewiseYieldCurve<Discount,Linear>(settlementDate, instruments, termStructureDayCounter, tolerance)); RelinkableHandle<YieldTermStructure> discountingTermStructure; RelinkableHandle<YieldTermStructure> forecastingTermStructure; Real faceAmount = 100; boost::shared_ptr<PricingEngine> bondEngine( new DiscountingBondEngine(discountingTermStructure)); RelinkableHandle<YieldTermStructure> liborTermStructure; const boost::shared_ptr<IborIndex> libor3m( new USDLibor(Period(3,Months),liborTermStructure)); //libor3m->addFixing(Date(19, October, 2009),0.0378625); Schedule floatingBondSchedule(Date(21, October, 2008), Date(21, October, 2010), Period(Annual), UnitedStates(UnitedStates::NYSE), Unadjusted, Unadjusted, DateGeneration::Forward, true); FloatingRateBond floatingRateBond( settlementDays, faceAmount, floatingBondSchedule, libor3m, ActualActual(), ModifiedFollowing, Natural(0), // Gearings std::vector<Real>(1, 1.0), // std::vector<Real>(), // Spreads std::vector<Rate>(1, 0.000), //std::vector<Rate>(), // Caps std::vector<Rate>(), // Floors std::vector<Rate>(), // Fixing in arrears true, Real(100.0), Date(21, October, 2008)); floatingRateBond.setPricingEngine(bondEngine); boost::shared_ptr<IborCouponPricer> pricer(new BlackIborCouponPricer); Volatility volatility = 0.0; Handle<OptionletVolatilityStructure> vol; vol = Handle<OptionletVolatilityStructure>( boost::shared_ptr<OptionletVolatilityStructure>(new ConstantOptionletVolatility( settlementDays, calendar, ModifiedFollowing, volatility, ActualActual()))); pricer->setCapletVolatility(vol); setCouponPricer(floatingRateBond.cashflows(),pricer); forecastingTermStructure.linkTo(termStructure); discountingTermStructure.linkTo(bondDiscountingTermStructure); liborTermStructure.linkTo(termStructure); TimeSeries<Real> Fixings; //ERROR --> FUNCTION IS inaccessible //Fixings[Date(20,October,2009)] = libor3m->forecastFixing(Date(20,October,2009)); //Fixings[Date(20,October,2010)] = libor3m->forecastFixing(Date(20,October,2010)); Fixings[Date(20,October,2009)] = liborTermStructure->zeroRate(liborTermStructure->timeFromReference(Date(20,October,2009)),Compounded,Annual,false) ; Fixings[Date(20,October,2010)] = liborTermStructure->zeroRate(liborTermStructure->timeFromReference(Date(20,October,2010)),Compounded,Annual,false) ; libor3m->addFixings(Fixings,true); std::cout << std::endl; /* std :: cout << "Floating Bond - Cashflows :" << std::endl; const std::vector<boost::shared_ptr<QuantLib::CashFlow> >& ftleg = floatingRateBond.cashflows(); for (int j = 0; j<ftleg.size(); j++){ std :: cout << "Date :" << ftleg[j]->date() << " FloatingLeg CashFlow :" << std::fixed << std::setprecision(5) << (ftleg[j]->amount()) << std :: endl ; }*/ std::cout<< floatingRateBond.NPV(); return 0; } catch (std::exception& e) { std::cerr << e.what() << std::endl; return 1; } catch (...) { std::cerr << "unknown error" << std::endl; return 1; } }
|
If I just set the fixingdates as -1 would it work the same way.
|
On Wed, 2011-06-15 at 22:31 -0700, d0tc0mguy wrote:
> If I just set the fixingdates as -1 would it work the same way. That's because the coupon won't look for fixings in the timeseries for future dates. It sees they're in the future and forecasts the fixing on the risk-free curve. If you want the bond to have predetermined rates, why not use a fixed-rate bond? Luigi > d0tc0mguy wrote: > > > > I am passing the two fixings dates as a timeseries through addfixings() > > > > #include <ql/quantlib.hpp> > > #include <boost/foreach.hpp> > > #include <boost/timer.hpp> > > #include <iostream> > > #include <iomanip> > > #include <ql/utilities/dataformatters.hpp> > > //#include "utilities.hpp" > > > > using namespace QuantLib; > > > > #if defined(QL_ENABLE_SESSIONS) > > namespace QuantLib { > > > > Integer sessionId() { return 0; } > > > > } > > #endif > > > > struct Datum { > > Integer n; > > TimeUnit units; > > Rate rate; > > }; > > > > > > int main(int, char* []) { > > > > try { > > > > boost::timer timer; > > std::cout << std::endl; > > > > > > Calendar calendar = TARGET(); > > > > Date settlementDate(21, October, 2008); > > > > Integer fixingDays = 0; > > Natural settlementDays = 0; > > > > Date todaysDate = calendar.advance(settlementDate, -fixingDays, > > Days); > > Settings::instance().evaluationDate() = todaysDate; > > > > Currency USD = USDCurrency(); > > > > std::cout << "Today: " << todaysDate.weekday() > > << ", " << todaysDate << std::endl; > > > > std::cout << "Settlement date: " << settlementDate.weekday() > > << ", " << settlementDate << std::endl; > > DayCounter termStructureDayCounter = > > ActualActual(ActualActual::ISDA); > > > > double tolerance = 1.0e-15;; > > > > std::vector<Date> dates; > > std::vector<Rate> rates; > > dates.push_back(settlementDate); > > dates.push_back(calendar.advance(settlementDate, 1, Years)); > > dates.push_back(calendar.advance(settlementDate, 2, Years)); > > dates.push_back(calendar.advance(settlementDate, 3, Years)); > > dates.push_back(calendar.advance(settlementDate, 4, Years)); > > rates.push_back(0.01); > > rates.push_back(0.015); > > rates.push_back(0.02); > > rates.push_back(0.025); > > rates.push_back(0.03); > > > > boost::shared_ptr<YieldTermStructure> bondDiscountingTermStructure( > > new > > InterpolatedZeroCurve<Linear>(dates, rates,termStructureDayCounter)); > > > > > > Datum depositData[] = { > > { 1, Months, 6.000 }, > > { 2, Months, 6.100 }, > > { 3, Months, 6.200 }, > > { 6, Months, 6.300 }, > > { 9, Months, 6.400 } > > }; > > Datum swapData[] = { > > { 1, Years, 6.500 }, > > { 5, Years, 7.000 }//, > > // { 10, Years, 7.500 }, > > // { 20, Years, 8.000 }, > > // { 30, Years, 9.000 } > > }; > > Size deposits = 5, > > swaps = 2; > > > > std::vector<boost::shared_ptr<RateHelper> > instruments( > > > > deposits+swaps); > > for (Size i=0; i<deposits; i++) { > > instruments[i] = boost::shared_ptr<RateHelper>(new > > DepositRateHelper(depositData[i].rate/100, > > > > depositData[i].n*depositData[i].units, > > settlementDays, calendar, > > ModifiedFollowing, true, > > ActualActual())); > > } > > boost::shared_ptr<IborIndex> index(new IborIndex("dummy", > > 3*Months, > > > > settlementDays, > > USD, > > calendar, > > > > ModifiedFollowing, > > false, > > > > ActualActual())); > > for (Size i=0; i<swaps; ++i) { > > instruments[i+deposits] = > > boost::shared_ptr<RateHelper>(new > > SwapRateHelper(swapData[i].rate/100, > > swapData[i].n*swapData[i].units, > > calendar, > > Annual, Unadjusted, ActualActual(), > > index)); > > } > > boost::shared_ptr<YieldTermStructure> termStructure(new > > PiecewiseYieldCurve<Discount,Linear>(settlementDate, > > instruments, > > termStructureDayCounter, > > tolerance)); > > > > RelinkableHandle<YieldTermStructure> discountingTermStructure; > > > > RelinkableHandle<YieldTermStructure> forecastingTermStructure; > > > > Real faceAmount = 100; > > > > boost::shared_ptr<PricingEngine> bondEngine( > > new DiscountingBondEngine(discountingTermStructure)); > > > > > > RelinkableHandle<YieldTermStructure> liborTermStructure; > > > > const boost::shared_ptr<IborIndex> libor3m( > > new USDLibor(Period(3,Months),liborTermStructure)); > > //libor3m->addFixing(Date(19, October, 2009),0.0378625); > > > > > > > > Schedule floatingBondSchedule(Date(21, October, 2008), > > Date(21, October, 2010), Period(Annual), > > UnitedStates(UnitedStates::NYSE), > > Unadjusted, Unadjusted, DateGeneration::Forward, true); > > > > FloatingRateBond floatingRateBond( > > settlementDays, > > faceAmount, > > floatingBondSchedule, > > libor3m, > > ActualActual(), > > ModifiedFollowing, > > Natural(0), > > // Gearings > > std::vector<Real>(1, 1.0), > > // std::vector<Real>(), > > // Spreads > > std::vector<Rate>(1, 0.000), > > //std::vector<Rate>(), > > // Caps > > std::vector<Rate>(), > > // Floors > > std::vector<Rate>(), > > // Fixing in arrears > > true, > > Real(100.0), > > Date(21, October, 2008)); > > > > floatingRateBond.setPricingEngine(bondEngine); > > > > boost::shared_ptr<IborCouponPricer> pricer(new > > BlackIborCouponPricer); > > > > Volatility volatility = 0.0; > > Handle<OptionletVolatilityStructure> vol; > > vol = Handle<OptionletVolatilityStructure>( > > boost::shared_ptr<OptionletVolatilityStructure>(new > > ConstantOptionletVolatility( > > settlementDays, > > calendar, > > ModifiedFollowing, > > volatility, > > ActualActual()))); > > > > pricer->setCapletVolatility(vol); > > setCouponPricer(floatingRateBond.cashflows(),pricer); > > > > forecastingTermStructure.linkTo(termStructure); > > discountingTermStructure.linkTo(bondDiscountingTermStructure); > > liborTermStructure.linkTo(termStructure); > > > > TimeSeries<Real> Fixings; > > //ERROR --> FUNCTION IS inaccessible > > //Fixings[Date(20,October,2009)] = > > libor3m->forecastFixing(Date(20,October,2009)); > > //Fixings[Date(20,October,2010)] = > > libor3m->forecastFixing(Date(20,October,2010)); > > Fixings[Date(20,October,2009)] = > > liborTermStructure->zeroRate(liborTermStructure->timeFromReference(Date(20,October,2009)),Compounded,Annual,false) > > ; > > Fixings[Date(20,October,2010)] = > > liborTermStructure->zeroRate(liborTermStructure->timeFromReference(Date(20,October,2010)),Compounded,Annual,false) > > ; > > > > libor3m->addFixings(Fixings,true); > > > > std::cout << std::endl; > > /* > > std :: cout << "Floating Bond - Cashflows :" << std::endl; > > const std::vector<boost::shared_ptr<QuantLib::CashFlow> >& ftleg = > > floatingRateBond.cashflows(); > > for (int j = 0; j<ftleg.size(); j++){ > > std :: cout << "Date :" << ftleg[j]->date() > > << " FloatingLeg CashFlow :" << std::fixed << > > std::setprecision(5) << (ftleg[j]->amount()) << std :: endl ; > > }*/ > > std::cout<< floatingRateBond.NPV(); > > > > > > return 0; > > > > } catch (std::exception& e) { > > std::cerr << e.what() << std::endl; > > return 1; > > } catch (...) { > > std::cerr << "unknown error" << std::endl; > > return 1; > > } > > } > > > > > > > > Luigi Ballabio wrote: > >> > >> On Wed, 2011-06-15 at 04:56 -0700, d0tc0mguy wrote: > >>> Hi, > >>> > >>> I am trying to use the Quantlib Library to price a adjustable rate bond. > >>> It > >>> is a Annual Coupon Bond. The bond coupon rate is repriced every 6 > >>> months. I > >>> am using the FloatingRateBond class for the pricing. > >>> > >>> I'm not able to understand > >>> 1) how to pass the repricing frequency as 6 months to be yield curve? > >>> 2) Im using the indexfixing. Is this right? > >> > >> Can you show your code so far? > >> > >> Luigi > >> > >> > >> -- > >> > >> When all else fails, pour a pint of Guinness in the gas tank, > >> advance the spark 20 degrees, cry "God Save the Queen!", and pull > >> the starter knob. > >> -- MG "Series MGA" Workshop Manual > >> > >> > >> > >> ------------------------------------------------------------------------------ > >> EditLive Enterprise is the world's most technically advanced content > >> authoring tool. Experience the power of Track Changes, Inline Image > >> Editing and ensure content is compliant with Accessibility Checking. > >> http://p.sf.net/sfu/ephox-dev2dev > >> _______________________________________________ > >> QuantLib-users mailing list > >> [hidden email] > >> https://lists.sourceforge.net/lists/listinfo/quantlib-users > >> > >> > > > > > -- Father's got the sack from the water-works For smoking of his old cherry-briar; Father's got the sack from the water-works 'Cos he might set the water-works on fire. ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Luigi,
Thanks for the reply. So, if I have cashflows on 21th October 2010 and 21th October 2011 for a floating rate bonds. And, the floating coupon would be fixed on 20th October 2010 and 20th October 2011. how should i pass this information? (by setting the fixingdays = -1. Is it?) Best, Das <quote author="Luigi Ballabio"> On Wed, 2011-06-15 at 22:31 -0700, d0tc0mguy wrote: > If I just set the fixingdates as -1 would it work the same way. That's because the coupon won't look for fixings in the timeseries for future dates. It sees they're in the future and forecasts the fixing on the risk-free curve. If you want the bond to have predetermined rates, why not use a fixed-rate bond? Luigi |
On Thu, 2011-06-16 at 01:31 -0700, d0tc0mguy wrote:
> So, if I have cashflows on 21th October 2010 and 21th October 2011 for a > floating rate bonds. And, the floating coupon would be fixed on 20th October > 2010 and 20th October 2011. how should i pass this information? (by setting > the fixingdays = -1. Is it?) Correct. Luigi -- I'd never join any club that would have the likes of me as a member. -- Groucho Marx ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
One last question. What if the repricing frequency and the payment frequency are different?
|
On Thu, 2011-06-16 at 01:56 -0700, d0tc0mguy wrote:
> > One last question. > > What if the repricing frequency and the payment frequency are different? Sorry, I'm probably not familiar with the instrument. What do you mean by repricing frequency? Luigi -- If you can't convince them, confuse them. -- Harry S. Truman ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Perhaps d0tc0mguy refers to a case like the Canadian Swap Convention where
the floating rate resets Quarterly and pays Semiannually -- would this be non-trivial to implement? > On Thu, 2011-06-16 at 01:56 -0700, d0tc0mguy wrote: >> >> One last question. >> >> What if the repricing frequency and the payment frequency are different? > > Sorry, I'm probably not familiar with the instrument. What do you mean > by repricing frequency? > > Luigi > > > -- > > If you can't convince them, confuse them. > -- Harry S. Truman > > > > ------------------------------------------------------------------------------ > EditLive Enterprise is the world's most technically advanced content > authoring tool. Experience the power of Track Changes, Inline Image > Editing and ensure content is compliant with Accessibility Checking. > http://p.sf.net/sfu/ephox-dev2dev > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users > ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Thanks mudcrab. Yes, I am trying to price an bond whose floating rate resets quarterly and pays semiannually.
|
On Sun, 2011-06-19 at 20:55 -0700, d0tc0mguy wrote:
> Thanks mudcrab. Yes, I am trying to price an bond whose floating rate resets > quarterly and pays semiannually. You can try and see if the classes defined in <ql/experimental/coupons/subperiodcoupons.hpp> work for you. There's still some work to do: for instance, there still is no function to build a vector of them. You'll have to adapt one of the existing functions, such as those in <ql/cashflows/cashflowvectors.hpp>. Once you have it, you can build a bond by using the Bond class directly and passing a vector of cashflows to its constructor. Luigi > > > > mudcrab wrote: > > > > Perhaps d0tc0mguy refers to a case like the Canadian Swap Convention where > > the floating rate resets Quarterly and pays Semiannually -- would this be > > non-trivial to implement? > > > >> On Thu, 2011-06-16 at 01:56 -0700, d0tc0mguy wrote: > >>> > >>> One last question. > >>> > >>> What if the repricing frequency and the payment frequency are different? > >> > >> Sorry, I'm probably not familiar with the instrument. What do you mean > >> by repricing frequency? > >> > >> Luigi > >> > >> > >> -- > >> > >> If you can't convince them, confuse them. > >> -- Harry S. Truman > >> > >> > >> > >> ------------------------------------------------------------------------------ > >> EditLive Enterprise is the world's most technically advanced content > >> authoring tool. Experience the power of Track Changes, Inline Image > >> Editing and ensure content is compliant with Accessibility Checking. > >> http://p.sf.net/sfu/ephox-dev2dev > >> _______________________________________________ > >> QuantLib-users mailing list > >> [hidden email] > >> https://lists.sourceforge.net/lists/listinfo/quantlib-users > >> > > > > > > > > ------------------------------------------------------------------------------ > > EditLive Enterprise is the world's most technically advanced content > > authoring tool. Experience the power of Track Changes, Inline Image > > Editing and ensure content is compliant with Accessibility Checking. > > http://p.sf.net/sfu/ephox-dev2dev > > _______________________________________________ > > QuantLib-users mailing list > > [hidden email] > > https://lists.sourceforge.net/lists/listinfo/quantlib-users > > > > > -- If you can't convince them, confuse them. -- Harry S. Truman ------------------------------------------------------------------------------ All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2d-c2 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hello,
I was thinking about submitting some code that computes bond prices following that Moosmuller and Braess-Fangmeyer conventions (was used for German govt bonds), but I am not sure if these conventions are still in use today. Can anyone comment on if/where these conventions are used today? Thanks, Dominick ------------------------------------------------------------------------------ Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by Luigi Ballabio
Does quantlib 1.9 support this non-trival case? like fixing rate frequency is quarterly and payment frequency is semiannual.
|
Hi Fagoal,
Floating rate bond class under the instruments folder should partially meets your requirements: https://github.com/lballabio/QuantLib/blob/master/ql/instruments/bonds/float ingratebond.hpp This is a bond with variable rate linked to a ibor index. According to your further description, you are looking forward to the sub period coupon class under QuantLib experimental folder: https://github.com/lballabio/QuantLib/blob/master/ql/experimental/coupons/su bperiodcoupons.hpp Peter Casper has another similar version of this in his open risk engine project: https://github.com/OpenSourceRisk/Engine/blob/master/QuantExt/qle/cashflows/ subperiodscoupon.hpp also based on QuantLib. It should be easy for yourself to extend QuantLib with a new type of bond class based on sub period coupon. It will be very similar to floating rate bond class. Regards, Cheng -----邮件原件----- 发件人: fagoal [mailto:[hidden email]] 发送时间: 2017年7月1日 15:24 收件人: [hidden email] 主题: Re: [Quantlib-users] Adjustable Rate Bonds Pricing Does quantlib 1.9 support this non-trival case? like fixing rate frequency is quarterly and payment frequency is semiannual. -- View this message in context: http://quantlib.10058.n7.nabble.com/Adjustable-Rate-Bonds-Pricing-tp5756p183 73.html Sent from the quantlib-users mailing list archive at Nabble.com. ---------------------------------------------------------------------------- -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Cheng, Fagoal,
I think you can also make do without creating a new class, simply set up a leg of sub period coupons (which you can take from QuantLib or ORE / QuantExt, the latter being a bit more general, if needed) and then pass this leg into the generic Bond constructor (see bond.hpp) Bond(Natural settlementDays, const Calendar& calendar, const Date& issueDate = Date(), const Leg& coupons = Leg()); The leg only needs to contain the coupons, amortisation and redemption flows are added automatically based on the notional information that comes with the coupons. Best Regards Peter > On 02 Jul 2017, at 16:42, cheng li <[hidden email]> wrote: > > Hi Fagoal, > > Floating rate bond class under the instruments folder should partially meets > your requirements: > > https://github.com/lballabio/QuantLib/blob/master/ql/instruments/bonds/float > ingratebond.hpp > > This is a bond with variable rate linked to a ibor index. > > According to your further description, you are looking forward to the sub > period coupon class under QuantLib experimental folder: > > https://github.com/lballabio/QuantLib/blob/master/ql/experimental/coupons/su > bperiodcoupons.hpp > > Peter Casper has another similar version of this in his open risk engine > project: > > https://github.com/OpenSourceRisk/Engine/blob/master/QuantExt/qle/cashflows/ > subperiodscoupon.hpp > > also based on QuantLib. > > It should be easy for yourself to extend QuantLib with a new type of bond > class based on sub period coupon. It will be very similar to floating rate > bond class. > > Regards, > Cheng > > -----邮件原件----- > 发件人: fagoal [mailto:[hidden email]] > 发送时间: 2017年7月1日 15:24 > 收件人: [hidden email] > 主题: Re: [Quantlib-users] Adjustable Rate Bonds Pricing > > Does quantlib 1.9 support this non-trival case? like fixing rate frequency > is quarterly and payment frequency is semiannual. > > > > -- > View this message in context: > http://quantlib.10058.n7.nabble.com/Adjustable-Rate-Bonds-Pricing-tp5756p183 > 73.html > Sent from the quantlib-users mailing list archive at Nabble.com. > > ---------------------------------------------------------------------------- > -- > Check out the vibrant tech community on one of the world's most engaging > tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |