Example #1
0
        internal static List <BillSwapPricer2CashflowItem> GenerateFixedCashlowsFromAmortResultItems(List <AmortResultItem> amortResultItems, IDayCounter dayCounter, double fixedRate)
        {
            var result = new List <BillSwapPricer2CashflowItem>();

            for (int i = 0; i < amortResultItems.Count - 1; ++i)
            {
                var billSwapPricer2CashflowItem = new BillSwapPricer2CashflowItem
                {
                    StartDate = amortResultItems[i].RollDate,
                    EndDate   = amortResultItems[i + 1].RollDate,
                    Notional  = amortResultItems[i].OutstandingValue
                };
                billSwapPricer2CashflowItem.AccrualPeriod      = dayCounter.YearFraction(billSwapPricer2CashflowItem.StartDate, billSwapPricer2CashflowItem.EndDate);
                billSwapPricer2CashflowItem.ImpliedForwardRate = fixedRate;
                billSwapPricer2CashflowItem.DiscountedValue    = billSwapPricer2CashflowItem.Notional /
                                                                 (1 + billSwapPricer2CashflowItem.ImpliedForwardRate * billSwapPricer2CashflowItem.AccrualPeriod);

                result.Add(billSwapPricer2CashflowItem);
            }
            return(result);
        }
Example #2
0
        internal static List <BillSwapPricer2CashflowItem> GenerateFloatingCashlowsFromAmortResultItems(List <AmortResultItem> amortResultItems, IDayCounter dayCounter, RateCurve curve, double floatRateMargin)
        {
            var result = new List <BillSwapPricer2CashflowItem>();

            for (int i = 0; i < amortResultItems.Count - 1; ++i)
            {
                var billSwapPricer2CashflowItem = new BillSwapPricer2CashflowItem
                {
                    StartDate = amortResultItems[i].RollDate,
                    EndDate   = amortResultItems[i + 1].RollDate,
                    Notional  = amortResultItems[i].OutstandingValue
                };
                billSwapPricer2CashflowItem.AccrualPeriod = dayCounter.YearFraction(billSwapPricer2CashflowItem.StartDate, billSwapPricer2CashflowItem.EndDate);
                double startOfPeriodDiscount = curve.GetDiscountFactor(billSwapPricer2CashflowItem.StartDate);
                double endOfPeriodDiscount   = curve.GetDiscountFactor(billSwapPricer2CashflowItem.EndDate);
                double forecastContinouslyCompoundingRate = floatRateMargin + ((startOfPeriodDiscount / endOfPeriodDiscount - 1.0) / billSwapPricer2CashflowItem.AccrualPeriod);
                billSwapPricer2CashflowItem.ImpliedForwardRate = forecastContinouslyCompoundingRate;
                billSwapPricer2CashflowItem.DiscountedValue    = billSwapPricer2CashflowItem.Notional /
                                                                 (1 + billSwapPricer2CashflowItem.ImpliedForwardRate * billSwapPricer2CashflowItem.AccrualPeriod);
                result.Add(billSwapPricer2CashflowItem);
            }
            return(result);
        }