public static void UpdatePaymentsAmounts(IBusinessCalendar paymentCalendar, CapFloor capFloor, CapFloorLegParametersRange capFloorLeg, IRateCurve discountCurve, DateTime valuationDate) { foreach (Payment payment in capFloor.additionalPayment) { var date = AdjustedDateHelper.GetAdjustedDate(paymentCalendar, payment.paymentDate); if (date != null) { payment.discountFactor = (decimal)discountCurve.GetDiscountFactor(valuationDate, (DateTime)date); payment.discountFactorSpecified = true; payment.presentValueAmount = MoneyHelper.Mul(payment.paymentAmount, payment.discountFactor); } } }
public static void UpdatePaymentsAmounts(ILogger logger, ICoreCache cache, String nameSpace, Swap swap, SwapLegParametersRange leg1Parameters, SwapLegParametersRange leg2Parameters, IRateCurve leg1DiscountCurve, IRateCurve leg2DiscountCurve, DateTime valuationDate, IBusinessCalendar paymentCalendar) { foreach (Payment payment in swap.additionalPayment) { // choose correct discount curve // IRateCurve discountCurve; if (payment.payerPartyReference.href == leg1Parameters.Payer) { discountCurve = leg1DiscountCurve; } else if (payment.payerPartyReference.href == leg2Parameters.Payer) { discountCurve = leg2DiscountCurve; } else { throw new NotImplementedException(); } if (paymentCalendar == null) { var containsPaymentDateAdjustments = AdjustableOrAdjustedDateHelper.Contains(payment.paymentDate, ItemsChoiceType.dateAdjustments, out var dateAdjustments); if (containsPaymentDateAdjustments && dateAdjustments != null) { paymentCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, ((BusinessDayAdjustments)dateAdjustments). businessCenters, nameSpace); } } var date = AdjustedDateHelper.GetAdjustedDate(paymentCalendar, payment.paymentDate); if (date == null) { continue; } payment.discountFactor = (decimal)discountCurve.GetDiscountFactor(valuationDate, (DateTime)date); payment.discountFactorSpecified = true; payment.presentValueAmount = MoneyHelper.Mul(payment.paymentAmount, payment.discountFactor); } }
/// <summary> /// Initializes a new instance of the <see cref="PriceableCashflow"/> class. /// </summary> /// <param name="cashflowId">The identifier.</param> /// <param name="payerIsBaseParty">The is base party flag.</param> /// <param name="modelIdentifier">The _model identifier.</param> /// <param name="amount">The amount.</param> /// <param name="paymentDate">The payment date.</param> /// <param name="paymentType">Type of the payment.</param> /// <param name="cashflowType">Type of the cashflow.</param> /// <param name="includePaymentDate">if set to <c>true</c> [include payment date].</param> /// <param name="paymentCalendar">Type paymentCalendar.</param> protected PriceableCashflow ( string cashflowId , string modelIdentifier , bool payerIsBaseParty , Money amount , AdjustableOrAdjustedDate paymentDate , PaymentType paymentType , CashflowType cashflowType , bool includePaymentDate , IBusinessCalendar paymentCalendar) { Multiplier = 1.0m; var date = AdjustedDateHelper.GetAdjustedDate(paymentCalendar, paymentDate); if (date != null) { PaymentDate = (DateTime)date; } var containsPaymentDateAdjustments = AdjustableOrAdjustedDateHelper.Contains(paymentDate, ItemsChoiceType.dateAdjustments, out var dateAdjustments); if (containsPaymentDateAdjustments && dateAdjustments != null) { PaymentDateAdjustments = (BusinessDayAdjustments)dateAdjustments; } PayerIsBaseParty = payerIsBaseParty; Id = cashflowId; ModelIdentifier = modelIdentifier; PaymentType = paymentType; PaymentAmount = amount; ForecastAmount = amount; CashflowType = cashflowType; PaymentDateIncluded = includePaymentDate; PricingStructureEvolutionType = PricingStructureEvolutionType.ForwardToSpot; RiskMaturityDate = PaymentDate; DiscountCurveName = CurveNameHelpers.GetDiscountCurveName(amount.currency.Value, true); if (!PaymentCurrencies.Contains(amount.currency.Value)) { PaymentCurrencies.Add(amount.currency.Value); } }
/// <summary> /// /// </summary> /// <param name="nameSpace"></param> /// <param name="baseDateForRelativeOffset"></param> /// <param name="baseParty"></param> /// <param name="optionPremia"></param> /// <param name="fixingCalendar"></param> /// <param name="paymentCalendar"> </param> /// <param name="cache"></param> /// <returns></returns> public static PriceableFxOptionPremium CreatePriceableFxOptionPremium(ICoreCache cache, String nameSpace, DateTime?baseDateForRelativeOffset, string baseParty, FxOptionPremium optionPremia, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar) { bool payerIsBase = baseParty == optionPremia.payerPartyReference.href; var multiplier = payerIsBase ? -1.0m : 1.0m; var settlementDate = AdjustedDateHelper.GetAdjustedDate(cache, nameSpace, fixingCalendar, baseDateForRelativeOffset, optionPremia.paymentDate); if (settlementDate == null) { return(null); } var date = new PriceableFxOptionPremium("FxOptionPremiumPayment", optionPremia.payerPartyReference.href, optionPremia.receiverPartyReference.href, payerIsBase, MoneyHelper.Mul(optionPremia.paymentAmount, multiplier), (DateTime)settlementDate, optionPremia.quote, optionPremia.settlementInformation, paymentCalendar); return(date); }