public static double convexity(Bond bond, InterestRate yield, Date settlementDate = null) { if (settlementDate == null) { settlementDate = bond.settlementDate(); } Utils.QL_REQUIRE(BondFunctions.isTradable(bond, settlementDate), () => "non tradable at " + settlementDate + " (maturity being " + bond.maturityDate() + ")"); return(CashFlows.convexity(bond.cashflows(), yield, false, settlementDate)); }
public static double bps(Bond bond, YieldTermStructure discountCurve, Date settlementDate = null) { if (settlementDate == null) { settlementDate = bond.settlementDate(); } Utils.QL_REQUIRE(BondFunctions.isTradable(bond, settlementDate), () => "non tradable at " + settlementDate + " (maturity being " + bond.maturityDate() + ")"); return(CashFlows.bps(bond.cashflows(), discountCurve, false, settlementDate) * 100.0 / bond.notional(settlementDate)); }
public static double accruedAmount(Bond bond, Date settlementDate = null) { if (settlementDate == null) { settlementDate = bond.settlementDate(); } Utils.QL_REQUIRE(BondFunctions.isTradable(bond, settlementDate), () => "non tradable at " + settlementDate + " (maturity being " + bond.maturityDate() + ")"); return(CashFlows.accruedAmount(bond.cashflows(), false, settlementDate) * 100.0 / bond.notional(settlementDate)); }
public static Date referencePeriodEnd(Bond bond, Date settlementDate = null) { if (settlementDate == null) { settlementDate = bond.settlementDate(); } Utils.QL_REQUIRE(BondFunctions.isTradable(bond, settlementDate), () => "non tradable at " + settlementDate + " (maturity being " + bond.maturityDate() + ")"); return(CashFlows.referencePeriodEnd(bond.cashflows(), false, settlementDate)); }
public static double dirtyPrice(Bond bond, InterestRate yield, Date settlementDate = null) { if (settlementDate == null) { settlementDate = bond.settlementDate(); } Utils.QL_REQUIRE(BondFunctions.isTradable(bond, settlementDate), () => "non tradable at " + settlementDate + " (maturity being " + bond.maturityDate() + ")"); double dirtyPrice = CashFlows.npv(bond.cashflows(), yield, false, settlementDate) * 100.0 / bond.notional(settlementDate); return(dirtyPrice); }
public static double cleanPrice(Bond bond, YieldTermStructure discount, double zSpread, DayCounter dayCounter, Compounding compounding, Frequency frequency, Date settlementDate = null) { if (settlementDate == null) { settlementDate = bond.settlementDate(); } Utils.QL_REQUIRE(BondFunctions.isTradable(bond, settlementDate), () => "non tradable at " + settlementDate + " (maturity being " + bond.maturityDate() + ")"); double dirtyPrice = CashFlows.npv(bond.cashflows(), discount, zSpread, dayCounter, compounding, frequency, false, settlementDate) * 100.0 / bond.notional(settlementDate); return(dirtyPrice - bond.accruedAmount(settlementDate)); }
public static double atmRate(Bond bond, YieldTermStructure discountCurve, Date settlementDate = null, double?cleanPrice = null) { if (settlementDate == null) { settlementDate = bond.settlementDate(); } Utils.QL_REQUIRE(BondFunctions.isTradable(bond, settlementDate), () => "non tradable at " + settlementDate + " (maturity being " + bond.maturityDate() + ")"); double?dirtyPrice = cleanPrice == null ? null : cleanPrice + bond.accruedAmount(settlementDate); double currentNotional = bond.notional(settlementDate); double?npv = dirtyPrice / 100.0 * currentNotional; return(CashFlows.atmRate(bond.cashflows(), discountCurve, false, settlementDate, settlementDate, npv)); }
public static double cleanPrice(Bond bond, YieldTermStructure discountCurve, Date settlementDate = null) { if (settlementDate == null) { settlementDate = bond.settlementDate(); } Utils.QL_REQUIRE(BondFunctions.isTradable(bond, settlementDate), () => "non tradable at " + settlementDate + " settlementDate date (maturity being " + bond.maturityDate() + ")"); double dirtyPrice = CashFlows.npv(bond.cashflows(), discountCurve, false, settlementDate) * 100.0 / bond.notional(settlementDate); return(dirtyPrice - bond.accruedAmount(settlementDate)); }
public static double yield(Bond bond, double cleanPrice, DayCounter dayCounter, Compounding compounding, Frequency frequency, Date settlementDate = null, double accuracy = 1.0e-10, int maxIterations = 100, double guess = 0.05) { if (settlementDate == null) { settlementDate = bond.settlementDate(); } Utils.QL_REQUIRE(BondFunctions.isTradable(bond, settlementDate), () => "non tradable at " + settlementDate + " (maturity being " + bond.maturityDate() + ")"); double dirtyPrice = cleanPrice + bond.accruedAmount(settlementDate); dirtyPrice /= 100.0 / bond.notional(settlementDate); return(CashFlows.yield(bond.cashflows(), dirtyPrice, dayCounter, compounding, frequency, false, settlementDate, settlementDate, accuracy, maxIterations, guess)); }