public void TestGetCapPremiumAUD_6M100M_5YExpiry05Vol20Pct() { var valuationDate = new DateTime(1994, 12, 14); var curveId = BuildAndCacheRateCurve(valuationDate); CapFloorLegParametersRange_Old capLeg = GetCapFloorInputParameters(valuationDate, valuationDate.AddMonths(6), valuationDate.AddYears(5), CapFloorType.Cap, "Standard", curveId, curveId); InterestRateStream floatStream = InterestRateStreamParametricDefinitionGenerator.GenerateStreamDefinition(capLeg); floatStream.cashflows = FixedAndFloatingRateStreamCashflowGenerator.GetCashflows(floatStream, FixingCalendar, PaymentCalendar); double sumOfCapletPremiums = 0; var rateCurve = (RateCurve)Engine.GetCurve(curveId, false); foreach (PaymentCalculationPeriod paymentCalculationPeriod in floatStream.cashflows.paymentCalculationPeriod) { DateTime startDate = PaymentCalculationPeriodHelper.GetCalculationPeriodStartDate(paymentCalculationPeriod); DateTime endDate = PaymentCalculationPeriodHelper.GetCalculationPeriodEndDate(paymentCalculationPeriod); double accrualFactor = (endDate - startDate).TotalDays / 365.0; var discountFactor = (double)paymentCalculationPeriod.discountFactor; var rate = (double)PaymentCalculationPeriodHelper.GetRate(paymentCalculationPeriod); double rate2 = rateCurve.GetForwardRate(startDate, endDate, "ACT/365.FIXED"); double diff = rate - rate2; Debug.Print("Diff in forward rate: {0}", diff); var strikeRate = (double)capLeg.StrikeRate; //fixed - replace with a schedule const double volatility = 0.2; //fixed - replace with a schedule double timeToExpiry = (startDate - valuationDate).TotalDays / 365.0; double optionValue = accrualFactor * BlackModel.GetSwaptionValue(rate, strikeRate, volatility, timeToExpiry) * discountFactor; Debug.Print("Expiry:\t{0},\tPremium:\t{1}'", timeToExpiry, optionValue); sumOfCapletPremiums += optionValue; } Debug.Print("Premium : '{0}'", sumOfCapletPremiums * (double)capLeg.NotionalAmount); }
private static InterestRateStream GetCashflowsSchedule(IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, CapFloorLegParametersRange legParametersRange) { InterestRateStream stream = InterestRateStreamParametricDefinitionGenerator.GenerateStreamDefinition(legParametersRange); Cashflows cashflows = FixedAndFloatingRateStreamCashflowGenerator.GetCashflows(stream, fixingCalendar, paymentCalendar); stream.cashflows = cashflows; return(stream); }
protected static Cashflows BuildCashflow(InterestRateStream stream, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar) { var cashflows = stream.cashflows; if (stream.cashflows == null || stream.cashflows.cashflowsMatchParameters == false) { cashflows = FixedAndFloatingRateStreamCashflowGenerator.GetCashflows(stream, fixingCalendar, paymentCalendar); } return(cashflows); }
public static InterestRateStream GetCashflowsSchedule(SwapLegParametersRange legParametersRange) { InterestRateStream stream = InterestRateStreamParametricDefinitionGenerator.GenerateStreamDefinition(legParametersRange); Cashflows cashflows = FixedAndFloatingRateStreamCashflowGenerator.GetCashflows(stream); stream.cashflows = cashflows; return(stream); }
private static InterestRateStream GetCashflowsScheduleWithNotionalSchedule( IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, SwapLegParametersRange_Old legParametersRange, NonNegativeAmountSchedule notionalSchedule) { InterestRateStream stream = InterestRateStreamParametricDefinitionGenerator.GenerateStreamDefinition(legParametersRange); InterestRateStreamParametricDefinitionGenerator.SetNotionalSchedule(stream, notionalSchedule); Cashflows cashflows = FixedAndFloatingRateStreamCashflowGenerator.GetCashflows(stream, fixingCalendar, paymentCalendar); stream.cashflows = cashflows; return(stream); }