Example #1
0
        /*! \warning Setting a pricing engine to the passed bond from
         *           external code will cause the bootstrap to fail or
         *           to give wrong results. It is advised to discard
         *           the bond after creating the helper, so that the
         *           helper has sole ownership of it.
         */
        public BondHelper(Handle <Quote> price, Bond bond, bool useCleanPrice = true)
            : base(price)
        {
            bond_ = bond;

            // the bond's last cashflow date, which can be later than
            // bond's maturity date because of adjustment
            latestDate_   = bond_.cashflows().Last().date();
            earliestDate_ = bond_.nextCashFlowDate();

            termStructureHandle_ = new RelinkableHandle <YieldTermStructure>();
            bond_.setPricingEngine(new DiscountingBondEngine(termStructureHandle_));

            useCleanPrice_ = useCleanPrice;
        }