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
        public static double GetPremiumImpl(
            ILogger logger,
            ICoreCache cache,
            String nameSpace,
            SwapLegParametersRange payLegParametersRange,
            SwapLegParametersRange receiveLegParametersRange,
            SwaptionParametersRange swaptionTermsRange,
            ValuationRange valuationRange)
        {
            InterestRateStream payStream     = null;
            InterestRateStream receiveStream = null;

            UpdateCashflowsWithAmounts(logger, cache, nameSpace, payStream, payLegParametersRange, valuationRange);
            UpdateCashflowsWithAmounts(logger, cache, nameSpace, receiveStream, receiveLegParametersRange, valuationRange);
            Money  fv         = CashflowsHelper.GetForecastValue(payStream.cashflows);
            Money  pv         = CashflowsHelper.GetPresentValue(payStream.cashflows);
            double tillExpiry = (swaptionTermsRange.ExpirationDate - valuationRange.ValuationDate).TotalDays / 365.0;
            //Debug.Print("Future value :{0}", fv.amount);
            //Debug.Print("Present value :{0}", pv.amount);
            // get swaption price
            //
            double pricePerDollar = BlackModel.GetSwaptionValue((double)payLegParametersRange.CouponOrLastResetRate, (double)swaptionTermsRange.StrikeRate, (double)swaptionTermsRange.Volatility, tillExpiry);
            double premium        = System.Math.Abs((double)payLegParametersRange.NotionalAmount * pricePerDollar);

            return(premium);
        }