FixedRateBond question

Posted by Dagur Gunnarsson-2 on
URL: http://quantlib.414.s1.nabble.com/FixedRateBond-question-tp5985.html

I am calculating the cashflow for a FixedRateBond which start paying coupons 2,37222 years after its issue date.  After that period the coupons are semiannual.  During the 2,37222 years period, I would like my bond to accrue Compounding interests (1.06)^2,37222-1 and not Simple interests (0,06)*2,37222 - which seems to be the Default for FixedRateBonds.

My question is, how do I make my FixedRateBond calculate Compounding interests instead of Simple??

my program is the following :

#include <ql/quantlib.hpp>
#include <iostream>

using namespace QuantLib;
using namespace std;

int main(int, char* [])
{
  Date interestFromDate(Date(1, Jun, 2011)), issueDate(Date(1, Jun, 2011)),
    firstInstallmentDate(Date(15, Oct, 2016)), maturityDate(Date(15, Oct, 2016)),
    firstCouponDate(Date(15, Oct, 2013));

  Rate rate(0.06);

  Frequency freq(Semiannual);

  DayCounter dayCounter(Thirty360(Thirty360::European));
  Compounding compounding(Compounded);
  

  Schedule *schedule = new Schedule(interestFromDate, 
   maturityDate, 
   Period(freq), 
   Iceland(), 
   Unadjusted, 
   Unadjusted, 
   DateGeneration::Backward, 
   false, 
   firstCouponDate);

  FixedRateBond* bond = new FixedRateBond(0, 
 100.0, 
 *schedule, 
 vector<Rate>(1, Rate(rate)), 
 dayCounter, 
 Unadjusted,
 Real(100.0), 
 issueDate);

  boost::shared_ptr<YieldTermStructure> 
    flatTermStructure(
     new FlatForward(
     issueDate, 
     Handle<Quote>(boost::shared_ptr<Quote>(new SimpleQuote(rate))), 
     dayCounter,
     compounding,
     freq));
  
  RelinkableHandle<YieldTermStructure> discountingTermStructure(flatTermStructure);
  discountingTermStructure.linkTo(flatTermStructure);
  
  boost::shared_ptr<PricingEngine> bondEngine(new DiscountingBondEngine(discountingTermStructure));
  bond->setPricingEngine(bondEngine);
  
  std::vector <boost::shared_ptr<QuantLib::CashFlow>, std::allocator<boost::shared_ptr<QuantLib::CashFlow> > > leg = bond->cashflows();
    
  for (unsigned i = 0; i < leg.size(); i++) {
    cout<<"day["<<i<<"] is "<<leg[i]->date()<<" "<<setprecision(15)
<<dayCounter.yearFraction(Date(1, Jun, 2011), leg[i]->date())<<", cashflow["<<i<<"] is "<<leg[i]->amount()<<endl;
    }

}

------------------------------------------------------------------------------
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users