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 CapFloor value() { VanillaSwap swap = makeVanillaSwap_; List <CashFlow> leg = swap.floatingLeg(); if (firstCapletExcluded_) { leg.RemoveAt(0); } // only leaves the last coupon if (asOptionlet_ && leg.Count > 1) { leg.RemoveRange(0, leg.Count - 2); // Sun Studio needs an lvalue } List <double> strikeVector; if (strike_ == null) { // temporary patch... // should be fixed for every CapFloor::Engine BlackCapFloorEngine temp = engine_ as BlackCapFloorEngine; Utils.QL_REQUIRE(temp != null, () => "cannot calculate ATM without a BlackCapFloorEngine"); Handle <YieldTermStructure> discountCurve = temp.termStructure(); strikeVector = new InitializedList <double>(1, CashFlows.atmRate(leg, discountCurve, false, discountCurve.link.referenceDate())); //strikeVector[0] = CashFlows.atmRate(leg,discountCurve,false,discountCurve.link.referenceDate()); } else { strikeVector = new InitializedList <double>(1, strike_.Value); } CapFloor capFloor = new CapFloor(capFloorType_, leg, strikeVector); capFloor.setPricingEngine(engine_); return(capFloor); }
public virtual double atmRate(YieldTermStructure discountCurve) { return(CashFlows.atmRate(yoyLeg_, discountCurve, false, discountCurve.referenceDate())); }
public double atmRate(YieldTermStructure discountCurve) { return(CashFlows.atmRate(floatingLeg_, discountCurve)); }