Exemplo n.º 1
0
        public override void setupArguments(IPricingEngineArguments args)
        {
            YoYInflationCapFloor.Arguments arguments = args as YoYInflationCapFloor.Arguments;
            Utils.QL_REQUIRE(arguments != null, () => "wrong argument type");

            int n = yoyLeg_.Count;

            arguments.startDates   = new List <Date>(n);
            arguments.fixingDates  = new List <Date>(n);
            arguments.payDates     = new List <Date>(n);
            arguments.accrualTimes = new List <double>(n);
            arguments.nominals     = new List <double>(n);
            arguments.gearings     = new List <double>(n);
            arguments.capRates     = new List <double?>(n);
            arguments.floorRates   = new List <double?>(n);
            arguments.spreads      = new List <double>(n);

            arguments.type = type_;

            for (int i = 0; i < n; ++i)
            {
                YoYInflationCoupon coupon = yoyLeg_[i] as YoYInflationCoupon;
                Utils.QL_REQUIRE(coupon != null, () => "non-YoYInflationCoupon given");
                arguments.startDates.Add(coupon.accrualStartDate());
                arguments.fixingDates.Add(coupon.fixingDate());
                arguments.payDates.Add(coupon.date());

                // this is passed explicitly for precision
                arguments.accrualTimes.Add(coupon.accrualPeriod());

                arguments.nominals.Add(coupon.nominal());
                double spread  = coupon.spread();
                double gearing = coupon.gearing();
                arguments.gearings.Add(gearing);
                arguments.spreads.Add(spread);

                if (type_ == CapFloorType.Cap || type_ == CapFloorType.Collar)
                {
                    arguments.capRates.Add((capRates_[i] - spread) / gearing);
                }
                else
                {
                    arguments.capRates.Add(null);
                }

                if (type_ == CapFloorType.Floor || type_ == CapFloorType.Collar)
                {
                    arguments.floorRates.Add((floorRates_[i] - spread) / gearing);
                }
                else
                {
                    arguments.floorRates.Add(null);
                }
            }
        }
Exemplo n.º 2
0
        // we may watch an underlying coupon ...
        public CappedFlooredYoYInflationCoupon(YoYInflationCoupon underlying,
                                               double?cap   = null,
                                               double?floor = null)
            : base(underlying.date(),
                   underlying.nominal(),
                   underlying.accrualStartDate(),
                   underlying.accrualEndDate(),
                   underlying.fixingDays(),
                   underlying.yoyIndex(),
                   underlying.observationLag(),
                   underlying.dayCounter(),
                   underlying.gearing(),
                   underlying.spread(),
                   underlying.referencePeriodStart,
                   underlying.referencePeriodEnd)

        {
            underlying_ = underlying;
            isFloored_  = false;
            isCapped_   = false;
            setCommon(cap, floor);
            underlying.registerWith(update);
        }