/// <summary>
        /// Gets a dates schedule.
        /// </summary>
        /// <param name="metaScheduleDefinitionRange"></param>
        /// <param name="startDate"></param>
        /// <param name="calendar"></param>
        /// <param name="businessCentreAsString">This should not be blank.</param>
        /// <param name="businessDayAdjustment">This should not be blank.</param>
        /// <returns></returns>
        public static DateTime[] GetDatesSchedule(List <ThreeStringsRangeItem> metaScheduleDefinitionRange,
                                                  DateTime startDate,
                                                  IBusinessCalendar calendar,
                                                  string businessCentreAsString,
                                                  string businessDayAdjustment)
        {
            var             metaScheduleDefinition = metaScheduleDefinitionRange.Select(item => new Triplet <Period, Period, RollConventionEnum>(PeriodHelper.Parse(item.Value1), PeriodHelper.Parse(item.Value2), RollConventionEnumHelper.Parse(item.Value3))).ToList();
            List <DateTime> resultAsListOfDates;

            if (calendar == null)
            {
                resultAsListOfDates = DatesMetaSchedule.GetUnadjustedDates(metaScheduleDefinition, startDate);
            }
            if (String.IsNullOrEmpty(businessCentreAsString) | String.IsNullOrEmpty(businessDayAdjustment))
            {
                resultAsListOfDates = DatesMetaSchedule.GetUnadjustedDates(metaScheduleDefinition, startDate);
            }
            else
            {
                var businessDayAdjustments = BusinessDayAdjustmentsHelper.Create(businessDayAdjustment, businessCentreAsString);
                resultAsListOfDates = GetAdjustedDates(metaScheduleDefinition, startDate, businessDayAdjustments, calendar);
            }
            var result = resultAsListOfDates.ToArray();

            return(result);
        }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PriceableSimpleIRSwap"/> class.
 /// </summary>
 /// <param name="amount">The amount.</param>
 /// <param name="discountingType">The discounting type.</param>
 /// <param name="effectiveDate">The base date.</param>
 /// <param name="tenor">The maturity tenor.</param>
 /// <param name="fxdDayFraction">The fixed leg day fraction.</param>
 /// <param name="businessCenters">The payment business centers.</param>
 /// <param name="businessDayConvention">The payment business day convention.</param>
 /// <param name="fxdFrequency">The business day adjustments.</param>
 /// <param name="underlyingRateIndex">Index of the rate.</param>
 /// <param name="fixedRate">The fixed rate.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="baseDate">The base date.</param>
 /// <param name="currency">THe currency.</param>
 /// <param name="fixingCalendar">The fixingCalendar.</param>
 /// <param name="paymentCalendar">The paymentCalendar.</param>
 public PriceableSimpleIRSwap(string id, DateTime baseDate, string currency,
                              decimal amount, DiscountingTypeEnum?discountingType,
                              DateTime effectiveDate, string tenor, string fxdDayFraction,
                              string businessCenters, string businessDayConvention, string fxdFrequency,
                              RateIndex underlyingRateIndex, IBusinessCalendar fixingCalendar, IBusinessCalendar paymentCalendar, BasicQuotation fixedRate)
     : this(baseDate, SimpleIrsHelper.Parse(id, currency, fxdDayFraction, tenor, fxdFrequency, id), effectiveDate,
            CalculationFactory.CreateFixed(fixedRate.value, MoneyHelper.GetAmount(amount, currency),
                                           DayCountFractionHelper.Parse(fxdDayFraction), discountingType),
            BusinessDayAdjustmentsHelper.Create(businessDayConvention, businessCenters), underlyingRateIndex, fixingCalendar, paymentCalendar, fixedRate)
 {
 }
        public List <DateTime> BuildDates(ILogger logger, ICoreCache cache, String nameSpace, BillSwapPricerDatesRange billSwapPricerDatesRange, IBusinessCalendar paymentCalendar)
        {
            CalculationPeriodFrequency frequency   = CalculationPeriodFrequencyHelper.Parse(billSwapPricerDatesRange.RollFrequency, billSwapPricerDatesRange.RollConvention);
            StubPeriodTypeEnum?        initialStub = null;

            if (!String.IsNullOrEmpty(billSwapPricerDatesRange.InitialStubPeriod))
            {
                initialStub = EnumHelper.Parse <StubPeriodTypeEnum>(billSwapPricerDatesRange.InitialStubPeriod);
            }
            StubPeriodTypeEnum?finalStub = null;

            if (!String.IsNullOrEmpty(billSwapPricerDatesRange.FinalStubPeriod))
            {
                finalStub = EnumHelper.Parse <StubPeriodTypeEnum>(billSwapPricerDatesRange.FinalStubPeriod);
            }
            //BusinessDayAdjustments adjustments = BusinessDayAdjustmentsHelper.Create(BusinessDayConventionEnum.NONE, "");
            //if (paymentCalendar == null)
            //{
            //    paymentCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, adjustments.businessCenters);//Make sure this builds a valid calendar!
            //}
            BusinessDayAdjustments calculationPeriodDayAdjustments = BusinessDayAdjustmentsHelper.Create(billSwapPricerDatesRange.BusinessDayConvention, billSwapPricerDatesRange.Calendar);

            if (paymentCalendar == null)
            {
                paymentCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, calculationPeriodDayAdjustments.businessCenters, nameSpace);
            }
            CalculationPeriodsPrincipalExchangesAndStubs result = CalculationPeriodGenerator.GenerateAdjustedCalculationPeriods(
                billSwapPricerDatesRange.StartDate,
                billSwapPricerDatesRange.EndDate,
                billSwapPricerDatesRange.FirstRegularPeriodStartDate,
                frequency,
                calculationPeriodDayAdjustments,
                initialStub,
                finalStub,
                paymentCalendar
                );

            foreach (CalculationPeriod regularCalculationPeriod in result.GetRegularAndStubPeriods())
            {
                // Adjust both startDate & endDate of period
                //
                CalculationPeriodHelper.SetAdjustedDates(regularCalculationPeriod,
                                                         AdjustedDateHelper.ToAdjustedDate(paymentCalendar, regularCalculationPeriod.unadjustedStartDate, calculationPeriodDayAdjustments),
                                                         AdjustedDateHelper.ToAdjustedDate(paymentCalendar, regularCalculationPeriod.unadjustedEndDate, calculationPeriodDayAdjustments));
            }
            var listResult = result.GetRegularAndStubPeriods().Select(regularCalculationPeriod => regularCalculationPeriod.adjustedStartDate).ToList();

            listResult.Add(result.GetRegularAndStubPeriods()[result.GetRegularAndStubPeriods().Count - 1].adjustedEndDate);
            return(listResult);
        }
        /// <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>
        ///</summary>
        ///<param name="termsRange"></param>
        ///<param name="metaScheduleDefinitionRange"></param>
        ///<param name="paymentCalendar"></param>
        ///<returns></returns>
        public static List <AmortisingResultItem> GenerateCashflowSchedule(BillsSwapPricer2TermsRange termsRange,
                                                                           List <MetaScheduleRangeItem> metaScheduleDefinitionRange, IBusinessCalendar paymentCalendar)
        {
            RollConventionEnum     rollConventionEnum     = RollConventionEnumHelper.Parse(termsRange.RollDay);
            BusinessDayAdjustments businessDayAdjustments = BusinessDayAdjustmentsHelper.Create(termsRange.DateRollConvention, termsRange.Calendar);
            bool            backwardGeneration            = (termsRange.BuildDates.ToLower() == "backward");
            List <DateTime> adjustedDatesResult;
            List <DateTime> unadjustedDatesResult;

            if (termsRange.RollFrequency.ToLower().Contains("custom"))
            {
                var rollsMetaSchedule = metaScheduleDefinitionRange.Select(item => new MetaScheduleItem
                {
                    RollFrequency = PeriodHelper.Parse(item.RollFrequency), Period = PeriodHelper.Parse(item.Period), RollConvention = RollConventionEnumHelper.Parse(item.RollConvention)
                }).ToList();
                unadjustedDatesResult = DatesMetaSchedule.GetUnadjustedDates3(termsRange.StartDate, termsRange.EndDate,
                                                                              rollsMetaSchedule, backwardGeneration);
                adjustedDatesResult = AdjustedDatesMetaSchedule.GetAdjustedDates3(termsRange.StartDate, termsRange.EndDate,
                                                                                  rollsMetaSchedule, backwardGeneration, businessDayAdjustments, paymentCalendar);
            }
            else
            {
                Period interval = PeriodHelper.Parse(termsRange.RollFrequency);
                unadjustedDatesResult = DatesMetaSchedule.GetUnadjustedDates2(termsRange.StartDate, termsRange.EndDate,
                                                                              interval, rollConventionEnum, backwardGeneration);
                adjustedDatesResult = AdjustedDatesMetaSchedule.GetAdjustedDates2(termsRange.StartDate, termsRange.EndDate,
                                                                                  interval, rollConventionEnum, backwardGeneration, businessDayAdjustments, paymentCalendar);
            }
            var result = new List <AmortisingResultItem>();

            for (int i = 0; i < adjustedDatesResult.Count; i++)
            {
                DateTime adjustedTime         = adjustedDatesResult[i];
                DateTime unadjustedTime       = unadjustedDatesResult[i];
                var      amortisingResultItem = new AmortisingResultItem
                {
                    WasRolled        = (adjustedTime == unadjustedTime) ? "No" : "Yes",
                    RollDate         = adjustedTime,
                    AmortisingAmount = 0,
                    OutstandingValue = termsRange.FaceValue
                };
                result.Add(amortisingResultItem);
            }
            return(result);
        }
        /// <summary>
        /// Gets the reset date.
        /// </summary>
        /// <param name="resetRelativeTo">The reset relative to.</param>
        /// <returns></returns>
        /// <param name="fixingDateRelativeOffset"></param>
        private DateTime GetResetDate(ResetRelativeToEnum resetRelativeTo, RelativeDateOffset fixingDateRelativeOffset)
        {
            var resetDate = AccrualStartDate;

            switch (resetRelativeTo)
            {
            case ResetRelativeToEnum.CalculationPeriodEndDate:
                resetDate = AccrualEndDate;
                break;
            }

            var interval = (Period)fixingDateRelativeOffset;

            if (fixingDateRelativeOffset != null)
            {
                var adjustment = BusinessDayAdjustmentsHelper.Create(fixingDateRelativeOffset.businessDayConvention, BusinessCentersHelper.BusinessCentersString(fixingDateRelativeOffset.businessCenters.businessCenter));
                resetDate = AdjustedDateHelper.ToAdjustedDate(FixingCalendar, resetDate, adjustment, OffsetHelper.FromInterval(interval, fixingDateRelativeOffset.dayType));
            }
            return(resetDate);
        }
        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 InterestRateStream GenerateCapFloorStreamDefinition(CapFloorLegParametersRange legParametersRange)
        {
            Discounting        discounting = null;
            InterestRateStream stream;

            if (legParametersRange.DiscountingType != null && legParametersRange.DiscountingType.ToUpper() != "NONE")
            {
                discounting = new Discounting
                {
                    discountingType =
                        EnumHelper.Parse <DiscountingTypeEnum>(legParametersRange.DiscountingType)
                };
                stream = InterestRateStreamFactory.CreateFloatingRateStream(DiscountingTypeToPayRelativeTo(discounting.discountingType));
            }
            // Create the stream object
            //
            else
            {
                stream = InterestRateStreamFactory.CreateFloatingRateStream(DiscountingTypeToPayRelativeTo(null));
            }
            // Set effective and termination dates of the stream.
            //
            SetEffectiveAndTerminationDates(stream, legParametersRange.EffectiveDate, legParametersRange.MaturityDate, legParametersRange.PaymentBusinessDayAdjustments, legParametersRange.PaymentCalendar);
            // Adjusted or unadjusted swap
            //
            stream.calculationPeriodDates.calculationPeriodDatesAdjustments = AdjustedType.Adjusted != legParametersRange.AdjustedType ? BusinessDayAdjustmentsHelper.Create(BusinessDayConventionEnum.NONE, legParametersRange.PaymentCalendar) : BusinessDayAdjustmentsHelper.Create(legParametersRange.PaymentBusinessDayAdjustments, legParametersRange.PaymentCalendar);
            stream.calculationPeriodDates.calculationPeriodFrequency        = CalculationPeriodFrequencyHelper.Parse(legParametersRange.PaymentFrequency, legParametersRange.RollConvention);
            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.ForecastIndexName;
            FloatingRateCalculation floatingRateCalculation = FloatingRateCalculationFactory.Create(indexName, indexTenor, legParametersRange.FloatingRateSpread);

            XsdClassesFieldResolver.CalculationSetFloatingRateCalculation(calculation, floatingRateCalculation);
            if (legParametersRange.CapOrFloor == CapFloorType.Cap)
            {
                floatingRateCalculation.capRateSchedule = new[] { new StrikeSchedule() };
                floatingRateCalculation.capRateSchedule[0].initialValue = legParametersRange.StrikeRate;
                floatingRateCalculation.capRateSchedule[0].buyer        = new IdentifiedPayerReceiver {
                    Value = PayerReceiverEnum.Receiver
                };
                floatingRateCalculation.capRateSchedule[0].seller = new IdentifiedPayerReceiver {
                    Value = PayerReceiverEnum.Payer
                };
            }
            else
            {
                floatingRateCalculation.floorRateSchedule = new[] { new StrikeSchedule() };
                floatingRateCalculation.floorRateSchedule[0].initialValue = legParametersRange.StrikeRate;
                floatingRateCalculation.floorRateSchedule[0].buyer        = new IdentifiedPayerReceiver {
                    Value = PayerReceiverEnum.Receiver
                };
                floatingRateCalculation.floorRateSchedule[0].seller = new IdentifiedPayerReceiver {
                    Value = PayerReceiverEnum.Payer
                };
            }
            // Set day count convention
            //
            calculation.dayCountFraction = DayCountFractionHelper.Parse(legParametersRange.DayCount);
            return(stream);
        }
        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);
        }