Discussion:
[Quantlib-users] Adjustable Rate Bonds Pricing
d0tc0mguy
2011-06-15 11:56:08 UTC
Permalink
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?
--
View this message in context: http://old.nabble.com/Adjustable-Rate-Bonds-Pricing-tp31850740p31850740.html
Sent from the quantlib-users mailing list archive at Nabble.com.
Luigi Ballabio
2011-06-15 12:20:50 UTC
Permalink
Post by d0tc0mguy
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
d0tc0mguy
2011-06-16 05:29:38 UTC
Permalink
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;
}
}
Post by Luigi Ballabio
Post by d0tc0mguy
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
https://lists.sourceforge.net/lists/listinfo/quantlib-users
--
View this message in context: http://old.nabble.com/Adjustable-Rate-Bonds-Pricing-tp31850740p31857227.html
Sent from the quantlib-users mailing list archive at Nabble.com.
d0tc0mguy
2011-06-16 05:31:43 UTC
Permalink
If I just set the fixingdates as -1 would it work the same way.
Post by d0tc0mguy
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;
}
}
Post by Luigi Ballabio
Post by d0tc0mguy
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
https://lists.sourceforge.net/lists/listinfo/quantlib-users
--
View this message in context: http://old.nabble.com/Adjustable-Rate-Bonds-Pricing-tp31850740p31857283.html
Sent from the quantlib-users mailing list archive at Nabble.com.
Luigi Ballabio
2011-06-16 07:28:28 UTC
Permalink
Post by d0tc0mguy
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
Post by d0tc0mguy
Post by d0tc0mguy
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;
}
}
Post by Luigi Ballabio
Post by d0tc0mguy
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
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.
d0tc0mguy
2011-06-16 08:31:03 UTC
Permalink
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
Post by d0tc0mguy
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
--
View this message in context: http://old.nabble.com/Adjustable-Rate-Bonds-Pricing-tp31850740p31858370.html
Sent from the quantlib-users mailing list archive at Nabble.com.
Luigi Ballabio
2011-06-16 08:52:03 UTC
Permalink
Post by d0tc0mguy
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
d0tc0mguy
2011-06-16 08:56:50 UTC
Permalink
One last question.

What if the repricing frequency and the payment frequency are different?
Post by Luigi Ballabio
Post by d0tc0mguy
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
https://lists.sourceforge.net/lists/listinfo/quantlib-users
--
View this message in context: http://old.nabble.com/Adjustable-Rate-Bonds-Pricing-tp31850740p31858533.html
Sent from the quantlib-users mailing list archive at Nabble.com.
Luigi Ballabio
2011-06-17 14:41:12 UTC
Permalink
Post by d0tc0mguy
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
t***@cds.caltech.edu
2011-06-17 21:54:34 UTC
Permalink
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?
Post by Luigi Ballabio
Post by d0tc0mguy
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
https://lists.sourceforge.net/lists/listinfo/quantlib-users
d0tc0mguy
2011-06-20 03:55:51 UTC
Permalink
Thanks mudcrab. Yes, I am trying to price an bond whose floating rate resets
quarterly and pays semiannually.
Post by t***@cds.caltech.edu
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?
Post by Luigi Ballabio
Post by d0tc0mguy
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
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
https://lists.sourceforge.net/lists/listinfo/quantlib-users
--
View this message in context: http://old.nabble.com/Adjustable-Rate-Bonds-Pricing-tp31850740p31882658.html
Sent from the quantlib-users mailing list archive at Nabble.com.
Luigi Ballabio
2011-06-29 15:24:51 UTC
Permalink
Post by d0tc0mguy
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
Post by d0tc0mguy
Post by t***@cds.caltech.edu
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?
Post by Luigi Ballabio
Post by d0tc0mguy
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
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
https://lists.sourceforge.net/lists/listinfo/quantlib-users
--
If you can't convince them, confuse them.
-- Harry S. Truman
Dominick Samperi
2012-02-21 15:03:29 UTC
Permalink
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
fagoal
2017-07-01 07:23:53 UTC
Permalink
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-tp5756p18373.html
Sent from the quantlib-users mailing list archive at Nabble.com.
cheng li
2017-07-02 14:42:17 UTC
Permalink
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:***@gmail.com]
发送时间: 2017年7月1日 15:24
收件人: quantlib-***@lists.sourceforge.net
主题: 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
QuantLib-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Peter Caspers
2017-07-02 19:09:50 UTC
Permalink
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
Post by cheng li
Hi Fagoal,
Floating rate bond class under the instruments folder should partially meets
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
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
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
-----邮件原件-----
发送时间: 2017年7月1日 15:24
主题: 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.
--
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
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
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Loading...