Examples of BMAIndex


Examples of org.jquantlib.indexes.BMAIndex

        final CommonVars vars,
            final Interpolator interpolator,
            /*@Real*/ final double tolerance) {
     
        // re-adjust settlement
        vars.calendar = new JointCalendar(new BMAIndex().fixingCalendar(),
                                          new USDLibor(new Period(3, TimeUnit.Months)).fixingCalendar(),
                                          JointCalendarRule.JoinHolidays);
        vars.today = vars.calendar.adjust(Date.todaysDate());
        new Settings().setEvaluationDate(vars.today);
        vars.settlement = vars.calendar.advance(vars.today, vars.settlementDays, TimeUnit.Days);


        final Handle<YieldTermStructure> riskFreeCurve = new Handle<YieldTermStructure>(new FlatForward(vars.settlement, 0.04, new Actual360()));

        final BMAIndex bmaIndex = new BMAIndex();
        final IborIndex liborIndex = new USDLibor(new Period(3, TimeUnit.Months), riskFreeCurve);
        for (int i=0; i<vars.bmas; ++i) {
            final Handle<Quote> f = new Handle<Quote>(vars.fractions[i]);
            vars.bmaHelpers[i] = // boost::shared_ptr<RateHelper>(
                      new BMASwapRateHelper(f, new Period(bmaData[i].n, bmaData[i].units),
                                            vars.settlementDays,
                                            vars.calendar,
                                            new Period(vars.bmaFrequency),
                                            vars.bmaConvention,
                                            vars.bmaDayCounter,
                                            bmaIndex,
                                            liborIndex);
        }

        final Weekday w = vars.today.weekday();
        final Date lastWednesday = (w.ordinal() >= 4) ? vars.today.sub(w.ordinal() - 4) : vars.today.add(4 - w.ordinal() - 7);
        final Date lastFixing = bmaIndex.fixingCalendar().adjust(lastWednesday);
        bmaIndex.addFixing(lastFixing, 0.03);

        vars.termStructure = new PiecewiseYieldCurve<T,I,B>(
                      classT, classI, classB,
                      vars.settlement, vars.bmaHelpers,
                                    new Actual360(),
                                    new Handle/*<Quote>*/[0],
                                    new Date[0],
                                    1.0e-12,
                                    interpolator);

        final RelinkableHandle<YieldTermStructure> curveHandle = new RelinkableHandle<YieldTermStructure>();
        curveHandle.linkTo(vars.termStructure);

        // check BMA swaps
        final BMAIndex bma = new BMAIndex(curveHandle);
        final IborIndex libor3m = new USDLibor(new Period(3, TimeUnit.Months), riskFreeCurve);
        for (int i=0; i<vars.bmas; i++) {
            final Period tenor = new Period(bmaData[i].n, bmaData[i].units);

            final Schedule bmaSchedule = new MakeSchedule(vars.settlement,
                                                  vars.settlement.add(tenor),
                                                  new Period(vars.bmaFrequency),
                                                  bma.fixingCalendar(),
                                                  vars.bmaConvention)
                                    .backwards()
                                    .schedule();
            final Schedule liborSchedule = new MakeSchedule(vars.settlement,
                                                      vars.settlement.add(tenor),
View Full Code Here

Examples of org.jquantlib.indexes.BMAIndex

                                  new Period(settlementDays, TimeUnit.Days),
                                  BusinessDayConvention.Following);
     

      Date maturity = earliestDate.add(tenor);
      BMAIndex clonedIndex = bmaIndex.clone(termStructureHandle);
      Schedule bmaSchedule = new MakeSchedule(earliestDate,
                                          maturity,
                                          bmaPeriod,
                                          bmaIndex.fixingCalendar(),
                                          bmaConvention)
                    .backwards()
                    .schedule();
     
      Schedule liborSchedule = new MakeSchedule(earliestDate,
                                  maturity,
                                  iborIndex.tenor(),
                                  iborIndex.fixingCalendar(),
                                  iborIndex.businessDayConvention())
                    .endOfMonth(iborIndex.endOfMonth())
                    .schedule();

      this.swap = new BMASwap(BMASwap.Type.Payer,
                  100.0,
                  liborSchedule,
                  0.75, //arbitary
                  0.0,
                  iborIndex,
                  iborIndex.dayCounter(),
                  bmaSchedule,
                  clonedIndex,
                  bmaDayCount);
     
      this.swap.setPricingEngine(new DiscountingSwapEngine(iborIndex.termStructure()));
     
      Date d = calendar.adjust(swap.maturityDate(), BusinessDayConvention.Following);
      Weekday w = d.weekday();
      Date nextWednesday = w.value() >=4 ? d.add(11 - w.value()) :  d.add(4 - w.value());
     
      latestDate = clonedIndex.valueDate(clonedIndex.fixingCalendar().adjust(nextWednesday));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.