Examples of YieldTermStructure


Examples of org.jquantlib.termstructures.YieldTermStructure

        Date date = settlementDate;
        if (date.isNull()) {
            date = new Settings().evaluationDate();
        }

        final YieldTermStructure flatRate = new FlatForward(date, irr.rate(), irr.dayCounter(), irr.compounding(), irr.frequency());
        return npv(cashflows, new Handle<YieldTermStructure>(flatRate), date, date, 0);
    }
View Full Code Here

Examples of org.jquantlib.termstructures.YieldTermStructure

    public double bps(final Leg cashflows, final InterestRate irr, Date settlementDate){
        if (settlementDate.isNull())
        {
            settlementDate = new Settings().evaluationDate();
        }
        final YieldTermStructure flatRate = new FlatForward(settlementDate, irr.rate(),
                    irr.dayCounter(), irr.compounding(), irr.frequency());
        return bps(cashflows, new Handle<YieldTermStructure>(flatRate), settlementDate, settlementDate);
     }
View Full Code Here

Examples of org.jquantlib.termstructures.YieldTermStructure

        final DayCounter dc = new Actual360();
        final SimpleQuote           spot  = new SimpleQuote(100.0);
        final Quote                 u     = spot;
        final SimpleQuote           qRate = new SimpleQuote(0.05);
        final YieldTermStructure    qTS   = Utilities.flatRate(today, qRate, dc);
        final SimpleQuote           rRate = new SimpleQuote(0.003);
        final YieldTermStructure    rTS   = Utilities.flatRate(today, rRate, dc);
        final SimpleQuote           vol   = new SimpleQuote(0.20);
        final BlackVolTermStructure volTS = Utilities.flatVol(today, vol, dc);

        final Date exerciseDate = today.add(Period.ONE_YEAR_FORWARD);
        final Exercise exercise = new EuropeanExercise(exerciseDate);
View Full Code Here

Examples of org.jquantlib.termstructures.YieldTermStructure

        final DayCounter dc = new Actual360();

        final SimpleQuote           spot  = new SimpleQuote(0.0);
        final SimpleQuote           qRate = new SimpleQuote(0.0);
        final YieldTermStructure    qTS   = Utilities.flatRate(today, qRate, dc);
        final SimpleQuote           rRate = new SimpleQuote(0.0);
        final YieldTermStructure    rTS   = Utilities.flatRate(today, rRate, dc);
        final SimpleQuote           vol   = new SimpleQuote(0.0);
        final BlackVolTermStructure volTS = Utilities.flatVol(today, vol, dc);

        for (final Type type : types) {
            for (final double strike3 : strikes) {
View Full Code Here

Examples of org.jquantlib.termstructures.YieldTermStructure

            final /*@Time*/ double time,
            final /*@Real*/ double underlyingLevel) {

        // obtain local copies of objects
        final Quote u = underlying_.currentLink();
        final YieldTermStructure dTS = dividendTS_.currentLink();
        final YieldTermStructure rTS = riskFreeTS_.currentLink();
        final BlackVolTermStructure bTS = blackTS_.currentLink();

        final double forwardValue = u.value() * ( dTS.discount(time, true) / rTS.discount(time, true) );

        // strike derivatives
        /*@Real*/ double strike;
        /*@Real*/ double strikem;
        /*@Real*/ double strikep;
View Full Code Here

Examples of org.jquantlib.termstructures.YieldTermStructure

        Date date = settlementDate;
        if (date.isNull()) {
            date = new Settings().evaluationDate();
        }

        final YieldTermStructure flatRate = new FlatForward(date, irr.rate(), irr.dayCounter(), irr.compounding(), irr.frequency());
        return npv(cashflows, new Handle<YieldTermStructure>(flatRate), date, date, 0);
    }
View Full Code Here

Examples of org.jquantlib.termstructures.YieldTermStructure

    public double bps(final Leg cashflows, final InterestRate irr, Date settlementDate){
        if (settlementDate.isNull())
        {
            settlementDate = new Settings().evaluationDate();
        }
        final YieldTermStructure flatRate = new FlatForward(settlementDate, irr.rate(),
                    irr.dayCounter(), irr.compounding(), irr.frequency());
        return bps(cashflows, new Handle<YieldTermStructure>(flatRate), settlementDate, settlementDate);
     }
View Full Code Here

Examples of org.jquantlib.termstructures.YieldTermStructure

        final Date[] jumpDates1 = new Date[0];
        final double tolerance1 = 1.0e-15;
        final LogLinear interpolator = null;
        final IterativeBootstrap bootstrap = null;
       
        final YieldTermStructure  bondDiscountingTermStructur =
                 new PiecewiseYieldCurve<Discount,LogLinear,IterativeBootstrap>(
                     Discount.class, LogLinear.class, IterativeBootstrap.class,
                     settlementDate,
                     instruments1,
                     termStructureDayCounter,
                     jumps1,
                     jumpDates1,
                     tolerance1,
                     interpolator,
                     bootstrap){/* anonymous */};

        // Building of the Libor forecasting curve
        // deposits
        final double d1wQuote = 0.043375;
        final double d1mQuote = 0.031875;
        final double d3mQuote = 0.0320375;
        final double d6mQuote = 0.03385;
        final double d9mQuote = 0.0338125;
        final double d1yQuote = 0.0335125;
        // swaps
        final double s2yQuote = 0.0295;
        final double s3yQuote = 0.0323;
        final double s5yQuote = 0.0359;
        final double s10yQuote = 0.0412;
        final double s15yQuote = 0.0433;

        /********************
         *** QUOTES ***
         ********************/

        // SimpleQuote stores a value which can be manually changed;
        // other Quote subclasses could read the value from a database
        // or some kind of data feed.

        // deposits
        final Quote d1wRate = (new SimpleQuote(d1wQuote));
        final Quote d1mRate = (new SimpleQuote(d1mQuote));
        final Quote d3mRate = (new SimpleQuote(d3mQuote));
        final Quote d6mRate = (new SimpleQuote(d6mQuote));
        final Quote d9mRate = (new SimpleQuote(d9mQuote));
        final Quote d1yRate = (new SimpleQuote(d1yQuote));
        // swaps
        final Quote s2yRate = (new SimpleQuote(s2yQuote));
        final Quote s3yRate = (new SimpleQuote(s3yQuote));
        final Quote s5yRate = (new SimpleQuote(s5yQuote));
        final Quote s10yRate = (new SimpleQuote(s10yQuote));
        final Quote s15yRate = (new SimpleQuote(s15yQuote));

        /*********************
         *** RATE HELPERS ***
         *********************/

        // RateHelpers are built from the above quotes together with
        // other instrument dependant infos. Quotes are passed in
        // relinkable handles which could be relinked to some other
        // data source later.

        // deposits
        final DayCounter depositDayCounter = new Actual360();

        final RateHelper d1w = new DepositRateHelper(
                  new Handle<Quote>(d1wRate),
                  new Period(1, TimeUnit.Weeks),
                  fixingDays, calendar,
                  BusinessDayConvention.ModifiedFollowing,
                  true, depositDayCounter);
        final RateHelper d1m = new DepositRateHelper(
                  new Handle<Quote>(d1mRate),
                  new Period(1, TimeUnit.Months),
                  fixingDays, calendar,
                  BusinessDayConvention.ModifiedFollowing,
                  true, depositDayCounter);
        final RateHelper d3m = new DepositRateHelper(
                  new Handle<Quote>(d3mRate),
                  new Period(3, TimeUnit.Months),
                  fixingDays, calendar,
                  BusinessDayConvention.ModifiedFollowing,
                  true, depositDayCounter);
        final RateHelper d6m = new DepositRateHelper(
                  new Handle<Quote>(d6mRate),
                  new Period(6, TimeUnit.Months),
                  fixingDays, calendar,
                  BusinessDayConvention.ModifiedFollowing,
                  true, depositDayCounter);
        final RateHelper d9m = new DepositRateHelper(
                new Handle<Quote>(d9mRate),
                new Period(9, TimeUnit.Months),
                fixingDays, calendar,
                BusinessDayConvention.ModifiedFollowing,
                true, depositDayCounter);
        final RateHelper d1y = new DepositRateHelper(
                new Handle<Quote>(d1yRate),
                new Period(1, TimeUnit.Years),
                fixingDays, calendar,
                BusinessDayConvention.ModifiedFollowing,
                true, depositDayCounter);

        // setup swaps
        final Frequency swFixedLegFrequency = Frequency.Annual;
        final BusinessDayConvention swFixedLegConvention = BusinessDayConvention.Unadjusted;
        final DayCounter swFixedLegDayCounter = new Thirty360(Convention.European);
        final IborIndex  swFloatingLegIndex = new Euribor6M(new Handle<YieldTermStructure>());

        // TODO and FIXME: not sure whether the class stuff works properly
        // final IborIndex swFloatingLegIndex = Euribor.getEuribor6M(new Handle<YieldTermStructure>(YieldTermStructure.class)); //FIXME::RG::Handle
//        final YieldTermStructure nullYieldTermStructure = new AbstractYieldTermStructure() {
//            @Override
//            protected double discountImpl(final double t) {
//                throw new UnsupportedOperationException();
//            }
//            @Override
//            public Date maxDate() {
//                throw new UnsupportedOperationException();
//            }
//        };
//        final IborIndex swFloatingLegIndex = new Euribor6M(new Handle<YieldTermStructure>(nullYieldTermStructure));


        final Period forwardStart = new Period(1, TimeUnit.Days);
       
        final RateHelper s2y = new SwapRateHelper(
              new Handle<Quote>(s2yRate),
              new Period(2, TimeUnit.Years),
              calendar,
              swFixedLegFrequency,
              swFixedLegConvention,
              swFixedLegDayCounter,
              swFloatingLegIndex,
              new Handle<Quote>(),
              forwardStart);
         final RateHelper s3y = new SwapRateHelper(
                 new Handle<Quote>(s3yRate),
                 new Period(3, TimeUnit.Years),
                 calendar,
                 swFixedLegFrequency,
                 swFixedLegConvention,
                 swFixedLegDayCounter,             
                 swFloatingLegIndex,
                 new Handle<Quote>(),
                 forwardStart);
        final RateHelper  s5y = new SwapRateHelper(
                new Handle<Quote>(s5yRate),
                new Period(5, TimeUnit.Years),
                calendar,
                swFixedLegFrequency,
                swFixedLegConvention,
                swFixedLegDayCounter,
                swFloatingLegIndex,
                new Handle<Quote>(),
                forwardStart);
        final RateHelper s10y = new SwapRateHelper(
                new Handle<Quote>(s10yRate),
                new Period(10, TimeUnit.Years),
                calendar,
                swFixedLegFrequency,
                swFixedLegConvention,
                swFixedLegDayCounter,
                swFloatingLegIndex,
                new Handle<Quote>(),
                forwardStart);
        final RateHelper  s15y = new SwapRateHelper(
                new Handle<Quote>(s15yRate),
                new Period(15, TimeUnit.Years),
                calendar,
                swFixedLegFrequency,
                swFixedLegConvention,
                swFixedLegDayCounter,
                swFloatingLegIndex,
                new Handle<Quote>(),
                forwardStart);

         /*********************
         ** CURVE BUILDING **
         *********************/
       
         // Any DayCounter would be fine.
         // ActualActual::ISDA ensures that 30 years is 30.0
       
         // A depo-swap curve
         final List<RateHelper> depoSwapInstruments = new ArrayList<RateHelper>();
         depoSwapInstruments.add(d1w);
         depoSwapInstruments.add(d1m);
         depoSwapInstruments.add(d3m);
         depoSwapInstruments.add(d6m);
         depoSwapInstruments.add(d9m);
         depoSwapInstruments.add(d1y);
         depoSwapInstruments.add(s2y);
         depoSwapInstruments.add(s3y);
         depoSwapInstruments.add(s5y);
         depoSwapInstruments.add(s10y);
         depoSwapInstruments.add(s15y);
        
         final RateHelper[] instruments = new RateHelper[depoSwapInstruments.size()];
         depoSwapInstruments.toArray(instruments);
         final Handle[] jumps= new Handle[0];//]<Quote>[]) new ArrayList<Handle<Quote>>().toArray();
         final Date[] jumpDates = new Date[0];// new ArrayList<Date>().toArray();
        
         final YieldTermStructure  depoSwapTermStructure =
             new PiecewiseYieldCurve<Discount,LogLinear,IterativeBootstrap>(
                 Discount.class, LogLinear.class, IterativeBootstrap.class,
                 settlementDate,
                 instruments,
                 termStructureDayCounter,
View Full Code Here

Examples of org.jquantlib.termstructures.YieldTermStructure

            final/* @Real */double x) {
        /* @Diffusion */final double sigma = diffusion(t, x);
        // we could be more anticipatory if we know the right dt
        // for which the drift will be used
        /* @Time */final double t1 = t + 0.0001;
        final YieldTermStructure yts = riskFreeRate.currentLink();
        /* @Rate */final double r = yts.forwardRate(t, t1, Compounding.Continuous, Frequency.NoFrequency, true).rate();

        final YieldTermStructure divTs = dividendYield.currentLink();
        final double d = divTs.forwardRate(t, t1, Compounding.Continuous, Frequency.NoFrequency, true).rate();
        return r - d - 0.5 * sigma * sigma;
    }
View Full Code Here

Examples of org.jquantlib.termstructures.YieldTermStructure

        return result;
    }

    @Override
    public final/* @Time */double time(final Date d) {
        final YieldTermStructure yts = riskFreeRate.currentLink();
        return yts.dayCounter().yearFraction(yts.referenceDate(), d);
    }
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.