Exemplo n.º 1
0
        public static double zSpread(Bond bond, double cleanPrice, YieldTermStructure discount, DayCounter dayCounter, Compounding compounding,
                                     Frequency frequency, Date settlementDate = null, double accuracy = 1.0e-10, int maxIterations = 100,
                                     double guess = 0.0)
        {
            if (settlementDate == null)
            {
                settlementDate = bond.settlementDate();
            }

            Utils.QL_REQUIRE(BondFunctions.isTradable(bond, settlementDate), () =>
                             "non tradable at " + settlementDate +
                             " (maturity being " + bond.maturityDate() + ")",
                             QLNetExceptionEnum.NotTradableException);

            double dirtyPrice = cleanPrice + bond.accruedAmount(settlementDate);

            dirtyPrice /= 100.0 / bond.notional(settlementDate);

            return(CashFlows.zSpread(bond.cashflows(),
                                     discount,
                                     dirtyPrice,
                                     dayCounter, compounding, frequency,
                                     false, settlementDate, settlementDate,
                                     accuracy, maxIterations, guess));
        }