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);
        }
示例#2
0
        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);
        }
示例#4
0
        public static InterestRateStream GetCashflowsSchedule(SwapLegParametersRange legParametersRange)
        {
            InterestRateStream stream = InterestRateStreamParametricDefinitionGenerator.GenerateStreamDefinition(legParametersRange);

            Cashflows cashflows = FixedAndFloatingRateStreamCashflowGenerator.GetCashflows(stream);

            stream.cashflows = cashflows;

            return(stream);
        }
示例#5
0
        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);
        }
示例#6
0
        private static void UpdateCashflowsWithAmounts(ILogger logger, ICoreCache cache,
                                                       String nameSpace, InterestRateStream stream,
                                                       CapFloorLegParametersRange_Old legParametersRange, ValuationRange valuationRange)
        {
            //  Get a forecast curve
            //
            IRateCurve forecastCurve = null;

            if (!String.IsNullOrEmpty(legParametersRange.ForecastCurve) && legParametersRange.ForecastCurve.ToLower() != "none")
            {
                forecastCurve = CurveLoader.LoadInterestRateCurve(logger, cache, nameSpace, legParametersRange.ForecastCurve);
            }
            //  Get a discount curve
            //
            var discountCurve = CurveLoader.LoadInterestRateCurve(logger, cache, nameSpace, legParametersRange.DiscountCurve);

            FixedAndFloatingRateStreamCashflowGenerator.UpdateCashflowsAmounts(stream, forecastCurve, discountCurve, valuationRange.ValuationDate);
        }