Exemple #1
0
        public BMASwap(Type type, double nominal,
                       // Libor leg
                       Schedule liborSchedule, double liborFraction, double liborSpread, IborIndex liborIndex, DayCounter liborDayCount,
                       // BMA leg
                       Schedule bmaSchedule, BMAIndex bmaIndex, DayCounter bmaDayCount)
            : base(2)
        {
            type_          = type;
            nominal_       = nominal;
            liborFraction_ = liborFraction;
            liborSpread_   = liborSpread;

            BusinessDayConvention convention = liborSchedule.businessDayConvention();

            legs_[0] = new IborLeg(liborSchedule, liborIndex)
                       .withPaymentDayCounter(liborDayCount)
                       .withFixingDays(liborIndex.fixingDays())
                       .withGearings(liborFraction)
                       .withSpreads(liborSpread)
                       .withNotionals(nominal)
                       .withPaymentAdjustment(convention);

            legs_[1] = new AverageBMALeg(bmaSchedule, bmaIndex)
                       .withPaymentDayCounter(bmaDayCount)
                       .withNotionals(nominal)
                       .withPaymentAdjustment(bmaSchedule.businessDayConvention());

            for (int j = 0; j < 2; ++j)
            {
                for (int i = 0; i < legs_[j].Count; i++)
                {
                    legs_[j][i].registerWith(update);
                }
            }

            switch (type_)
            {
            case Type.Payer:
                payer_[0] = +1.0;
                payer_[1] = -1.0;
                break;

            case Type.Receiver:
                payer_[0] = -1.0;
                payer_[1] = +1.0;
                break;

            default:
                Utils.QL_FAIL("Unknown BMA-swap type");
                break;
            }
        }
Exemple #2
0
        public BMASwap(Type type, double nominal,
                // Libor leg
                Schedule liborSchedule, double liborFraction, double liborSpread, IborIndex liborIndex, DayCounter liborDayCount,
                // BMA leg
                Schedule bmaSchedule, BMAIndex bmaIndex, DayCounter bmaDayCount)
            : base(2)
        {
            type_ = type;
            nominal_ = nominal;
            liborFraction_ = liborFraction;
            liborSpread_ = liborSpread;

            BusinessDayConvention convention = liborSchedule.businessDayConvention();

            legs_[0] = new IborLeg(liborSchedule, liborIndex)
                        .withPaymentDayCounter(liborDayCount)
                        .withFixingDays(liborIndex.fixingDays())
                        .withGearings(liborFraction)
                        .withSpreads(liborSpread)
                        .withNotionals(nominal)
                        .withPaymentAdjustment(convention);

            legs_[1] = new AverageBMALeg(bmaSchedule, bmaIndex)
                        .withPaymentDayCounter(bmaDayCount)
                        .withNotionals(nominal)
                        .withPaymentAdjustment(bmaSchedule.businessDayConvention());

            for (int j=0; j<2; ++j) {
                for (int i=0; i<legs_[j].Count; i++)
                    legs_[j][i].registerWith(update);
            }

            switch (type_) {
                case Type.Payer:
                    payer_[0] = +1.0;
                    payer_[1] = -1.0;
                    break;
                case Type.Receiver:
                    payer_[0] = -1.0;
                    payer_[1] = +1.0;
                    break;
                default:
                    throw new ApplicationException("Unknown BMA-swap type");
            }
        }