/// <summary> /// Obtains an instance representing an amount where the date is adjustable. /// <para> /// Whether the payment is pay or receive is determined by the sign of the specified amount. /// /// </para> /// </summary> /// <param name="value"> the amount of the payment </param> /// <param name="date"> the date that the payment is made </param> /// <returns> the adjustable payment instance </returns> public static AdjustablePayment of(CurrencyAmount value, AdjustableDate date) { return(new AdjustablePayment(value, date)); }
/// <summary> /// /// </summary> /// <param name="calculationPeriodDates"></param> /// <param name="value"></param> public static void CalculationPeriodDatesSetTerminationDate(CalculationPeriodDates calculationPeriodDates, AdjustableDate value) { calculationPeriodDates.Item1 = value; }
/// <summary> /// /// </summary> /// <param name="calculationPeriodDates"></param> /// <param name="value"></param> public static void CalculationPeriodDatesSetFirstPeriodStartDate(CalculationPeriodDates calculationPeriodDates, AdjustableDate value) { calculationPeriodDates.firstPeriodStartDate = value; }
private static InterestRateStream GenerateFloatingStreamDefinition(SwapLegParametersRange legParametersRange) { Discounting discounting = null; InterestRateStream stream; if (legParametersRange.DiscountingType != null && legParametersRange.DiscountingType.ToUpper() != "NONE") { discounting = new Discounting { discountingType = EnumHelper.Parse <DiscountingTypeEnum>(legParametersRange.DiscountingType) }; // Create the stream object stream = InterestRateStreamFactory.CreateFloatingRateStream(DiscountingTypeToPayRelativeTo(discounting.discountingType)); } else { // Create the stream object // stream = InterestRateStreamFactory.CreateFloatingRateStream(DiscountingTypeToPayRelativeTo(null)); } // Set effective and termination dates of the stream. // SetEffectiveAndTerminationDates(stream, legParametersRange.EffectiveDate, legParametersRange.MaturityDate, legParametersRange.PaymentBusinessDayAdjustments, legParametersRange.PaymentCalendar); //Set the FirstRegularPeriodStartDate SetFirstRegularPeriodStartDate(stream, legParametersRange.FirstRegularPeriodStartDate); //Set the LastRegularPeriodEndDate SetLastRegularPeriodEndDate(stream, legParametersRange.LastRegularPeriodEndDate); // Adjusted or unadjusted swap //Set the stub period type var dateAdjustments = AdjustedType.Adjusted != legParametersRange.AdjustedType ? BusinessDayAdjustmentsHelper.Create(BusinessDayConventionEnum.NONE, legParametersRange.PaymentCalendar) : BusinessDayAdjustmentsHelper.Create(legParametersRange.PaymentBusinessDayAdjustments, legParametersRange.PaymentCalendar); stream.calculationPeriodDates.calculationPeriodDatesAdjustments = dateAdjustments; stream.calculationPeriodDates.calculationPeriodFrequency = CalculationPeriodFrequencyHelper.Parse(legParametersRange.PaymentFrequency, legParametersRange.RollConvention); if (legParametersRange.FirstCouponType == FirstCouponType.Full) { var firstCouponStartDate = new AdjustableDate { dateAdjustments = dateAdjustments, id = "FullFirstCoupon" }; SetFirstPeriodStartDate(stream, firstCouponStartDate); } //Set the payment dates stream.paymentDates.paymentFrequency = PeriodHelper.Parse(legParametersRange.PaymentFrequency).ToFrequency(); stream.paymentDates.paymentDatesAdjustments = BusinessDayAdjustmentsHelper.Create(legParametersRange.PaymentBusinessDayAdjustments, legParametersRange.PaymentCalendar); stream.resetDates.fixingDates = RelativeDateOffsetHelper.Create(legParametersRange.PaymentFrequency, DayTypeEnum.Business, BusinessDayConventionEnum.NONE.ToString(), legParametersRange.FixingCalendar, "resetDates");//"NONE" & "resedDates" - hardcoded stream.resetDates.resetFrequency = ResetFrequencyHelper.Parse(legParametersRange.PaymentFrequency); stream.resetDates.resetDatesAdjustments = BusinessDayAdjustmentsHelper.Create(legParametersRange.FixingBusinessDayAdjustments, legParametersRange.FixingCalendar); Calculation calculation = XsdClassesFieldResolver.CalculationPeriodAmountGetCalculation(stream.calculationPeriodAmount); // Set discounting type // calculation.discounting = discounting; // Set notional amount (as the initial value in notional schedule) // SetNotional(calculation, legParametersRange.NotionalAmount, legParametersRange.Currency); // Set floating rate index name // string indexTenor = legParametersRange.PaymentFrequency; //string indexName = legParametersRange.ForecastCurve; string indexName = legParametersRange.ForecastIndexName; FloatingRateCalculation floatingRateCalculation = FloatingRateCalculationFactory.Create(indexName, indexTenor, legParametersRange.FloatingRateSpread); XsdClassesFieldResolver.CalculationSetFloatingRateCalculation(calculation, floatingRateCalculation); // Set day count convention // calculation.dayCountFraction = DayCountFractionHelper.Parse(legParametersRange.DayCount); return(stream); }
/// <summary> /// /// </summary> /// <param name="calculationPeriodDates"></param> /// <param name="value"></param> public static void CalculationPeriodDatesSetEffectiveDate(CalculationPeriodDates calculationPeriodDates, AdjustableDate value) { calculationPeriodDates.Item = value; }
private static InterestRateStream GenerateFixedStreamDefinition(SwapLegParametersRange legParametersRange) { var discountingType = legParametersRange.DiscountingType; InterestRateStream stream; Discounting discounting = null; if (discountingType != null && discountingType.ToUpper() != "NONE") { discounting = new Discounting { discountingType = EnumHelper.Parse <DiscountingTypeEnum>(legParametersRange.DiscountingType), discountingTypeSpecified = true }; stream = InterestRateStreamFactory.CreateFixedRateStream(DiscountingTypeToPayRelativeTo(discounting.discountingType)); } else { stream = InterestRateStreamFactory.CreateFixedRateStream(DiscountingTypeToPayRelativeTo(null)); } // Set effective and termination dates of the stream. // SetEffectiveAndTerminationDates(stream, legParametersRange.EffectiveDate, legParametersRange.MaturityDate, legParametersRange.PaymentBusinessDayAdjustments, legParametersRange.PaymentCalendar); //Set the FirstRegularPeriodStartDate SetFirstRegularPeriodStartDate(stream, legParametersRange.FirstRegularPeriodStartDate); //Set the LastRegularPeriodEndDate SetLastRegularPeriodEndDate(stream, legParametersRange.LastRegularPeriodEndDate); // Adjusted or unadjusted swap // var dateAdjustments = AdjustedType.Adjusted != legParametersRange.AdjustedType ? BusinessDayAdjustmentsHelper.Create(BusinessDayConventionEnum.NONE, legParametersRange.PaymentCalendar) : BusinessDayAdjustmentsHelper.Create(legParametersRange.PaymentBusinessDayAdjustments, legParametersRange.PaymentCalendar); stream.calculationPeriodDates.calculationPeriodDatesAdjustments = dateAdjustments; stream.calculationPeriodDates.calculationPeriodFrequency = CalculationPeriodFrequencyHelper.Parse(legParametersRange.PaymentFrequency, legParametersRange.RollConvention); //Set FirstPeriodStartDate i.e. Full or Partial period. if (legParametersRange.FirstCouponType == FirstCouponType.Full) { var firstCouponStartDate = new AdjustableDate { dateAdjustments = dateAdjustments, id = "FullFirstCoupon" }; SetFirstPeriodStartDate(stream, firstCouponStartDate); } // Set payment dates frequency and adjustments // stream.paymentDates.paymentFrequency = PeriodHelper.Parse(legParametersRange.PaymentFrequency).ToFrequency(); stream.paymentDates.paymentDatesAdjustments = BusinessDayAdjustmentsHelper.Create(legParametersRange.PaymentBusinessDayAdjustments, legParametersRange.PaymentCalendar); Calculation calculation = XsdClassesFieldResolver.CalculationPeriodAmountGetCalculation(stream.calculationPeriodAmount); // Set discounting type // calculation.discounting = discounting; // Set notional amount (as the initial value in notional schedule) // SetNotional(calculation, legParametersRange.NotionalAmount, legParametersRange.Currency); // Set fixed rate (as the initial value in fixed-rate schedule) // Schedule fixedRateSchedule = ScheduleHelper.Create(legParametersRange.CouponOrLastResetRate); XsdClassesFieldResolver.CalculationSetFixedRateSchedule(calculation, fixedRateSchedule); // Set the 'day count convention' // calculation.dayCountFraction = DayCountFractionHelper.Parse(legParametersRange.DayCount); // Initial stub // //if (paymentCalendar==null) //{ // paymentCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, stream.paymentDates.paymentDatesAdjustments.businessCenters); //} //ProcessStubs(stream, legParametersRange, paymentCalendar); return(stream); }
private static Trade trade(string counterparty, double notional) { TradeInfo tradeInfo = TradeInfo.builder().counterparty(StandardId.of("cpty", counterparty)).build(); Fra fra = Fra.builder().buySell(BUY).notional(notional).startDate(date(2015, 8, 5)).endDate(date(2015, 11, 5)).paymentDate(AdjustableDate.of(date(2015, 8, 7))).fixedRate(0.25d).index(GBP_LIBOR_3M).build(); return(FraTrade.builder().info(tradeInfo).product(fra).build()); }
/// <summary> /// Sets the date that the payment is made. /// <para> /// This date should normally be a valid business day. /// </para> /// </summary> /// <param name="date"> the new value, not null </param> /// <returns> this, for chaining, not null </returns> public Builder date(AdjustableDate date) { JodaBeanUtils.notNull(date, "date"); this.date_Renamed = date; return(this); }
/// <summary> /// Restricted copy constructor. </summary> /// <param name="beanToCopy"> the bean to copy from, not null </param> internal Builder(BulletPayment beanToCopy) { this.payReceive_Renamed = beanToCopy.PayReceive; this.value_Renamed = beanToCopy.Value; this.date_Renamed = beanToCopy.Date; }
/// <summary> /// /// </summary> /// <param name="logger"></param> /// <param name="cache"></param> /// <param name="paymentCalendar"> </param> /// <param name="capFloorFpML"></param> /// <param name="basePartyReference"></param> /// <param name="forecastRateInterpolation"></param> /// <param name="nameSpace"></param> /// <param name="fixingCalendar"> </param> public CapFloorPricer(ILogger logger, ICoreCache cache, String nameSpace, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, CapFloor capFloorFpML, string basePartyReference, Boolean forecastRateInterpolation) { if (capFloorFpML == null) { return; } //AnalyticsModel = new SimpleIRSwapInstrumentAnalytic(); BusinessCentersResolver.ResolveBusinessCenters(capFloorFpML); ForecastRateInterpolation = forecastRateInterpolation; //We make the assumption that the termination date is the same for all legs.. AdjustableDate adjustableTerminationDate = XsdClassesFieldResolver.CalculationPeriodDatesGetTerminationDate(capFloorFpML.capFloorStream.calculationPeriodDates); if (paymentCalendar == null) { paymentCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, adjustableTerminationDate.dateAdjustments.businessCenters, nameSpace); } RiskMaturityDate = AdjustedDateHelper.ToAdjustedDate(paymentCalendar, adjustableTerminationDate); ProductType = ProductTypeSimpleEnum.CapFloor; PaymentCurrencies = new List <string>(); //Resolve the payer if (capFloorFpML.capFloorStream == null) { return; } var calculation = capFloorFpML.capFloorStream.calculationPeriodAmount.Item as Calculation; var floatingRateCalculation = calculation?.Items[0] as FloatingRateCalculation; if (floatingRateCalculation == null) { return; } if (floatingRateCalculation.capRateSchedule != null) { var schedule = floatingRateCalculation.capRateSchedule[0]; var buyerPartyReference = schedule.buyer.Value; if (buyerPartyReference == PayerReceiverEnum.Receiver) { BuyerPartyReference = capFloorFpML.capFloorStream.receiverPartyReference.href; SellerPartyReference = capFloorFpML.capFloorStream.payerPartyReference.href; } else { BuyerPartyReference = capFloorFpML.capFloorStream.payerPartyReference.href; SellerPartyReference = capFloorFpML.capFloorStream.receiverPartyReference.href; } } if (floatingRateCalculation.capRateSchedule == null && floatingRateCalculation.floorRateSchedule != null) { var schedule = floatingRateCalculation.floorRateSchedule[0]; var buyerPartyReference = schedule.buyer.Value; if (buyerPartyReference == PayerReceiverEnum.Receiver) { BuyerPartyReference = capFloorFpML.capFloorStream.receiverPartyReference.href; SellerPartyReference = capFloorFpML.capFloorStream.payerPartyReference.href; } else { BuyerPartyReference = capFloorFpML.capFloorStream.payerPartyReference.href; SellerPartyReference = capFloorFpML.capFloorStream.receiverPartyReference.href; } } BasePartyBuyer = basePartyReference == BuyerPartyReference;//TODO add in the calendar functionality. //Set the id of the first stream. THe generator requires the flag: BasePartyPayer. var capFloorLeg = new PriceableCapFloorStream(logger, cache, nameSpace, !BasePartyBuyer, capFloorFpML.capFloorStream, ForecastRateInterpolation, fixingCalendar, paymentCalendar); Legs.Add(capFloorLeg); //Add the currencies for the trade pricer. if (!PaymentCurrencies.Contains(capFloorLeg.Currency.Value)) { PaymentCurrencies.Add(capFloorLeg.Currency.Value); } if (capFloorFpML.additionalPayment != null) { AdditionalPayments = PriceableInstrumentsFactory.CreatePriceablePayments(basePartyReference, capFloorFpML.additionalPayment, null); foreach (var payment in capFloorFpML.additionalPayment) { if (!PaymentCurrencies.Contains(payment.paymentAmount.currency.Value)) { PaymentCurrencies.Add(payment.paymentAmount.currency.Value); } } } }