/// <summary>
        ///
        /// </summary>
        /// <param name="capFloorLeg"></param>
        /// <param name="fixingCalendar"></param>
        /// <param name="paymentCalendar"></param>
        /// <param name="spreadSchedule"></param>
        /// <param name="capOrFloorSchedule"></param>
        /// <param name="notionalSchedule"></param>
        /// <returns></returns>
        public static CapFloor GenerateDefinitionCashflows(IBusinessCalendar fixingCalendar,
                                                           IBusinessCalendar paymentCalendar,
                                                           CapFloorLegParametersRange_Old capFloorLeg,
                                                           Schedule spreadSchedule,
                                                           Schedule capOrFloorSchedule,
                                                           NonNegativeAmountSchedule notionalSchedule)

        {
            CapFloor capFloor = GenerateDefiniton(capFloorLeg, spreadSchedule, capOrFloorSchedule, notionalSchedule);

            if (null != spreadSchedule)
            {
                InterestRateStreamParametricDefinitionGenerator.SetSpreadSchedule(capFloor.capFloorStream, spreadSchedule);
            }
            if (null != notionalSchedule)
            {
                InterestRateStreamParametricDefinitionGenerator.SetNotionalSchedule(capFloor.capFloorStream, notionalSchedule);
            }
            if (null != capOrFloorSchedule)
            {
                if (capFloorLeg.CapOrFloor == CapFloorType.Cap)
                {
                    InterestRateStreamParametricDefinitionGenerator.SetCapRateSchedule(capFloor.capFloorStream, capOrFloorSchedule, true);
                }
                else
                {
                    InterestRateStreamParametricDefinitionGenerator.SetFloorRateSchedule(capFloor.capFloorStream, capOrFloorSchedule, true);
                }
            }
            capFloor.capFloorStream.cashflows = FixedAndFloatingRateStreamCashflowGenerator.GetCashflows(capFloor.capFloorStream, fixingCalendar, paymentCalendar);
            return(capFloor);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="cache"></param>
        /// <param name="capFloorLeg"></param>
        /// <param name="nameSpace"></param>
        /// <param name="fixingCalendar"></param>
        /// <param name="paymentCalendar"></param>
        /// <param name="spreadSchedule"></param>
        /// <param name="capOrFloorSchedule"></param>
        /// <param name="notionalSchedule"></param>
        /// <returns></returns>
        public static CapFloor GenerateDefinitionCashflows(ILogger logger, ICoreCache cache,
                                                           string nameSpace,
                                                           IBusinessCalendar fixingCalendar,
                                                           IBusinessCalendar paymentCalendar,
                                                           CapFloorLegParametersRange capFloorLeg,
                                                           Schedule spreadSchedule,
                                                           Schedule capOrFloorSchedule,
                                                           NonNegativeAmountSchedule notionalSchedule)
        {
            if (paymentCalendar == null)
            {
                if (!string.IsNullOrEmpty(capFloorLeg.PaymentCalendar))
                {
                    var payCalendar = BusinessCentersHelper.Parse(capFloorLeg.PaymentCalendar);
                    paymentCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, payCalendar, nameSpace);
                }
            }
            if (fixingCalendar == null)
            {
                if (!string.IsNullOrEmpty(capFloorLeg.FixingCalendar))
                {
                    var fixCalendar = BusinessCentersHelper.Parse(capFloorLeg.FixingCalendar);
                    fixingCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, fixCalendar, nameSpace);
                }
            }
            CapFloor capFloor = GenerateDefiniton(capFloorLeg, spreadSchedule, capOrFloorSchedule, notionalSchedule);

            if (null != spreadSchedule)
            {
                InterestRateStreamParametricDefinitionGenerator.SetSpreadSchedule(capFloor.capFloorStream, spreadSchedule);
            }
            if (null != notionalSchedule)
            {
                InterestRateStreamParametricDefinitionGenerator.SetNotionalSchedule(capFloor.capFloorStream, notionalSchedule);
            }
            if (null != capOrFloorSchedule)
            {
                if (capFloorLeg.CapOrFloor == CapFloorType.Cap)
                {
                    InterestRateStreamParametricDefinitionGenerator.SetCapRateSchedule(capFloor.capFloorStream, capOrFloorSchedule, true);
                }
                else
                {
                    InterestRateStreamParametricDefinitionGenerator.SetFloorRateSchedule(capFloor.capFloorStream, capOrFloorSchedule, true);
                }
            }
            capFloor.capFloorStream.cashflows = FixedAndFloatingRateStreamCashflowGenerator.GetCashflows(capFloor.capFloorStream, fixingCalendar, paymentCalendar);
            return(capFloor);
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="cache"></param>
        /// <param name="nameSpace"></param>
        /// <param name="leg1Parameters"></param>
        /// <param name="leg1Calendars"></param>
        /// <param name="leg2Parameters"></param>
        /// <param name="leg2Calendars"></param>
        /// <param name="fixedRateSchedule"></param>
        /// <param name="spreadSchedule"></param>
        /// <param name="notionalSchedule"></param>
        /// <returns></returns>
        public static Swap GenerateDefinitionCashflows(ILogger logger,
                                                       ICoreCache cache, string nameSpace,
                                                       SwapLegParametersRange leg1Parameters,
                                                       Pair <IBusinessCalendar, IBusinessCalendar> leg1Calendars,
                                                       SwapLegParametersRange leg2Parameters,
                                                       Pair <IBusinessCalendar, IBusinessCalendar> leg2Calendars,
                                                       Schedule fixedRateSchedule,
                                                       Schedule spreadSchedule,
                                                       NonNegativeAmountSchedule notionalSchedule)
        {
            IBusinessCalendar leg1PaymentCalendar = null;
            IBusinessCalendar leg2PaymentCalendar = null;
            IBusinessCalendar leg1FixingCalendar  = null;
            IBusinessCalendar leg2FixingCalendar  = null;

            if (leg1Calendars != null)
            {
                leg1FixingCalendar  = leg1Calendars.First;
                leg1PaymentCalendar = leg1Calendars.Second;
            }
            else
            {
                if (!string.IsNullOrEmpty(leg1Parameters.PaymentCalendar))
                {
                    var payCalendar = BusinessCentersHelper.Parse(leg1Parameters.PaymentCalendar);
                    leg1PaymentCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, payCalendar, nameSpace);
                    leg1FixingCalendar  = leg1PaymentCalendar;
                }
                if (!string.IsNullOrEmpty(leg1Parameters.FixingCalendar))
                {
                    var fixingCalendar = BusinessCentersHelper.Parse(leg1Parameters.FixingCalendar);
                    leg1FixingCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, fixingCalendar, nameSpace);
                }
            }
            if (leg2Calendars != null)
            {
                leg2FixingCalendar  = leg2Calendars.First;
                leg2PaymentCalendar = leg2Calendars.Second;
            }
            else
            {
                if (!string.IsNullOrEmpty(leg2Parameters.PaymentCalendar))
                {
                    var payCalendar = BusinessCentersHelper.Parse(leg2Parameters.PaymentCalendar);
                    leg2PaymentCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, payCalendar, nameSpace);
                    leg2FixingCalendar  = leg2PaymentCalendar;
                }
                if (!string.IsNullOrEmpty(leg2Parameters.FixingCalendar))
                {
                    var fixingCalendar = BusinessCentersHelper.Parse(leg2Parameters.FixingCalendar);
                    leg2FixingCalendar = BusinessCenterHelper.ToBusinessCalendar(cache, fixingCalendar, nameSpace);
                }
            }
            var swap = GenerateDefiniton(leg1Parameters, leg2Parameters);
            InterestRateStream stream1 = swap.swapStream[0];
            InterestRateStream stream2 = swap.swapStream[1];

            if (null != fixedRateSchedule)
            {
                //  Set FixedRateSchedule (if this is a fixed leg)
                //
                if (leg1Parameters.IsFixedLegType())
                {
                    InterestRateStreamParametricDefinitionGenerator.SetFixedRateSchedule(stream1, fixedRateSchedule);
                }
                //  Set FixedRateSchedule (if this is a fixed leg)
                //
                if (leg2Parameters.IsFixedLegType())
                {
                    InterestRateStreamParametricDefinitionGenerator.SetFixedRateSchedule(stream2, fixedRateSchedule);
                }
            }
            if (null != spreadSchedule) //for float legs only
            {
                if (leg1Parameters.IsFloatingLegType())
                {
                    InterestRateStreamParametricDefinitionGenerator.SetSpreadSchedule(stream1, spreadSchedule);
                }
                if (leg2Parameters.IsFloatingLegType())
                {
                    InterestRateStreamParametricDefinitionGenerator.SetSpreadSchedule(stream2, spreadSchedule);
                }
            }
            if (null != notionalSchedule)
            {
                //  Set notional schedule
                //
                InterestRateStreamParametricDefinitionGenerator.SetNotionalSchedule(stream1, notionalSchedule);
                InterestRateStreamParametricDefinitionGenerator.SetNotionalSchedule(stream2, notionalSchedule);
            }
            stream1.cashflows = FixedAndFloatingRateStreamCashflowGenerator.GetCashflows(stream1, leg1FixingCalendar, leg1PaymentCalendar);
            stream2.cashflows = FixedAndFloatingRateStreamCashflowGenerator.GetCashflows(stream2, leg2FixingCalendar, leg2PaymentCalendar);
            return(swap);
        }