//private static void ProcessStubs(InterestRateStream stream, SwapLegParametersRange_Old swapTermParametersRange, IBusinessCalendar paymentCalendar)
        //{
        //    //bool isFullFirstCoupon = swapTermParametersRange.FirstCouponType == FirstCouponType.Full?true:false;
        //    DateTime adjustedEffectiveDate = AdjustedDateHelper.ToAdjustedDate(paymentCalendar, XsdClassesFieldResolver.CalculationPeriodDates_GetEffectiveDate(stream.calculationPeriodDates));
        //    DateTime adjustedTerminationDate = AdjustedDateHelper.ToAdjustedDate(paymentCalendar, XsdClassesFieldResolver.CalculationPeriodDates_GetTerminationDate(stream.calculationPeriodDates));
        //    StubPeriodTypeEnum? initialStubType = null;
        //    if (!string.IsNullOrEmpty(swapTermParametersRange.InitialStubType))
        //    {
        //        initialStubType = EnumHelper.Parse<StubPeriodTypeEnum>(swapTermParametersRange.InitialStubType);
        //    }
        //    StubPeriodTypeEnum? finalStubType = null;
        //    if (!string.IsNullOrEmpty(swapTermParametersRange.FinalStubType))
        //    {
        //        finalStubType = EnumHelper.Parse<StubPeriodTypeEnum>(swapTermParametersRange.FinalStubType);
        //    }
        //    //Only calculate a stub if required i.e.
        //    //If a FirsteRegularPeriod is specified -> Roll forward
        //    //If a lastRegularePeriod is specified --> Roll Backwards
        //    //If intialstub is not null
        //    //if finalStubType is not null
        //    //Otherwise, check if the maturity - effective date is modulo the frequency.
        //    //If yes, there is no stub.
        //    var periods = CalculationPeriodGenerator.GenerateAdjustedCalculationPeriods(adjustedEffectiveDate,
        //                                                                                adjustedTerminationDate,
        //                                                                                swapTermParametersRange.FirstRegularPeriodStartDate,
        //                                                                                stream.calculationPeriodDates.calculationPeriodFrequency,
        //                                                                                stream.calculationPeriodDates.calculationPeriodDatesAdjustments,
        //                                                                                initialStubType,
        //                                                                                finalStubType,
        //                                                                                paymentCalendar);
        //    //var periods = CalculationPeriodGenerator.GenerateAdjustedCalculationPeriods(adjustedEffectiveDate,
        //    //                                                                            adjustedTerminationDate,
        //    //                                                                            stream.calculationPeriodDates.firstRegularPeriodStartDate,
        //    //                                                                            stream.calculationPeriodDates.lastRegularPeriodEndDate,
        //    //                                                                            stream.calculationPeriodDates.calculationPeriodFrequency,
        //    //                                                                            stream.calculationPeriodDates.calculationPeriodDatesAdjustments,
        //    //                                                                            paymentCalendar);
        //    if (!stream.calculationPeriodDates.firstRegularPeriodStartDateSpecified && periods.HasInitialStub)
        //    {
        //        stream.calculationPeriodDates.firstRegularPeriodStartDate = periods.FirstRegularPeriodUnadjustedStartDate;
        //        stream.calculationPeriodDates.firstRegularPeriodStartDateSpecified = true;
        //    }
        //    if (!stream.calculationPeriodDates.lastRegularPeriodEndDateSpecified && periods.HasFinalStub)
        //    {
        //        stream.calculationPeriodDates.lastRegularPeriodEndDate = periods.LastRegularPeriodUnadjustedEndDate;
        //        stream.calculationPeriodDates.lastRegularPeriodEndDateSpecified = true;
        //    }
        //}

        private static void SetNotional(Calculation calculation,
                                        decimal amount,
                                        string currencyAsString)
        {
            Money    notionalAsMoney  = MoneyHelper.GetAmount(amount, currencyAsString);
            Notional notionalSchedule = NotionalFactory.Create(notionalAsMoney);

            XsdClassesFieldResolver.CalculationSetNotionalSchedule(calculation, notionalSchedule);
        }
Exemplo n.º 2
0
        public static Calculation CreateFloating(decimal fixedRate, Money notional, FloatingRateIndex floatingRateIndex, Period tenor,
                                                 DayCountFraction dayCountFraction, DiscountingTypeEnum discountingType)
        {
            var calculation = new Calculation
            {
                Item = NotionalFactory.Create(notional),
                compoundingMethod          = CompoundingMethodEnum.None,
                compoundingMethodSpecified = true,
                dayCountFraction           = dayCountFraction,
                discounting =
                    DiscountingHelper.Create(fixedRate, dayCountFraction, discountingType),
                Items = new object[] { FloatingRateCalculationHelper.CreateFloating(floatingRateIndex, tenor) }
            };

            return(calculation);
        }
Exemplo n.º 3
0
        public static Calculation CreateFixed(decimal fixedRate, decimal discountRate, Money notional,
                                              CompoundingMethodEnum compoundingMethod, DayCountFraction dayCountFraction, DiscountingTypeEnum discountingType)
        {
            var calculation = new Calculation
            {
                Item = NotionalFactory.Create(notional),
                compoundingMethod          = compoundingMethod,
                compoundingMethodSpecified = true,
                dayCountFraction           = dayCountFraction,
                discounting =
                    DiscountingHelper.Create(discountRate, dayCountFraction,
                                             discountingType),
                Items = new object[] { FixedRateScheduleHelper.Create(fixedRate) }
            };

            return(calculation);
        }
Exemplo n.º 4
0
        public static Calculation CreateFloating(Money notional, FloatingRateIndex floatingRateIndex, Period tenor, DayCountFraction dayCountFraction, DiscountingTypeEnum?discountingType)
        {
            var discounting = discountingType != null
                                  ? DiscountingHelper.Create(null, dayCountFraction, (DiscountingTypeEnum)discountingType)
                                  : null;

            var calculation = new Calculation
            {
                Items                      = new object[] { NotionalFactory.Create(notional) },
                compoundingMethod          = CompoundingMethodEnum.None,
                compoundingMethodSpecified = true,
                dayCountFraction           = dayCountFraction,
                discounting                = discounting,
                Items1                     = new object[] { FloatingRateCalculationHelper.CreateFloating(floatingRateIndex, tenor) }
            };

            return(calculation);
        }
Exemplo n.º 5
0
        public static Calculation CreateFixed(decimal fixedRate, NonNegativeAmountSchedule notionalSchedule,
                                              DayCountFraction dayCountFraction, DiscountingTypeEnum?discountingType)
        {
            var discounting = discountingType != null
                                  ? DiscountingHelper.Create(fixedRate, dayCountFraction, (DiscountingTypeEnum)discountingType)
                                  : null;

            var calculation = new Calculation
            {
                Item = NotionalFactory.Create(notionalSchedule),
                compoundingMethod          = CompoundingMethodEnum.None,
                compoundingMethodSpecified = true,
                dayCountFraction           = dayCountFraction,
                discounting = discounting,
                Items       = new object[] { FixedRateScheduleHelper.Create(fixedRate) }
            };

            return(calculation);
        }
Exemplo n.º 6
0
        public static Calculation CreateFloating(Money notional, FloatingRateIndex floatingRateIndex, Period tenor, DayCountFraction dayCountFraction, DiscountingTypeEnum discountingType)
        {
            var calculation = new Calculation
            {
                Items                      = new object[] { NotionalFactory.Create(notional) },
                compoundingMethod          = CompoundingMethodEnum.None,
                compoundingMethodSpecified = true,
                dayCountFraction           = dayCountFraction
            };
            var discounting = new Discounting
            {
                discountingType = discountingType,
                discountRateDayCountFraction = dayCountFraction
            };

            calculation.discounting = discounting;
            calculation.Items       = new object[] { FloatingRateCalculationHelper.CreateFloating(floatingRateIndex, tenor) };
            return(calculation);
        }