Example #1
0
        public override void setupArguments(IPricingEngineArguments args)
        {
            base.setupArguments(args);

            VanillaSwap.Arguments arguments = args as VanillaSwap.Arguments;
            if (arguments == null) // it's a swap engine...
            {
                return;
            }

            arguments.type    = type_;
            arguments.nominal = nominal_;

            List <CashFlow> fixedCoupons = fixedLeg();

            arguments.fixedResetDates = new InitializedList <Date>(fixedCoupons.Count);
            arguments.fixedPayDates   = new InitializedList <Date>(fixedCoupons.Count);
            arguments.fixedCoupons    = new InitializedList <double>(fixedCoupons.Count);

            for (int i = 0; i < fixedCoupons.Count; ++i)
            {
                FixedRateCoupon coupon = (FixedRateCoupon)fixedCoupons[i];

                arguments.fixedPayDates[i]   = coupon.date();
                arguments.fixedResetDates[i] = coupon.accrualStartDate();
                arguments.fixedCoupons[i]    = coupon.amount();
            }

            List <CashFlow> floatingCoupons = floatingLeg();

            arguments.floatingResetDates   = new InitializedList <Date>(floatingCoupons.Count);
            arguments.floatingPayDates     = new InitializedList <Date>(floatingCoupons.Count);
            arguments.floatingFixingDates  = new InitializedList <Date>(floatingCoupons.Count);
            arguments.floatingAccrualTimes = new InitializedList <double>(floatingCoupons.Count);
            arguments.floatingSpreads      = new InitializedList <double>(floatingCoupons.Count);
            arguments.floatingCoupons      = new InitializedList <double>(floatingCoupons.Count);
            for (int i = 0; i < floatingCoupons.Count; ++i)
            {
                IborCoupon coupon = (IborCoupon)floatingCoupons[i];

                arguments.floatingResetDates[i] = coupon.accrualStartDate();
                arguments.floatingPayDates[i]   = coupon.date();

                arguments.floatingFixingDates[i]  = coupon.fixingDate();
                arguments.floatingAccrualTimes[i] = coupon.accrualPeriod();
                arguments.floatingSpreads[i]      = coupon.spread();
                try
                {
                    arguments.floatingCoupons[i] = coupon.amount();
                }
                catch
                {
                    arguments.floatingCoupons[i] = default(double);
                }
            }
        }
Example #2
0
        public override void setupArguments(IPricingEngineArguments args)
        {
            base.setupArguments(args);

            BasisSwap.Arguments arguments = args as BasisSwap.Arguments;
            if (arguments == null) // it's a swap engine...
            {
                return;
            }

            arguments.type    = type_;
            arguments.nominal = nominal_;


            List <CashFlow> floating1Coupons = floating1Leg();

            arguments.floating1ResetDates   = new InitializedList <Date>(floating1Coupons.Count);
            arguments.floating1PayDates     = new InitializedList <Date>(floating1Coupons.Count);
            arguments.floating1FixingDates  = new InitializedList <Date>(floating1Coupons.Count);
            arguments.floating1AccrualTimes = new InitializedList <double>(floating1Coupons.Count);
            arguments.floating1Spreads      = new InitializedList <double>(floating1Coupons.Count);
            arguments.floating1Coupons      = new InitializedList <double>(floating1Coupons.Count);
            for (int i = 0; i < floating1Coupons.Count; ++i)
            {
                IborCoupon coupon = (IborCoupon)floating1Coupons[i];

                arguments.floating1ResetDates[i] = coupon.accrualStartDate();
                arguments.floating1PayDates[i]   = coupon.date();

                arguments.floating1FixingDates[i]  = coupon.fixingDate();
                arguments.floating1AccrualTimes[i] = coupon.accrualPeriod();
                arguments.floating1Spreads[i]      = coupon.spread();
                try
                {
                    arguments.floating1Coupons[i] = coupon.amount();
                }
                catch
                {
                    arguments.floating1Coupons[i] = default(double);
                }
            }

            List <CashFlow> floating2Coupons = floating2Leg();

            arguments.floating2ResetDates   = new InitializedList <Date>(floating2Coupons.Count);
            arguments.floating2PayDates     = new InitializedList <Date>(floating2Coupons.Count);
            arguments.floating2FixingDates  = new InitializedList <Date>(floating2Coupons.Count);
            arguments.floating2AccrualTimes = new InitializedList <double>(floating2Coupons.Count);
            arguments.floating2Spreads      = new InitializedList <double>(floating2Coupons.Count);
            arguments.floating2Coupons      = new InitializedList <double>(floating2Coupons.Count);
            for (int i = 0; i < floating2Coupons.Count; ++i)
            {
                IborCoupon coupon = (IborCoupon)floating2Coupons[i];

                arguments.floating2ResetDates[i] = coupon.accrualStartDate();
                arguments.floating2PayDates[i]   = coupon.date();

                arguments.floating2FixingDates[i]  = coupon.fixingDate();
                arguments.floating2AccrualTimes[i] = coupon.accrualPeriod();
                arguments.floating2Spreads[i]      = coupon.spread();
                try
                {
                    arguments.floating2Coupons[i] = coupon.amount();
                }
                catch
                {
                    arguments.floating2Coupons[i] = default(double);
                }
            }
        }