/// <summary> /// Initializes a new instance of the <see cref="PriceableCapFloorStream"/> class. /// </summary> /// <param name="logger">The logger.</param> /// <param name="cache">The cache.</param> /// <param name="nameSpace">The nameSpace</param> /// <param name="capId">The cap Id.</param> /// <param name="payerPartyReference">The payer party reference.</param> /// <param name="receiverPartyReference">The receiver party reference.</param> /// <param name="payerIsBase">The flag for whether the payerreference is the base party.</param> /// <param name="calculationPeriodDates">The caluclation period date information.</param> /// <param name="paymentDates">The payment dates of the swap leg.</param> /// <param name="resetDates">The reset dates of the swap leg.</param> /// <param name="principalExchanges">The principal Exchange type.</param> /// <param name="calculationPeriodAmount">The calculation period amount data.</param> /// <param name="stubCalculationPeriodAmount">The stub calculation information.</param> /// <param name="cashflows">The FpML cashflows for that stream.</param> /// <param name="settlementProvision">The settlement provision data.</param> /// <param name="forecastRateInterpolation">ForwardEndDate = forecastRateInterpolation ? AccrualEndDate /// : AdjustedDateHelper.ToAdjustedDate(forecastRateIndex.indexTenor.Add(AccrualStartDate), AccrualBusinessDayAdjustments);</param> /// <param name="fixingCalendar">The fixingCalendar.</param> /// <param name="paymentCalendar">The paymentCalendar.</param> public PriceableCapFloorStream ( ILogger logger , ICoreCache cache , String nameSpace , string capId , string payerPartyReference , string receiverPartyReference , bool payerIsBase , CalculationPeriodDates calculationPeriodDates , PaymentDates paymentDates , ResetDates resetDates , PrincipalExchanges principalExchanges , CalculationPeriodAmount calculationPeriodAmount , StubCalculationPeriodAmount stubCalculationPeriodAmount , Cashflows cashflows , SettlementProvision settlementProvision , bool forecastRateInterpolation , IBusinessCalendar fixingCalendar , IBusinessCalendar paymentCalendar) : base(logger, cache, nameSpace, capId, payerPartyReference, receiverPartyReference, payerIsBase, calculationPeriodDates, paymentDates, resetDates, principalExchanges, calculationPeriodAmount, stubCalculationPeriodAmount, cashflows, settlementProvision, forecastRateInterpolation, fixingCalendar, paymentCalendar) { }
public void CashflowsCalculatesPVCorrectly() { Curve discountCurve = new Curve(discountRateList); Cashflows cashflows = new Cashflows(inputCashflowsList); Assert.AreEqual(46004733, cashflows.PV(discountCurve), 1); }
private static void UpdateCashflowsWithDetailedCashflows(Cashflows cashflows, IEnumerable <DetailedCashflowRangeItem> listDetailedCashflows /*, bool fixedLeg*/) { var paymentCalculationPeriods = new List <PaymentCalculationPeriod>(); foreach (DetailedCashflowRangeItem detailedCashflowRangeItem in listDetailedCashflows) { var paymentCalculationPeriod = new PaymentCalculationPeriod(); var calculationPeriod = new CalculationPeriod(); paymentCalculationPeriod.Items = new object[] { calculationPeriod }; paymentCalculationPeriod.adjustedPaymentDate = detailedCashflowRangeItem.PaymentDate; paymentCalculationPeriod.adjustedPaymentDateSpecified = true; PaymentCalculationPeriodHelper.SetCalculationPeriodStartDate(paymentCalculationPeriod, detailedCashflowRangeItem.StartDate); PaymentCalculationPeriodHelper.SetCalculationPeriodEndDate(paymentCalculationPeriod, detailedCashflowRangeItem.EndDate); // Update notional amount // PaymentCalculationPeriodHelper.SetNotionalAmount(paymentCalculationPeriod, (decimal)detailedCashflowRangeItem.NotionalAmount); if (detailedCashflowRangeItem.CouponType == "Fixed") { //CalculationPeriod calculationPeriod = PaymentCalculationPeriodHelper.GetCalculationPeriods(paymentCalculationPeriod)[0]; //if (XsdClassesFieldResolver.CalculationPeriod_HasFixedRate(calculationPeriod)) //{ // Fixed->Fixed // //PaymentCalculationPeriodHelper.SetRate(paymentCalculationPeriod, (decimal)detailedCashflowRangeItem.Rate); XsdClassesFieldResolver.SetCalculationPeriodFixedRate(calculationPeriod, (decimal)detailedCashflowRangeItem.Rate); //} //else if (XsdClassesFieldResolver.CalculationPeriod_HasFloatingRateDefinition(calculationPeriod)) // { // // Float->Fixed // // // PaymentCalculationPeriodHelper.ReplaceFloatingRateWithFixedRate(paymentCalculationPeriod, (decimal)detailedCashflowRangeItem.Rate); // } // else // { // throw new NotImplementedException(); // } } else if (detailedCashflowRangeItem.CouponType == "Float") { // Create floating rate definiton... // var floatingRateDefinition = new FloatingRateDefinition(); //XsdClassesFieldResolver.CalculationPeriod_SetFloatingRateDefinition(calculationPeriod, floatingRateDefinition); calculationPeriod.Item1 = floatingRateDefinition; // After the spread is reset - we need to update calculated rate. // PaymentCalculationPeriodHelper.SetSpread(paymentCalculationPeriod, (decimal)detailedCashflowRangeItem.Spread); } else { string message = $"Unsupported coupon type '{detailedCashflowRangeItem.CouponType}"; throw new System.Exception(message); } paymentCalculationPeriods.Add(paymentCalculationPeriod); } cashflows.cashflowsMatchParameters = false; cashflows.paymentCalculationPeriod = paymentCalculationPeriods.ToArray(); }
public void CashflowsPVMethodRaisesErrorOnCurveDimensionMismatch() { discountRateList.RemoveAt(discountRateList.Count - 1); Curve discountCurve = new Curve(discountRateList); Cashflows cashflows = new Cashflows(inputCashflowsList); cashflows.PV(discountCurve); }
public void CashflowsInflateMethodRaisesErrorOnCurveDimensionMismatch() { inflationRateList.RemoveAt(inflationRateList.Count - 1); Curve inflationCurve = new Curve(inflationRateList); Cashflows cashflows = new Cashflows(inputCashflowsList); cashflows.Inflate(inflationCurve, 12); }
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); }
public void CashflowsCalculatesPVOfInflatedCashflowsCorrectly() { Curve discountCurve = new Curve("../../../TestData/DiscountRate.txt"); Curve inflationCurve = new Curve("../../../TestData/InflationRate.txt"); Cashflows cashflows = new Cashflows("../../../TestData/Cashflows.txt"); Cashflows inflatedCashflows = cashflows.Inflate(inflationCurve, 12); Assert.AreEqual(920913970, inflatedCashflows.PV(discountCurve), 1); }
public static Cashflows Create(List <PaymentCalculationPeriod> paymentCalculationPeriods, bool cashflowsMatchParameters) { var cashflows = new Cashflows { cashflowsMatchParameters = cashflowsMatchParameters, paymentCalculationPeriod = paymentCalculationPeriods.ToArray() }; return(cashflows); }
public static InterestRateStream GetCashflowsSchedule(SwapLegParametersRange legParametersRange) { InterestRateStream stream = InterestRateStreamParametricDefinitionGenerator.GenerateStreamDefinition(legParametersRange); Cashflows cashflows = FixedAndFloatingRateStreamCashflowGenerator.GetCashflows(stream); stream.cashflows = cashflows; return(stream); }
/// <summary> /// Builds the cashflows. /// </summary> /// <returns></returns> public Cashflows Build() { //TODO what about the cash flow match parameter? var cashflows = new Cashflows { paymentCalculationPeriod = Coupons.Select(priceableCoupon => priceableCoupon.Build()).ToArray() }; return(cashflows); }
public static Money GetPresentValue(Cashflows cashflows) { List <Money> presentValueList = new List <Money>(); foreach (PaymentCalculationPeriod period in cashflows.paymentCalculationPeriod) { presentValueList.Add(period.presentValueAmount); } return(MoneyHelper.Sum(presentValueList)); }
public static Money GetForecastValue(Cashflows cashflows) { List <Money> forecastValueList = new List <Money>(); foreach (PaymentCalculationPeriod period in cashflows.paymentCalculationPeriod) { forecastValueList.Add(period.forecastPaymentAmount); } return(MoneyHelper.Sum(forecastValueList)); }
public void CashflowsConstructorCalledWithListReturnsCashflowsOnCall() { Curve discountCurve = new Curve(discountRateList); Cashflows cashflows = new Cashflows(inputCashflowsList); List <double> baseCashflows = cashflows.BaseCashflows; Assert.AreEqual(5483309, baseCashflows[0]); Assert.AreEqual(8258105, baseCashflows[1]); Assert.AreEqual(9996353, baseCashflows[2]); Assert.AreEqual(11190735, baseCashflows[3]); Assert.AreEqual(12165875, baseCashflows[4]); }
public void CashflowsInflatesCashflowsCorrectly() { Curve inflationCurve = new Curve(inflationRateList); Cashflows cashflows = new Cashflows(inputCashflowsList); Cashflows inflatedCashflows = cashflows.Inflate(inflationCurve, 12); double inflatedCashflowSum = 0; foreach (double inflatedCashflow in inflatedCashflows.BaseCashflows) { inflatedCashflowSum += inflatedCashflow; } Assert.AreEqual(50458603, inflatedCashflowSum, 1); }
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); }
TimedAnswer <int> getSecondAnwser(Test <Cashflows> test) { var timer = new Stopwatch(); Cashflows cashflows = test.GetInput(); timer.Start(); var answer = Question2.Answer(cashflows.cashFlowIn, cashflows.cashFlowOut); timer.Stop(); var timeTaken = ((double)timer.ElapsedTicks / Stopwatch.Frequency) * 1000000000; return(new TimedAnswer <int>(answer, timeTaken)); }
public async Task TestQ2() { var travisUUID = Environment.GetEnvironmentVariable("travistestidentifier"); if (travisUUID == null) { travisUUID = ""; } Console.WriteLine("Testing Q2"); string responseBody = await client.GetStringAsync(baseUrl + "tests/run/2/" + travisUUID); List<TestCase> testCases = JsonConvert.DeserializeObject<List<TestCase>>(responseBody); List<Answer> answers = new List<Answer>(); foreach (var test in testCases) { try { Answer answer = new Answer(); Cashflows input = JsonConvert.DeserializeObject<Cashflows>(test.input); var cancellationToken = new CancellationTokenSource(); cancellationToken.CancelAfter(1000); await Task.Run(() => answer = getSecondAnswer(input, test), cancellationToken.Token); answers.Add(answer); } catch (TaskCanceledException _) { Console.WriteLine("A test in Question 2 has timed out. Tests must complete within one second."); answers.Add(new Answer() { questionNumber = 2, testNumber = test.testNumber, correct = "TIMED_OUT", speed = -1 }); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } if (travisUUID.Length > 0) { Console.WriteLine("Submitting Q2"); string ans = JsonConvert.SerializeObject(answers); await client.PostAsync(baseUrl + "answer/contestant/" + travisUUID + "/2", new StringContent(ans, Encoding.UTF8, "application/json")); } }
/// <summary> /// Builds the cashflows. /// </summary> /// <returns></returns> protected Cashflows BuildCashflows() { //TODO what about the cash flow match parameter? var cashflows = new Cashflows { paymentCalculationPeriod = Coupons.Select(priceableCoupon => priceableCoupon.Build()).ToArray() }; if (Exchanges != null) { var principalExchanges = Exchanges.Select(principalExchange => principalExchange.Build()).ToArray(); if (principalExchanges.Any()) { cashflows.principalExchange = principalExchanges; } } return(cashflows); }
Answer getSecondAnswer(Cashflows input, TestCase test) { var timer = new Stopwatch(); timer.Start(); var answer = Question2.Answer(input.cashFlowIn, input.cashFlowOut); timer.Stop(); var timeTaken = ((double)timer.ElapsedTicks / Stopwatch.Frequency) * 1000000000; return new Answer() { questionNumber = 2, testNumber = test.testNumber, correct = answer == test.output ? "CORRECT" : "INCORRECT", speed = timeTaken }; }
private void PopulateCashflowsTask(List <Cashflow> data) { int prevId = 0; if (SelectedCashflow != null) { prevId = SelectedCashflow.CashflowId; } Cashflows.Clear(); SelectedCashflow = null; if (data != null) { data.ForEach(d => Cashflows.Add(new CashflowItemViewModel(d))); if (Cashflows.Count > 0) { SelectedCashflow = prevId == 0 ? Cashflows[0] : Cashflows.FirstOrDefault(c => c.CashflowId == prevId); NotifyPropertyChanged(() => this.SelectedCashflow); } } }
public static Money GetPresentValue(Cashflows cashflows) { var presentValueList = cashflows.paymentCalculationPeriod.Select(period => period.presentValueAmount).ToList(); return(MoneyHelper.Sum(presentValueList)); }
/// <summary> /// Initializes a new instance of the <see cref="PriceableInterestRateStream"/> class. /// </summary> /// <param name="logger">The logger.</param> /// <param name="cache">The cache.</param> /// <param name="nameSpace">The client namesspace.</param> /// <param name="swapId">The swap Id.</param> /// <param name="payerPartyReference">The payer party reference.</param> /// <param name="receiverPartyReference">The receiver party reference.</param> /// <param name="payerIsBase">The flag for whether the payerreference is the base party.</param> /// <param name="calculationPeriodDates">The caluclation period date information.</param> /// <param name="paymentDates">The payment dates of the swap leg.</param> /// <param name="resetDates">The reset dates of the swap leg.</param> /// <param name="principalExchanges">The principal Exchange type.</param> /// <param name="calculationPeriodAmount">The calculation period amount data.</param> /// <param name="stubCalculationPeriodAmount">The stub calculation information.</param> /// <param name="cashflows">The FpML cashflows for that stream.</param> /// <param name="settlementProvision">The settlement provision data.</param> /// <param name="forecastRateInterpolation">ForwardEndDate = forecastRateInterpolation ? AccrualEndDate /// : AdjustedDateHelper.ToAdjustedDate(forecastRateIndex.indexTenor.Add(AccrualStartDate), AccrualBusinessDayAdjustments);</param> /// <param name="fixingCalendar">The fixingCalendar.</param> /// <param name="paymentCalendar">The paymentCalendar.</param> public PriceableInterestRateStream ( ILogger logger , ICoreCache cache , String nameSpace , string swapId , string payerPartyReference , string receiverPartyReference , bool payerIsBase , CalculationPeriodDates calculationPeriodDates , PaymentDates paymentDates , ResetDates resetDates , PrincipalExchanges principalExchanges , CalculationPeriodAmount calculationPeriodAmount , StubCalculationPeriodAmount stubCalculationPeriodAmount , Cashflows cashflows , SettlementProvision settlementProvision , bool forecastRateInterpolation , IBusinessCalendar fixingCalendar , IBusinessCalendar paymentCalendar) { Multiplier = 1.0m; Payer = payerPartyReference; Receiver = receiverPartyReference; PayerIsBaseParty = payerIsBase; CalculationPeriodDates = calculationPeriodDates; PaymentDates = paymentDates; PaymentCurrencies = new List <string>(); ResetDates = resetDates; PrincipalExchanges = principalExchanges; CalculationPeriodAmount = calculationPeriodAmount; AnalyticsModel = new StructuredStreamAnalytic(); Calculation = (Calculation)CalculationPeriodAmount.Item; if (Calculation.Items?[0] is Schedule strikeSchedule) { Strike = strikeSchedule.initialValue;//Only picks up the first fixed rate for the swaption calculation. } StubCalculationPeriodAmount = stubCalculationPeriodAmount; Cashflows = cashflows; CouponStreamType = CouponTypeFromCalculation(Calculation); Id = BuildId(swapId, CouponStreamType); ForecastRateInterpolation = forecastRateInterpolation; var isThereDiscounting = XsdClassesFieldResolver.CalculationHasDiscounting(Calculation); if (isThereDiscounting) { IsDiscounted = true; //TODO need to include rate logic for the correct solved answers. What about reset cashflows?? } //Get the currency. var currency = XsdClassesFieldResolver.CalculationGetNotionalSchedule(Calculation); Currency = currency.notionalStepSchedule.currency; if (!PaymentCurrencies.Contains(Currency.Value)) { PaymentCurrencies.Add(Currency.Value); } //The calendars if (paymentCalendar == null) { paymentCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, PaymentDates.paymentDatesAdjustments.businessCenters, nameSpace); } SettlementProvision = settlementProvision; //Set the default discount curve name. DiscountCurveName = CurveNameHelpers.GetDiscountCurveName(Currency.Value, true); //Set the forecast curve name.//TODO extend this to the other types. if (CouponStreamType != CouponStreamType.GenericFixedRate) { if (fixingCalendar == null) { fixingCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, ResetDates.resetDatesAdjustments.businessCenters, nameSpace); } ForecastCurveName = null; if (Calculation.Items != null) { var floatingRateCalculation = Calculation.Items; var floatingRateIndex = (FloatingRateCalculation)floatingRateCalculation[0]; ForecastCurveName = CurveNameHelpers.GetForecastCurveName(floatingRateIndex); } } //Build the coupons and principal exchanges. if (GetCashflowPaymentCalculationPeriods() != null) { Coupons = PriceableInstrumentsFactory.CreatePriceableCoupons(PayerIsBaseParty, GetCashflowPaymentCalculationPeriods(), Calculation, ForecastRateInterpolation, fixingCalendar, paymentCalendar);//TODO add the stubcalculation. UpdateCouponIds(); } if (GetCashflowPrincipalExchanges() != null) { var exchanges = GetCashflowPrincipalExchanges(); Exchanges = PriceableInstrumentsFactory.CreatePriceablePrincipalExchanges(PayerIsBaseParty, exchanges, Currency.Value, paymentCalendar); UpdateExchangeIds(); } RiskMaturityDate = LastDate(); logger.LogInfo("Stream built"); }
public void CashflowConstructorCalledWithEmptyListThrowsError() { // TODO : assert form of error message when file is empty Cashflows cashflows = new Cashflows(new List <double>()); }
private static Cashflows UpdateCashflowsWithDetailedCashflows(IEnumerable <InputCashflowRangeItem> listDetailedCashflows /*, bool fixedLeg*/) { var cashflows = new Cashflows(); var paymentCalculationPeriods = new List <PaymentCalculationPeriod>(); foreach (var detailedCashflowRangeItem in listDetailedCashflows) { var paymentCalculationPeriod = new PaymentCalculationPeriod(); var calculationPeriod = new CalculationPeriod(); paymentCalculationPeriod.Items = new object[] { calculationPeriod }; paymentCalculationPeriod.adjustedPaymentDate = detailedCashflowRangeItem.PaymentDate; paymentCalculationPeriod.adjustedPaymentDateSpecified = true; PaymentCalculationPeriodHelper.SetCalculationPeriodStartDate(paymentCalculationPeriod, detailedCashflowRangeItem.StartDate); PaymentCalculationPeriodHelper.SetCalculationPeriodEndDate(paymentCalculationPeriod, detailedCashflowRangeItem.EndDate); // Update notional amount // PaymentCalculationPeriodHelper.SetNotionalAmount(paymentCalculationPeriod, (decimal)detailedCashflowRangeItem.NotionalAmount); switch (detailedCashflowRangeItem.CouponType.ToLower()) { case "cap": { var floatingRateDefinition = new FloatingRateDefinition(); calculationPeriod.Item1 = floatingRateDefinition; // After the spread is reset - we need to update calculated rate. // PaymentCalculationPeriodHelper.SetSpread(paymentCalculationPeriod, (decimal)detailedCashflowRangeItem.Spread); floatingRateDefinition.capRate = new[] { new Strike() }; floatingRateDefinition.capRate[0].strikeRate = (decimal)detailedCashflowRangeItem.StrikeRate; //tODO There is no fixing date. { var rateObservation = new RateObservation { adjustedFixingDate = detailedCashflowRangeItem.FixingDate, adjustedFixingDateSpecified = true }; floatingRateDefinition.rateObservation = new[] { rateObservation }; } break; } case "floor": { var floatingRateDefinition = new FloatingRateDefinition(); //XsdClassesFieldResolver.CalculationPeriod_SetFloatingRateDefinition(calculationPeriod, floatingRateDefinition); calculationPeriod.Item1 = floatingRateDefinition; // After the spread is reset - we need to update calculated rate. // PaymentCalculationPeriodHelper.SetSpread(paymentCalculationPeriod, (decimal)detailedCashflowRangeItem.Spread); floatingRateDefinition.capRate = new[] { new Strike() }; floatingRateDefinition.capRate[0].strikeRate = (decimal)detailedCashflowRangeItem.StrikeRate; { var rateObservation = new RateObservation { adjustedFixingDate = detailedCashflowRangeItem.FixingDate, adjustedFixingDateSpecified = true }; floatingRateDefinition.rateObservation = new[] { rateObservation }; } break; } default: { string message = String.Format("Specified coupon type : '{0}' is not supported. Please use one of these: 'cap, floor'", detailedCashflowRangeItem.CouponType.ToLower()); throw new NotSupportedException(message); } } paymentCalculationPeriods.Add(paymentCalculationPeriod); } cashflows.cashflowsMatchParameters = true; cashflows.paymentCalculationPeriod = paymentCalculationPeriods.ToArray(); return(cashflows); }
// private static void UpdateCashflowsWithDetailedCashflows(Cashflows cashflows, List<DetailedCashflowRangeItem> listDetailedCashflows, bool fixedLeg) // { // for (int i = 0; i < cashflows.paymentCalculationPeriod.Length; ++i) // { // PaymentCalculationPeriod paymentCalculationPeriod = cashflows.paymentCalculationPeriod[i]; // DetailedCashflowRangeItem detailedCashflowRangeItem = listDetailedCashflows[i]; // // paymentCalculationPeriod.adjustedPaymentDate = detailedCashflowRangeItem.PaymentDate; // PaymentCalculationPeriodHelper.SetCalculationPeriodStartDate(paymentCalculationPeriod, detailedCashflowRangeItem.StartDate); // PaymentCalculationPeriodHelper.SetCalculationPeriodEndDate(paymentCalculationPeriod, detailedCashflowRangeItem.EndDate); // //PaymentCalculationPeriodHelper.GetNumberOfDays(paymentCalculationPeriod, ); // // // Update notional amount // // // PaymentCalculationPeriodHelper.SetNotionalAmount(paymentCalculationPeriod, (decimal)detailedCashflowRangeItem.NotionalAmount); // // if (detailedCashflowRangeItem.CouponType == "Fixed") // { // CalculationPeriod calculationPeriod = PaymentCalculationPeriodHelper.GetCalculationPeriods(paymentCalculationPeriod)[0]; // // if (XsdClassesFieldResolver.CalculationPeriod_HasFixedRate(calculationPeriod)) // { // // Fixed->Fixed // // // PaymentCalculationPeriodHelper.SetRate(paymentCalculationPeriod, (decimal)detailedCashflowRangeItem.Rate); // } // else if (XsdClassesFieldResolver.CalculationPeriod_HasFloatingRateDefinition(calculationPeriod)) // { // // Float->Fixed // // // PaymentCalculationPeriodHelper.ReplaceFloatingRateWithFixedRate(paymentCalculationPeriod, (decimal)detailedCashflowRangeItem.Rate); // } // else // { // throw new NotImplementedException(); // } // // } // else if (detailedCashflowRangeItem.CouponType == "Float") // { // // After the spread is reset - we need to update calculated rate. // // // PaymentCalculationPeriodHelper.SetSpread(paymentCalculationPeriod, (decimal)detailedCashflowRangeItem.Spread); // } // else // { // throw new NotImplementedException(); // } // } // } private static void CreatePrincipalExchangesFromListOfRanges(Cashflows cashflows, IEnumerable <PrincipalExchangeCashflowRangeItem> principalExchangeRangeList) { cashflows.principalExchange = (from item in principalExchangeRangeList where 0 != item.Amount select PrincipalExchangeHelper.Create(item.PaymentDate, (decimal)item.Amount)).ToArray(); }
private static void CreatePrincipalExchangesFromListOfRanges( Cashflows cashflows, IEnumerable <InputPrincipalExchangeCashflowRangeItem> principalExchangeRangeList) { cashflows.principalExchange = principalExchangeRangeList.Select(item => PrincipalExchangeHelper.Create(item.PaymentDate, (decimal)item.Amount)).ToArray(); }
public static Money GetForecastValue(Cashflows cashflows) { var forecastValueList = cashflows.paymentCalculationPeriod.Select(period => period.forecastPaymentAmount).ToList(); return(MoneyHelper.Sum(forecastValueList)); }