public static AdjustableOrAdjustedDate CreateUnadjustedDate(DateTime unadjustedDate, BusinessDayAdjustments businessDayAdjustments) { var date = new AdjustableOrAdjustedDate(); var identifiedDate = IdentifiedDateHelper.Create(ItemsChoiceType.unadjustedDate.ToString(), unadjustedDate); object[] items; ItemsChoiceType[] itemsElementName; if (businessDayAdjustments != null) { items = new object[2]; items[0] = identifiedDate; items[1] = businessDayAdjustments; itemsElementName = new ItemsChoiceType[2]; itemsElementName[0] = ItemsChoiceType.unadjustedDate; itemsElementName[1] = ItemsChoiceType.dateAdjustments; } else { items = new object[1]; items[0] = identifiedDate; itemsElementName = new ItemsChoiceType[1]; itemsElementName[0] = ItemsChoiceType.unadjustedDate; } date.Items = items; date.ItemsElementName = itemsElementName; return(date); }
public static AdjustableOrAdjustedDate Create(DateTime?unadjustedDate, DateTime?adjustedDate, BusinessDayAdjustments businessDayAdjustments) { var date = new AdjustableOrAdjustedDate(); var items = new List <object>(); var itemsElementName = new List <ItemsChoiceType>(); if (unadjustedDate == null && adjustedDate == null) { return(date); } if (unadjustedDate != null) { items.Add(IdentifiedDateHelper.Create(ItemsChoiceType.unadjustedDate.ToString(), (DateTime)unadjustedDate)); itemsElementName.Add(ItemsChoiceType.unadjustedDate); } if (adjustedDate != null) { items.Add(IdentifiedDateHelper.Create(ItemsChoiceType.adjustedDate.ToString(), (DateTime)adjustedDate)); itemsElementName.Add(ItemsChoiceType.adjustedDate); } if (businessDayAdjustments != null) { items.Add(businessDayAdjustments); itemsElementName.Add(ItemsChoiceType.dateAdjustments); } date.Items = items.ToArray(); date.ItemsElementName = itemsElementName.ToArray(); return(date); }
/// <summary> /// /// </summary> /// <param name="uniqueId"></param> /// <param name="payerIsBase"></param> /// <param name="accrualStartDate"></param> /// <param name="accrualEndDate"></param> /// <param name="adjustCalculationDatesIndicator"></param> /// <param name="paymentDate"></param> /// <param name="notionalAmount"></param> /// <param name="resetRelativeTo"></param> /// <param name="fixingDateRelativeOffset"></param> /// <param name="margin"></param> /// <param name="calculation"></param> /// <param name="forecastRateIndex"></param> /// <param name="fixingCalendar"></param> /// <param name="paymentCalendar"></param> public PriceableFloatingRateCoupon (string uniqueId , bool payerIsBase , DateTime accrualStartDate , DateTime accrualEndDate , Boolean adjustCalculationDatesIndicator , AdjustableOrAdjustedDate paymentDate , Money notionalAmount , ResetRelativeToEnum resetRelativeTo , RelativeDateOffset fixingDateRelativeOffset , Decimal margin , Calculation calculation , ForecastRateIndex forecastRateIndex , IBusinessCalendar fixingCalendar , IBusinessCalendar paymentCalendar) : this (uniqueId , payerIsBase , accrualStartDate , accrualEndDate , adjustCalculationDatesIndicator , paymentDate , notionalAmount , resetRelativeTo , fixingDateRelativeOffset , margin , 0.0m , calculation , forecastRateIndex , fixingCalendar , paymentCalendar) { }
/// <summary> /// Derives the adjusted date if not already provided. /// </summary> /// <param name="adjustableOrAdjustedDate">this may contain the adjustedDate, an unadjusted Date and business Centre</param> /// <param name="businessCalendar">THe business calendar must be provided, no namespace is required and can be null</param> /// <returns></returns> public static DateTime?GetAdjustedDate(IBusinessCalendar businessCalendar, AdjustableOrAdjustedDate adjustableOrAdjustedDate) { var result = AdjustableOrAdjustedDateHelper.Contains(adjustableOrAdjustedDate, ItemsChoiceType.adjustedDate, out var date); if (result) { return(((IdentifiedDate)date).Value); } result = AdjustableOrAdjustedDateHelper.Contains(adjustableOrAdjustedDate, ItemsChoiceType.unadjustedDate, out date); var bda = AdjustableOrAdjustedDateHelper.Contains(adjustableOrAdjustedDate, ItemsChoiceType.dateAdjustments, out var businessDayAdjustments); if (result && date != null) { DateTime unadjustedDate = ((IdentifiedDate)date).Value; if (bda && businessCalendar != null) { if (businessDayAdjustments is BusinessDayAdjustments adjustments) { return(businessCalendar.Roll(unadjustedDate, adjustments.businessDayConvention)); } } return(unadjustedDate); } return(null); }
/// <summary> /// Initializes a new instance of the <see cref="PriceableFixedRateCoupon"/> class. /// </summary> /// <param name="uniqueId">The unique id.</param> /// <param name="payerIsBase">The payer is base flag.</param> /// <param name="accrualStartDate">The accrual start date. If they are adjusted then set <c>adjustCalculationDatesIndicator</c> to <c>false</c> [adjust calculation dates indicator].</param> /// <param name="accrualEndDate">The accrual end date. If they are adjusted then set <c>adjustCalculationDatesIndicator</c> to <c>false</c> [adjust calculation dates indicator].</param> /// <param name="adjustCalculationDatesIndicator">if set to <c>true</c> [adjust calculation dates indicator].</param> /// <param name="accrualDayAdjustments">The accrual business day adjustments.</param> /// <param name="paymentDate">The payment date.</param> /// <param name="calculation">The fixed rate calculation.</param> /// <param name="notionalAmount">The notional amount.</param> /// <param name="paymentCalendar">The paymentCalendar.</param> public PriceableFixedRateCoupon ( string uniqueId , bool payerIsBase , DateTime accrualStartDate , DateTime accrualEndDate , bool adjustCalculationDatesIndicator , BusinessDayAdjustments accrualDayAdjustments , AdjustableOrAdjustedDate paymentDate , Calculation calculation , Money notionalAmount , IBusinessCalendar paymentCalendar) : base (uniqueId , CouponType.FixedRate , payerIsBase , accrualStartDate , accrualEndDate , adjustCalculationDatesIndicator , accrualDayAdjustments , calculation , notionalAmount , paymentDate , paymentCalendar) { Id = uniqueId; }
/// <summary> /// Initializes a new instance of the <see cref="PriceableRateCoupon"/> class. /// </summary> /// <param name="cashflowId">The stream id.</param> /// <param name="payerIsBase">The payer is base flag.</param> /// <param name="accrualStartDate">The accrual start date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="accrualEndDate">The accrual end date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="adjustCalculationDatesIndicator">if set to <c>true</c> [adjust calculation dates indicator].</param> /// <param name="accrualBusinessCenters">The accrual business centers.</param> /// <param name="fixedRate">The fixed rate.</param> /// <param name="notionalAmount">The notional amount.</param> /// <param name="dayCountFraction">Type of day Count fraction.</param> /// <param name="paymentDate">The payment date.</param> /// <param name="accrualRollConvention">The accrual roll convention.</param> /// <param name="discountingType">The swap discounting type.</param> /// <param name="discountRate">The discount rate.</param> /// <param name="fraDiscounting">Determines whether the coupon is discounted or not. If this parameter is null, /// then it is assumed that there is no fra discounting</param> /// <param name="paymentCalendar">The paymentCalendar.</param> public PriceableFixedRateCoupon ( string cashflowId , bool payerIsBase , DateTime accrualStartDate , DateTime accrualEndDate , bool adjustCalculationDatesIndicator , BusinessCenters accrualBusinessCenters , BusinessDayConventionEnum accrualRollConvention , DayCountFraction dayCountFraction , decimal fixedRate , Money notionalAmount , AdjustableOrAdjustedDate paymentDate , DiscountingTypeEnum?discountingType , decimal?discountRate , FraDiscountingEnum?fraDiscounting , IBusinessCalendar paymentCalendar) : base(cashflowId, CouponType.FixedRate, payerIsBase, accrualStartDate, accrualEndDate, adjustCalculationDatesIndicator, accrualBusinessCenters, accrualRollConvention, dayCountFraction, fixedRate, notionalAmount, paymentDate, discountingType, discountRate, fraDiscounting, paymentCalendar) { Id = cashflowId; CalculatePaymentAmount(0); ForecastAmount = PaymentAmount; }
/// <summary> /// Initializes a new instance of the <see cref="PriceableFxRateCashflow"/> class. /// </summary> /// <param name="cashlfowId">The stream id.</param> /// <param name="payerIsBase">The payer is base flag.</param> /// <param name="accrualStartDate">The accrual start date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="accrualEndDate">The accrual end date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="adjustAccrualDatesIndicator">if set to <c>true</c> [adjust calculation dates indicator].</param> /// <param name="accrualBusinessCenters">The accrual business centers.</param> /// <param name="margin">The margin.</param> /// <param name="baseRate">The base rate for a nettable fixed/floating cash flow. </param> /// <param name="observedRate">The observed Rate.</param> /// <param name="notionalAmount">The notional amount.</param> /// <param name="dayCountfraction">Type of day Countfraction.</param> /// <param name="paymentDate">The payment date.</param> /// <param name="accrualRollConvention">The accrual roll convention.</param> /// <param name="resetRelativeTo">reset relative to?</param> /// <param name="fixingDateRelativeOffset">The fixing date offset.</param> /// <param name="forecastRateIndex">The forecastrateindex.</param> /// <param name="discountingType">The swap discounting type.</param> /// <param name="discountRate">The discount rate.</param> /// <param name="fraDiscounting">Determines whether the coupon is discounted or not. If this parameter is null, /// then it is assumed that there is no fradiscounting</param> /// <param name="fixingCalendar">The fixingCalendar.</param> /// <param name="paymentCalendar">The paymentCalendar.</param> public PriceableFloatingRateCoupon ( string cashlfowId , bool payerIsBase , DateTime accrualStartDate , DateTime accrualEndDate , Boolean adjustAccrualDatesIndicator , BusinessCenters accrualBusinessCenters , BusinessDayConventionEnum accrualRollConvention , DayCountFraction dayCountfraction , ResetRelativeToEnum resetRelativeTo , RelativeDateOffset fixingDateRelativeOffset , Decimal margin , Decimal baseRate , Decimal?observedRate , Money notionalAmount , AdjustableOrAdjustedDate paymentDate , ForecastRateIndex forecastRateIndex , DiscountingTypeEnum?discountingType , Decimal?discountRate , FraDiscountingEnum?fraDiscounting , IBusinessCalendar fixingCalendar , IBusinessCalendar paymentCalendar) : base( cashlfowId , CouponType.FloatingRate , payerIsBase , accrualStartDate , accrualEndDate , adjustAccrualDatesIndicator , accrualBusinessCenters , accrualRollConvention , dayCountfraction , observedRate , notionalAmount , paymentDate , discountingType , discountRate , fraDiscounting , paymentCalendar) { BaseRate = baseRate; FixingCalendar = fixingCalendar; ModelIdentifier = "DualCurveCouponModel"; Id = cashlfowId; ForwardStartDate = AccrualStartDate; ForecastRateIndex = forecastRateIndex; FixingDateRelativeOffset = fixingDateRelativeOffset; ResetRelativeTo = resetRelativeTo; Margin = margin; AdjustedFixingDate = GetResetDate(resetRelativeTo, fixingDateRelativeOffset); if (observedRate != null) { RateObservation = RateObservationHelper.Parse(AdjustedFixingDate, (decimal)observedRate, "1"); } SetRateObservation(RateObservation, ResetDate); ForecastCurveName = CurveNameHelpers.GetForecastCurveName(forecastRateIndex); }
/// <summary> /// Initializes a new instance of the <see cref="PriceablePrincipalExchange"/> class. /// </summary> /// <param name="id">The identifier.</param> /// <param name="payerIsBase">The payerIsBase flag.</param> /// <param name="amount">The amount.</param> /// <param name="paymentDate">The payment date.</param> /// <param name="paymentCalendar">The paymentCalendar.</param> public BulletPaymentPricer ( string id , bool payerIsBase , Money amount , AdjustableOrAdjustedDate paymentDate , IBusinessCalendar paymentCalendar) : base(id, "DiscountedCashflow", payerIsBase, amount, paymentDate, PaymentTypeHelper.Create("Certain"), CashflowTypeHelper.Create(CashflowTypeEnum.PrincipalExchange.ToString()), false, paymentCalendar) { }
/// <summary> /// Initializes a new instance of the <see cref="PriceableCapFloorCoupon"/> class. /// </summary> /// <param name="uniqueId"></param> /// <param name="buyerIsBase">The buyer is base flag.</param> /// <param name="capStrike">The Cap strike.</param> /// <param name="floorStrike">The floor strike.</param> /// <param name="accrualStartDate"></param> /// <param name="accrualEndDate"></param> /// <param name="adjustCalculationDatesIndicator"></param> /// <param name="paymentDate"></param> /// <param name="notionalAmount"></param> /// <param name="resetRelativeTo"></param> /// <param name="fixingDateRelativeOffset"></param> /// <param name="margin"></param> /// <param name="calculation"></param> /// <param name="forecastRateIndex"></param> /// <param name="fixingCalendar"></param> /// <param name="paymentCalendar"></param> public PriceableCapFloorCoupon (string uniqueId , bool buyerIsBase , decimal?capStrike , decimal?floorStrike , DateTime accrualStartDate , DateTime accrualEndDate , Boolean adjustCalculationDatesIndicator , AdjustableOrAdjustedDate paymentDate , Money notionalAmount , ResetRelativeToEnum resetRelativeTo , RelativeDateOffset fixingDateRelativeOffset , Decimal margin , Calculation calculation , ForecastRateIndex forecastRateIndex , IBusinessCalendar fixingCalendar , IBusinessCalendar paymentCalendar) : base (uniqueId , buyerIsBase , accrualStartDate , accrualEndDate , adjustCalculationDatesIndicator , paymentDate , notionalAmount , resetRelativeTo , fixingDateRelativeOffset , margin , calculation , forecastRateIndex , fixingCalendar , paymentCalendar) { CapStrike = capStrike; FloorStrike = floorStrike; VolatilitySurfaceName = CurveNameHelpers.GetRateVolatilityMatrixName(forecastRateIndex); if (capStrike != null && floorStrike == null) { PriceableCouponType = CouponType.Cap; ModelIdentifier = "DualCurveCapModel"; IsCall = true; } if (floorStrike != null && capStrike == null) { PriceableCouponType = CouponType.Floor; ModelIdentifier = "DualCurveFloorModel"; } if (floorStrike != null && capStrike != null) { PriceableCouponType = CouponType.Collar; ModelIdentifier = "DualCurveCollarModel"; } }
public static AdjustableOrAdjustedDate CreateUnadjustedDate(DateTime unadjustedDate) { var date = new AdjustableOrAdjustedDate(); var identifiedDate = IdentifiedDateHelper.Create("UnadjustedDate", unadjustedDate); var items = new object[1]; items[0] = identifiedDate; date.Items = items; var itemsElementName = new ItemsChoiceType[1]; itemsElementName[0] = ItemsChoiceType.unadjustedDate; date.ItemsElementName = itemsElementName; return(date); }
private static AdjustableOrAdjustedDate CreateAdjustedDate(DateTime adjustedDate) { var date = new AdjustableOrAdjustedDate(); var identifiedDate = CreateIdentifiedDate("AdjustedDate", adjustedDate); var items = new object[1]; items[0] = identifiedDate; date.Items = items; var itemsElementName = new ItemsChoiceType1[1]; itemsElementName[0] = ItemsChoiceType1.adjustedDate; date.ItemsElementName = itemsElementName; return(date); }
public static AdjustableOrAdjustedDate CreateUnadjustedDate(DateTime unadjustedDate) { var date = new AdjustableOrAdjustedDate(); var identifiedDate = ProductTypeHelper.IdentifiedDateHelper.Create(ItemsChoiceType1.unadjustedDate.ToString(), unadjustedDate); var items = new object[1]; items[0] = identifiedDate; date.Items = items; var itemsElementName = new ItemsChoiceType1[1]; itemsElementName[0] = ItemsChoiceType1.unadjustedDate; date.ItemsElementName = itemsElementName; return(date); }
/// <summary> /// Initializes a new instance of the <see cref="PriceableFxRateCashflow"/> class. /// </summary> /// <param name="cashlfowId">The stream id.</param> /// <param name="payerIsBase">The payer is base flag.</param> /// <param name="accrualStartDate">The accrual start date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="accrualEndDate">The accrual end date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="adjustAccrualDatesIndicator">if set to <c>true</c> [adjust calculation dates indicator].</param> /// <param name="accrualBusinessCenters">The accrual business centers.</param> /// <param name="margin">The margin.</param> /// <param name="observedRate">The observed Rate.</param> /// <param name="notionalAmount">The notional amount.</param> /// <param name="dayCountfraction">Type of day Countfraction.</param> /// <param name="paymentDate">The payment date.</param> /// <param name="accrualRollConvention">The accrual roll convention.</param> /// <param name="resetRelativeTo">reset relative to?</param> /// <param name="fixingDateRelativeOffset">The fixing date offset.</param> /// <param name="forecastRateIndex">The forecastrateindex.</param> /// <param name="discountingType">The swap discounting type.</param> /// <param name="discountRate">The discount rate.</param> /// <param name="fraDiscounting">Determines whether the coupon is discounted or not. If this parameter is null, /// then it is assumed that there is no fradiscounting</param> /// <param name="fixingCalendar">The fixingCalendar.</param> /// <param name="paymentCalendar">The paymentCalendar.</param> public PriceableFloatingRateCoupon ( string cashlfowId , bool payerIsBase , DateTime accrualStartDate , DateTime accrualEndDate , Boolean adjustAccrualDatesIndicator , BusinessCenters accrualBusinessCenters , BusinessDayConventionEnum accrualRollConvention , DayCountFraction dayCountfraction , ResetRelativeToEnum resetRelativeTo , RelativeDateOffset fixingDateRelativeOffset , Decimal margin , Decimal?observedRate , Money notionalAmount , AdjustableOrAdjustedDate paymentDate , ForecastRateIndex forecastRateIndex , DiscountingTypeEnum?discountingType , Decimal?discountRate , FraDiscountingEnum?fraDiscounting , IBusinessCalendar fixingCalendar , IBusinessCalendar paymentCalendar) : this( cashlfowId , payerIsBase , accrualStartDate , accrualEndDate , adjustAccrualDatesIndicator , accrualBusinessCenters , accrualRollConvention , dayCountfraction , resetRelativeTo , fixingDateRelativeOffset , margin , 0.0m , observedRate , notionalAmount , paymentDate , forecastRateIndex , discountingType , discountRate , fraDiscounting , fixingCalendar , paymentCalendar) { }
/// <summary> /// Initializes a new instance of the <see cref="PriceablePayment"/> class. /// </summary> /// <param name="id">The identifier.</param> /// <param name="payerPartyReference">The payer.</param> /// <param name="receiverPartyReference">The receiver.</param> /// <param name="payerIsBase">The payer is base flag.</param> /// <param name="amount">The amount.</param> /// <param name="paymentDate">The payment date.</param> /// <param name="paymentCalendar">Type paymentCalendar.</param> public PriceablePayment ( string id , string payerPartyReference , string receiverPartyReference , bool payerIsBase , Money amount , AdjustableOrAdjustedDate paymentDate , IBusinessCalendar paymentCalendar) : base(id, "DiscountedCashflow", payerIsBase, amount, paymentDate, PaymentTypeHelper.Create("Certain"), CashflowTypeHelper.Create(CashflowTypeEnum.PrincipalExchange.ToString()), false, paymentCalendar) { PayerPartyReference = PartyReferenceFactory.Create(payerPartyReference); ReceiverPartyReference = PartyReferenceFactory.Create(receiverPartyReference); OrderedPartyNames.Add(PayerPartyReference.href); OrderedPartyNames.Add(ReceiverPartyReference.href); }
/// <summary> /// Initializes a new instance of the <see cref="PriceableFxRateCashflow"/> class. /// </summary> /// <param name="cashflowId">The stream id.</param> /// <param name="startIndex">The start Index. If null then the cash flow is not a differenctial.</param> /// <param name="observedIndex">The observed Index. If null then the cash flow is not a differenctial. </param> /// <param name="isCurrency1Base">The isCurrency1Base flag. </param> /// <param name="currency2PayerIsBase">The currency2PayerIsBase lag.</param> /// <param name="isSettlementInCurrency1">The isSettlementInCurrency1 flag</param> /// <param name="hybridValuation">Is hybrid valuation used, or the base fa curve. </param> /// <param name="currency1NotionalAmount">The currency1 notional amount.</param> /// <param name="fixingDateRelativeOffset">The fixingDateRelativeOffset.</param> /// <param name="paymentDate">The payment date.</param> /// <param name="fixingCalendar">The fixingCalendar.</param> /// <param name="paymentCalendar">The paymentCalendar.</param> protected PriceableFxRateCashflow ( string cashflowId , FxRate startIndex , FxRate observedIndex , bool isCurrency1Base , bool currency2PayerIsBase , bool isSettlementInCurrency1 , bool hybridValuation , Money currency1NotionalAmount , AdjustableOrAdjustedDate paymentDate , RelativeDateOffset fixingDateRelativeOffset , IBusinessCalendar fixingCalendar , IBusinessCalendar paymentCalendar) : base ( cashflowId , FloatingIndexType.Fx , startIndex.rate , IsObserved(observedIndex) , currency2PayerIsBase , currency1NotionalAmount , paymentDate , fixingDateRelativeOffset , fixingCalendar , paymentCalendar) { ModelIdentifier = "FloatingFxRateCashflowModel"; StartFxRate = startIndex; IsSettlementInCurrency1 = isSettlementInCurrency1; HybridValuation = hybridValuation; if (StartFxRate.quotedCurrencyPair.quoteBasis == QuoteBasisEnum.Currency1PerCurrency2) { InvertFxRate = true; } IsCurrency1Base = isCurrency1Base; Currency1 = StartFxRate.quotedCurrencyPair.currency1; Currency2 = StartFxRate.quotedCurrencyPair.currency2; //Set the default discount curve name. Currency1DiscountCurveName = CurveNameHelpers.GetDiscountCurveName(Currency1.Value, true); //Set the default discount curve name. Currency2DiscountCurveName = CurveNameHelpers.GetDiscountCurveName(Currency2.Value, true); ForecastCurveName = MarketEnvironmentHelper.ResolveFxCurveNames(StartFxRate.quotedCurrencyPair.currency1.Value, StartFxRate.quotedCurrencyPair.currency2.Value); }
/// <summary> /// /// </summary> /// <param name="uniqueId"></param> /// <param name="payerIsBase"></param> /// <param name="accrualStartDate"></param> /// <param name="accrualEndDate"></param> /// <param name="adjustCalculationDatesIndicator"></param> /// <param name="paymentDate"></param> /// <param name="notionalAmount"></param> /// <param name="resetRelativeTo"></param> /// <param name="fixingDateRelativeOffset"></param> /// <param name="margin"></param> /// <param name="baseRate"> </param> /// <param name="calculation"></param> /// <param name="forecastRateIndex"></param> /// <param name="fixingCalendar"></param> /// <param name="paymentCalendar"></param> public PriceableFloatingRateCoupon (string uniqueId , bool payerIsBase , DateTime accrualStartDate , DateTime accrualEndDate , Boolean adjustCalculationDatesIndicator , AdjustableOrAdjustedDate paymentDate , Money notionalAmount , ResetRelativeToEnum resetRelativeTo , RelativeDateOffset fixingDateRelativeOffset , Decimal margin , Decimal baseRate , Calculation calculation , ForecastRateIndex forecastRateIndex , IBusinessCalendar fixingCalendar , IBusinessCalendar paymentCalendar) : base (uniqueId , CouponType.FloatingRate , payerIsBase , accrualStartDate , accrualEndDate , adjustCalculationDatesIndicator , BusinessDayAdjustmentsHelper.Create(fixingDateRelativeOffset.businessDayConvention, fixingDateRelativeOffset.businessCenters) , calculation , notionalAmount , paymentDate , paymentCalendar) { BaseRate = baseRate; FixingCalendar = fixingCalendar; ModelIdentifier = "DualCurveCouponModel"; ForwardStartDate = AccrualStartDate; ForwardEndDate = AccrualEndDate; ForecastRateIndex = forecastRateIndex; FixingDateRelativeOffset = fixingDateRelativeOffset; ResetRelativeTo = resetRelativeTo; Margin = margin; var floatingRateDefinition = (FloatingRateDefinition)calculation.Items[0]; RateObservation = floatingRateDefinition.rateObservation[0]; AdjustedFixingDate = GetResetDate(resetRelativeTo, fixingDateRelativeOffset); SetRateObservation(RateObservation, ResetDate); ForecastCurveName = CurveNameHelpers.GetForecastCurveName(forecastRateIndex); }
/// <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); } }
public static Swaption GenerateSwaptionDefiniton(SwapLegParametersRange_Old leg1Parameters, IBusinessCalendar leg1PaymentCalendar, SwapLegParametersRange_Old leg2Parameters, IBusinessCalendar leg2PaymentCalendar, SwaptionParametersRange swaptionParameters) { Swap swap = SwapGenerator.GenerateDefiniton(leg1Parameters, leg2Parameters); NonNegativeMoney premium = MoneyHelper.GetNonNegativeAmount(swaptionParameters.Premium, swaptionParameters.PremiumCurrency); AdjustableDate expirationDate = DateTypesHelper.ToAdjustableDate(swaptionParameters.ExpirationDate, swaptionParameters.ExpirationDateBusinessDayAdjustments, swaptionParameters.ExpirationDateCalendar); AdjustableOrAdjustedDate paymentDate = DateTypesHelper.ToAdjustableOrAdjustedDate(swaptionParameters.PaymentDate, swaptionParameters.PaymentDateBusinessDayAdjustments, swaptionParameters.PaymentDateCalendar); TimeSpan earliestExerciseTimeAsTimeSpan = TimeSpan.FromDays(swaptionParameters.EarliestExerciseTime); DateTime earliestExerciseTime = DateTime.MinValue.Add(earliestExerciseTimeAsTimeSpan); TimeSpan expirationTimeAsTimeSpan = TimeSpan.FromDays(swaptionParameters.ExpirationTime); DateTime expirationTime = DateTime.MinValue.Add(expirationTimeAsTimeSpan); return(SwaptionFactory.Create(swap, premium, swaptionParameters.PremiumPayer, swaptionParameters.PremiumReceiver, paymentDate, expirationDate, earliestExerciseTime, expirationTime, swaptionParameters.AutomaticExcercise)); }
/// <summary> /// /// </summary> /// <param name="identifier"></param> /// <param name="payerPartyReference"></param> /// <param name="receiverPartyReference"></param> /// <param name="paymentAmount"></param> /// <param name="adjustablePaymentDate"></param> /// <param name="settlementInformation"></param> /// <param name="paymentType"></param> /// <param name="discountFactor"></param> /// <param name="presentValueAmount"></param> /// <returns></returns> public static Payment Create(string identifier, PartyReference payerPartyReference, PartyReference receiverPartyReference, NonNegativeMoney paymentAmount, AdjustableOrAdjustedDate adjustablePaymentDate, SettlementInformation settlementInformation, PaymentType paymentType, decimal discountFactor, Money presentValueAmount) { var payment = new Payment { paymentDate = adjustablePaymentDate, discountFactor = discountFactor, discountFactorSpecified = true, href = identifier, payerPartyReference = payerPartyReference, paymentAmount = paymentAmount, paymentType = paymentType, presentValueAmount = presentValueAmount, receiverPartyReference = receiverPartyReference, settlementInformation = settlementInformation }; return(payment); }
/// <summary> /// Initializes a new instance of the <see cref="PriceableVanillaFxOption"/> class. /// </summary> /// <param name="cashlfowId">The stream id.</param> /// <param name="startIndex">The start Index. If null then the cash flow is not a differenctial.</param> /// <param name="observedIndex">The observed Index. If null then the cash flow is not a differenctial. </param> /// <param name="isCurrency1Base">The isCurrency1Base flag. </param> /// <param name="currency2PayerIsBase">The currency2PayerIsBase lag.</param> /// <param name="isSettlementInCurrency1">The isSettlementInCurrency1 flag</param> /// <param name="hybridValuation">Is hybrid valuation used, or the base fa curve. </param> /// <param name="currency1NotionalAmount">The currency1 notional amount.</param> /// <param name="fixingDateRelativeOffset">The fixingDateRelativeOffset.</param> /// <param name="strike">The strike. </param> /// <param name="fxOptionType">THe option type: currently only call or pt </param> /// <param name="paymentDate">The payment date.</param> /// <param name="fixingCalendar">The fixingCalendar.</param> /// <param name="paymentCalendar">The paymentCalendar.</param> protected PriceableVanillaFxOption ( string cashlfowId , FxRate startIndex , FxRate observedIndex , bool isCurrency1Base , bool currency2PayerIsBase , bool isSettlementInCurrency1 , bool hybridValuation , Money currency1NotionalAmount , decimal strike , FxOptionType fxOptionType , AdjustableOrAdjustedDate paymentDate , RelativeDateOffset fixingDateRelativeOffset , IBusinessCalendar fixingCalendar , IBusinessCalendar paymentCalendar) : base ( cashlfowId , startIndex , observedIndex , isCurrency1Base , currency2PayerIsBase , isSettlementInCurrency1 , hybridValuation , currency1NotionalAmount , paymentDate , fixingDateRelativeOffset , fixingCalendar , paymentCalendar) { Strike = strike; FxOptionType = FxOptionType.Call; if (fxOptionType != FxOptionType.Call)//TODO Only call or put. { FxOptionType = FxOptionType.Put; } VolatilitySurfaceName = CurveNameHelpers.GetFxVolatilityMatrixName(startIndex, "FxSpot"); ModelIdentifier = "VanillaFxOptionModel"; }
public static Boolean Contains(AdjustableOrAdjustedDate adjustableOrAdjustedDate, ItemsChoiceType item, out object dateOrBusinessConvention) { dateOrBusinessConvention = null; if (adjustableOrAdjustedDate.Items == null) { return(false); } if (adjustableOrAdjustedDate.ItemsElementName != null) { for (var i = 0; i < adjustableOrAdjustedDate.ItemsElementName.Length; i++) { if (adjustableOrAdjustedDate.ItemsElementName[i] != item) { continue; } dateOrBusinessConvention = adjustableOrAdjustedDate.Items[i]; return(true); } return(false); } return(false); }
public static Trade CreateSwaptionTrade(SwaptionParametersRange swaptionParametersRange, IBusinessCalendar paymentCalendar, Swap underlyingSwap) { var premium = MoneyHelper.GetNonNegativeAmount(swaptionParametersRange.Premium, swaptionParametersRange.PremiumCurrency); AdjustableDate expirationDate = DateTypesHelper.ToAdjustableDate(swaptionParametersRange.ExpirationDate, swaptionParametersRange.ExpirationDateBusinessDayAdjustments, swaptionParametersRange.ExpirationDateCalendar); AdjustableOrAdjustedDate paymentDate = DateTypesHelper.ToAdjustableOrAdjustedDate(swaptionParametersRange.PaymentDate, swaptionParametersRange.PaymentDateBusinessDayAdjustments, swaptionParametersRange.PaymentDateCalendar); TimeSpan earliestExerciseTimeAsTimeSpan = TimeSpan.FromDays(swaptionParametersRange.EarliestExerciseTime); DateTime earliestExerciseTime = DateTime.MinValue.Add(earliestExerciseTimeAsTimeSpan); TimeSpan expirationTimeAsTimeSpan = TimeSpan.FromDays(swaptionParametersRange.ExpirationTime); DateTime expirationTime = DateTime.MinValue.Add(expirationTimeAsTimeSpan); var swaption = SwaptionFactory.Create(underlyingSwap, premium, swaptionParametersRange.PremiumPayer, swaptionParametersRange.PremiumReceiver, paymentDate, expirationDate, earliestExerciseTime, expirationTime, swaptionParametersRange.AutomaticExcercise); swaption.Items = new object[] { new ProductType { Value = ProductTypeSimpleEnum.InterestRateSwaption.ToString() } }; swaption.ItemsElementName = new[] { ItemsChoiceType2.productType }; var trade = new Trade(); XsdClassesFieldResolver.TradeSetSwaption(trade, swaption); return(trade); }
public static Swaption Create(Swap swap, NonNegativeMoney premium, string premiumPayer, string premiumReceiver, AdjustableOrAdjustedDate paymentDate, AdjustableDate expirationDate, DateTime earliestExerciseTime, DateTime expirationTime, bool automaticExercise) { var swaption = new Swaption { swap = swap, premium = new[] { new Payment() }, buyerPartyReference = PartyReferenceHelper.Parse(premiumPayer), sellerPartyReference = PartyReferenceHelper.Parse(premiumReceiver) }; swaption.premium[0].paymentAmount = premium; swaption.premium[0].paymentDate = paymentDate; swaption.premium[0].payerPartyReference = PartyReferenceHelper.Parse(premiumPayer); swaption.premium[0].receiverPartyReference = PartyReferenceHelper.Parse(premiumReceiver); var europeanExercise = new EuropeanExercise { expirationDate = new AdjustableOrRelativeDate(), earliestExerciseTime = BusinessCenterTimeHelper.Create(earliestExerciseTime), expirationTime = BusinessCenterTimeHelper.Create(expirationTime) }; europeanExercise.expirationDate.Item = expirationDate; swaption.exerciseProcedure = new ExerciseProcedure(); if (automaticExercise) { XsdClassesFieldResolver.ExerciseProcedureSetAutomaticExercise(swaption.exerciseProcedure, new AutomaticExercise()); } else//manual exercise { XsdClassesFieldResolver.ExerciseProcedureSetManualExercise(swaption.exerciseProcedure, new ManualExercise()); } XsdClassesFieldResolver.SwaptionSetEuropeanExercise(swaption, europeanExercise); return(swaption); }
/// <summary> /// Initializes a new instance of the <see cref="PriceableCapFloorCoupon"/> class. /// </summary> /// <param name="cashFlowId">The stream id.</param> /// <param name="buyerIsBase">The buyer is base flag.</param> /// <param name="capStrike">The Cap strike.</param> /// <param name="floorStrike">The floor strike.</param> /// <param name="accrualStartDate">The accrual start date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="accrualEndDate">The accrual end date. If adjusted, the adjustCalculationDatesIndicator should be false.</param> /// <param name="adjustAccrualDatesIndicator">if set to <c>true</c> [adjust calculation dates indicator].</param> /// <param name="accrualBusinessCenters">The accrual business centers.</param> /// <param name="margin">The margin.</param> /// <param name="observedRate">The observed Rate.</param> /// <param name="notionalAmount">The notional amount.</param> /// <param name="dayCountFraction">Type of day Count fraction.</param> /// <param name="paymentDate">The payment date.</param> /// <param name="accrualRollConvention">The accrual roll convention.</param> /// <param name="resetRelativeTo">reset relative to?</param> /// <param name="fixingDateRelativeOffset">The fixing date offset.</param> /// <param name="forecastRateIndex">The forecast rate index.</param> /// <param name="discountingType">The swap discounting type.</param> /// <param name="discountRate">The discount rate.</param> /// <param name="fraDiscounting">Determines whether the coupon is discounted or not. If this parameter is null, /// then it is assumed that there is no fra discounting</param> /// <param name="fixingCalendar">The fixingCalendar.</param> /// <param name="paymentCalendar">The paymentCalendar.</param> public PriceableCapFloorCoupon ( string cashFlowId , bool buyerIsBase , decimal?capStrike , decimal?floorStrike , DateTime accrualStartDate , DateTime accrualEndDate , Boolean adjustAccrualDatesIndicator , BusinessCenters accrualBusinessCenters , BusinessDayConventionEnum accrualRollConvention , DayCountFraction dayCountFraction , ResetRelativeToEnum resetRelativeTo , RelativeDateOffset fixingDateRelativeOffset , Decimal margin , Decimal?observedRate , Money notionalAmount , AdjustableOrAdjustedDate paymentDate , ForecastRateIndex forecastRateIndex , DiscountingTypeEnum?discountingType , Decimal?discountRate , FraDiscountingEnum?fraDiscounting , IBusinessCalendar fixingCalendar , IBusinessCalendar paymentCalendar) : base( cashFlowId , buyerIsBase , accrualStartDate , accrualEndDate , adjustAccrualDatesIndicator , accrualBusinessCenters , accrualRollConvention , dayCountFraction , resetRelativeTo , fixingDateRelativeOffset , margin , observedRate , notionalAmount , paymentDate , forecastRateIndex , discountingType , discountRate , fraDiscounting , fixingCalendar , paymentCalendar) { CapStrike = capStrike; FloorStrike = floorStrike; VolatilitySurfaceName = CurveNameHelpers.GetRateVolatilityMatrixName(forecastRateIndex); if (capStrike != null && floorStrike == null) { PriceableCouponType = CouponType.Cap; ModelIdentifier = "DualCurveCapModel"; IsCall = true; } if (floorStrike != null && capStrike == null) { PriceableCouponType = CouponType.Floor; ModelIdentifier = "DualCurveFloorModel"; } if (floorStrike != null && capStrike != null) { PriceableCouponType = CouponType.Collar; ModelIdentifier = "DualCurveCollarModel"; } }
public string CreateValuation( ILogger logger, ICoreCache cache, String nameSpace, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, SwaptionParametersRange swaptionParametersRange, List <StringObjectRangeItem> valuationSet, ValuationRange valuationRange, TradeRange tradeRange, SwapLegParametersRange leg1ParametersRange, SwapLegParametersRange leg2ParametersRange, List <InputCashflowRangeItem> leg1DetailedCashflowsListArray, List <InputCashflowRangeItem> leg2DetailedCashflowsListArray, List <InputPrincipalExchangeCashflowRangeItem> leg1PrincipalExchangeCashflowListArray, List <InputPrincipalExchangeCashflowRangeItem> leg2PrincipalExchangeCashflowListArray, List <AdditionalPaymentRangeItem> leg1AdditionalPaymentListArray, List <AdditionalPaymentRangeItem> leg2AdditionalPaymentListArray, List <PartyIdRangeItem> partyIdList, //optional List <OtherPartyPaymentRangeItem> otherPartyPaymentList, //opt List <FeePaymentRangeItem> feePaymentList //opt ) { var swap = GetPriceAndGeneratedFpMLSwap(logger, cache, nameSpace, fixingCalendar, paymentCalendar, valuationRange, tradeRange, leg1ParametersRange, leg2ParametersRange, leg1DetailedCashflowsListArray, leg2DetailedCashflowsListArray, leg1PrincipalExchangeCashflowListArray, leg2PrincipalExchangeCashflowListArray, leg1AdditionalPaymentListArray, leg2AdditionalPaymentListArray).Second; string baseParty = valuationRange.BaseParty; List <IRateCurve> uniqueCurves = GetUniqueCurves(logger, cache, nameSpace, leg1ParametersRange, leg2ParametersRange); Market fpMLMarket = InterestRateProduct.CreateFpMLMarketFromCurves(uniqueCurves); // TODO: add Trade Id & Trade data into valuation. (Trade.Id & Trade.TradeHeader.TradeDate) // // create ValuationReport and add it to in-memory collection. // Add methods! AssetValuation assetValuation = InterestRateProduct.CreateAssetValuationFromValuationSet(valuationSet); NonNegativeMoney premium = MoneyHelper.GetNonNegativeAmount(swaptionParametersRange.Premium, swaptionParametersRange.PremiumCurrency); AdjustableDate expirationDate = DateTypesHelper.ToAdjustableDate(swaptionParametersRange.ExpirationDate, swaptionParametersRange.ExpirationDateBusinessDayAdjustments, swaptionParametersRange.ExpirationDateCalendar); AdjustableOrAdjustedDate paymentDate = DateTypesHelper.ToAdjustableOrAdjustedDate(swaptionParametersRange.PaymentDate, swaptionParametersRange.PaymentDateBusinessDayAdjustments, swaptionParametersRange.PaymentDateCalendar); TimeSpan earliestExerciseTimeAsTimeSpan = TimeSpan.FromDays(swaptionParametersRange.EarliestExerciseTime); DateTime earliestExerciseTime = DateTime.MinValue.Add(earliestExerciseTimeAsTimeSpan); TimeSpan expirationTimeAsTimeSpan = TimeSpan.FromDays(swaptionParametersRange.ExpirationTime); DateTime expirationTime = DateTime.MinValue.Add(expirationTimeAsTimeSpan); var swaption = SwaptionFactory.Create(swap, premium, swaptionParametersRange.PremiumPayer, swaptionParametersRange.PremiumReceiver, paymentDate, expirationDate, earliestExerciseTime, expirationTime, swaptionParametersRange.AutomaticExcercise); // overrides the premium created by SwaptionFactort.Create // var feeList = new List <Payment>(); if (null != feePaymentList) { feeList.AddRange(feePaymentList.Select(feePaymentRangeItem => new Payment { paymentDate = DateTypesHelper.ToAdjustableOrAdjustedDate(feePaymentRangeItem.PaymentDate), paymentAmount = MoneyHelper.GetNonNegativeAmount(feePaymentRangeItem.Amount), payerPartyReference = PartyReferenceFactory.Create(feePaymentRangeItem.Payer), receiverPartyReference = PartyReferenceFactory.Create(feePaymentRangeItem.Receiver) })); } swaption.premium = feeList.ToArray(); string valuationReportAndProductId = tradeRange.Id ?? Guid.NewGuid().ToString(); swaption.id = valuationReportAndProductId; ValuationReport valuationReport = ValuationReportGenerator.Generate(valuationReportAndProductId, baseParty, valuationReportAndProductId, tradeRange.TradeDate, swaption, fpMLMarket, assetValuation); cache.SaveObject(valuationReport, valuationReportAndProductId, null); InterestRateProduct.ReplacePartiesInValuationReport(valuationReport, partyIdList); InterestRateProduct.AddOtherPartyPayments(valuationReport, otherPartyPaymentList); return(valuationReportAndProductId); }