Esempio n. 1
0
 public List <BillSwapPricerCashflowRow> PopulatePurchaseCosts(List <BillSwapPricerCashflowRow> input, IDayCounter dayCounter, RateCurve rateCurve)
 {
     for (int i = 0; i < input.Count - 1; ++i)
     {
         BillSwapPricerCashflowRow currentItem = input[i];
         BillSwapPricerCashflowRow nextItem    = input[i + 1];
         double yearFraction = dayCounter.YearFraction(currentItem.DateTime, nextItem.DateTime);
         double purchaseCost = currentItem.MaturityValue / (1.0 + currentItem.ForwardRate * yearFraction);
         currentItem.PurchaseCost = purchaseCost;
     }
     input[0].MaturityValue = 0;//no maturity value inflow at the settlement day.
     return(input);
 }
Esempio n. 2
0
        public double GetSimpleYield(List <BillSwapPricerCashflowRow> input, IDayCounter dayCounter, RateCurve rateCurve)
        {
            double yield = 0;

            for (int i = 0; i < input.Count - 1; ++i)
            {
                BillSwapPricerCashflowRow currentItem = input[i];
                BillSwapPricerCashflowRow nextItem    = input[i + 1];
                double yearFraction = dayCounter.YearFraction(currentItem.DateTime, nextItem.DateTime);
                if (yield == 0)
                {
                    yield = (1.0 + currentItem.ForwardRate * yearFraction);
                }
                else
                {
                    yield *= (1.0 + currentItem.ForwardRate * yearFraction);
                }
            }
            return(yield - 1.0);
        }
Esempio n. 3
0
        public List <BillSwapPricerCashflowRow> PopulateForwardRates(List <BillSwapPricerDateNotional> input, IDayCounter dayCounter, RateCurve rateCurve)
        {
            var result = new List <BillSwapPricerCashflowRow>();

            for (int i = 0; i < input.Count; ++i)
            {
                BillSwapPricerDateNotional currentItem = input[i];
                double forwardRate = 0;
                if (i != input.Count - 1)
                {
                    BillSwapPricerDateNotional nextItem = input[i + 1];
                    forwardRate = rateCurve.GetForwardRate(currentItem.DateTime, nextItem.DateTime, dayCounter);
                }
                var resultItem = new BillSwapPricerCashflowRow
                {
                    DateTime      = currentItem.DateTime,
                    MaturityValue = currentItem.MaturityValue,
                    ForwardRate   = forwardRate
                };

                result.Add(resultItem);
            }
            return(result);
        }