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 netxItem = input[i + 1]; double yearFraction = dayCounter.YearFraction(currentItem.DateTime, netxItem.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); }
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 netxItem = input[i + 1]; double yearFraction = dayCounter.YearFraction(currentItem.DateTime, netxItem.DateTime); if (yield == 0) { yield = (1.0 + currentItem.ForwardRate * yearFraction); } else { yield *= (1.0 + currentItem.ForwardRate * yearFraction); } } return(yield - 1.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 netxItem = input[i + 1]; forwardRate = rateCurve.GetForwardRate(currentItem.DateTime, netxItem.DateTime, dayCounter); } var resultItem = new BillSwapPricerCashflowRow { DateTime = currentItem.DateTime, MaturityValue = currentItem.MaturityValue, ForwardRate = forwardRate }; result.Add(resultItem); } return(result); }