Esempio n. 1
0
 public Date previousCashFlowDate(Date settlement = null)
 {
     return(BondFunctions.previousCashFlowDate(this, settlement));
 }
Esempio n. 2
0
        protected override void performCalculations()
        {
            List <BTP>             btps   = basket_.btps();
            List <Handle <Quote> > quotes = basket_.cleanPriceQuotes();
            Date bondSettlementDate       = btps[0].settlementDate();

            for (int i = 0; i < basket_.size(); ++i)
            {
                yields_[i] = BondFunctions.yield(btps[i], quotes[i].link.value(),
                                                 new ActualActual(ActualActual.Convention.ISMA),
                                                 Compounding.Compounded, Frequency.Annual,
                                                 bondSettlementDate,
                                                 // accuracy, maxIterations, guess
                                                 1.0e-10, 100, yields_[i]);

                durations_[i] = BondFunctions.duration(btps[i], yields_[i], new ActualActual(ActualActual.Convention.ISMA),
                                                       Compounding.Compounded, Frequency.Annual, Duration.Type.Modified,
                                                       bondSettlementDate);
            }

            duration_ = 0;
            basket_.weights().ForEach((ii, vv) => duration_ += vv * yields()[ii]);

            int        settlDays     = 2;
            DayCounter fixedDayCount = swaps_[0].fixedDayCount();

            equivalentSwapIndex_ = nSwaps_ - 1;
            swapRates_[0]        = swaps_[0].fairRate();
            FixedRateBond swapBond = new FixedRateBond(settlDays,
                                                       100.0,   // faceAmount
                                                       swaps_[0].fixedSchedule(),
                                                       new List <double>()
            {
                swapRates_[0].Value
            },
                                                       fixedDayCount,
                                                       BusinessDayConvention.Following, // paymentConvention
                                                       100.0);                          // redemption

            swapBondYields_[0] = BondFunctions.yield(swapBond,
                                                     100.0, // floating leg NPV including end payment
                                                     new ActualActual(ActualActual.Convention.ISMA),
                                                     Compounding.Compounded, Frequency.Annual,
                                                     bondSettlementDate,
                                                     // accuracy, maxIterations, guess
                                                     1.0e-10, 100, swapBondYields_[0].Value);

            swapBondDurations_[0] = BondFunctions.duration(swapBond, swapBondYields_[0].Value,
                                                           new ActualActual(ActualActual.Convention.ISMA),
                                                           Compounding.Compounded, Frequency.Annual,
                                                           Duration.Type.Modified, bondSettlementDate);
            for (int i = 1; i < nSwaps_; ++i)
            {
                swapRates_[i] = swaps_[i].fairRate();
                FixedRateBond swapBond2 = new FixedRateBond(settlDays,
                                                            100.0,  // faceAmount
                                                            swaps_[i].fixedSchedule(),
                                                            new List <double>()
                {
                    swapRates_[i].Value
                },
                                                            fixedDayCount,
                                                            BusinessDayConvention.Following, // paymentConvention
                                                            100.0);                          // redemption

                swapBondYields_[i] = BondFunctions.yield(swapBond2, 100.0,                   // floating leg NPV including end payment
                                                         new ActualActual(ActualActual.Convention.ISMA),
                                                         Compounding.Compounded, Frequency.Annual,
                                                         bondSettlementDate,
                                                         // accuracy, maxIterations, guess
                                                         1.0e-10, 100, swapBondYields_[i].Value);

                swapBondDurations_[i] = BondFunctions.duration(swapBond2, swapBondYields_[i].Value,
                                                               new ActualActual(ActualActual.Convention.ISMA),
                                                               Compounding.Compounded, Frequency.Annual,
                                                               Duration.Type.Modified, bondSettlementDate);
                if (swapBondDurations_[i] > duration_)
                {
                    equivalentSwapIndex_ = i - 1;
                    break; // exit the loop
                }
            }

            return;
        }
Esempio n. 3
0
        //! Previous coupon already paid at a given date

        /*! Expected previous coupon: depending on (the bond and) the given
         *  date the coupon can be historic, deterministic or expected in a
         *  stochastic sense. When the bond settlement date is used the coupon
         *  is the last paid one.
         *
         *  The current bond settlement is used if no date is given.
         */
        public double previousCouponRate(Date settlement = null)
        {
            return(BondFunctions.previousCouponRate(this, settlement));
        }
Esempio n. 4
0
 public Date nextCashFlowDate(Date settlement = null)
 {
     return(BondFunctions.nextCashFlowDate(this, settlement));
 }
Esempio n. 5
0
 /*! Expected next coupon: depending on (the bond and) the given date
  *  the coupon can be historic, deterministic or expected in a
  *  stochastic sense. When the bond settlement date is used the coupon
  *  is the already-fixed not-yet-paid one.
  *
  *  The current bond settlement is used if no date is given.
  */
 public virtual double nextCouponRate(Date settlement = null)
 {
     return(BondFunctions.nextCouponRate(this, settlement));
 }
Esempio n. 6
0
 //! clean price given a yield and settlement date
 /*! The default bond settlement is used if no date is given. */
 public double cleanPrice(double yield, DayCounter dc, Compounding comp, Frequency freq, Date settlement = null)
 {
     return(BondFunctions.cleanPrice(this, yield, dc, comp, freq, settlement));
 }
Esempio n. 7
0
 public bool isTradable(Date d = null)
 {
     return(BondFunctions.isTradable(this, d));
 }
Esempio n. 8
0
 public Date maturityDate()
 {
     return(maturityDate_ ?? BondFunctions.maturityDate(this));
 }
Esempio n. 9
0
 public Date startDate()
 {
     return(BondFunctions.startDate(this));
 }