Package org.jquantlib.termstructures.yieldcurves

Examples of org.jquantlib.termstructures.yieldcurves.FlatForward


        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]);
View Full Code Here


            // fall back to absolute error
            return Math.abs(x1 - x2);
    }

    static public YieldTermStructure flatRate(final Date today, final Quote forward, final DayCounter dc) {
        return new FlatForward(today, new Handle<Quote>(forward), dc);
    }
View Full Code Here

    static public YieldTermStructure flatRate(final Date today, final/* @Rate */double forward, final DayCounter dc) {
        return flatRate(today, new SimpleQuote(forward), dc);
    }

    static public YieldTermStructure flatRate(final Quote forward, final DayCounter dc) {
        return new FlatForward(0, new NullCalendar(), new Handle<Quote>(forward), dc);
    }
View Full Code Here

    @Test
    public void testReferenceChange() {
        QL.info("Testing term structure against evaluation date change...");

        final YieldTermStructure localTermStructure = new FlatForward(settlementDays, new NullCalendar(), 0.03, new Actual360());

        final int days[] = { 10, 30, 60, 120, 360, 720 };
        /*@DiscountFactor*/ final double[] expected = new /*@DiscountFactor*/ double[days.length];

        final Date today = new Settings().evaluationDate();

        for (int i=0; i<days.length; i++) {
            final Date anotherDay = today.add(days[i]);
            expected[i] = localTermStructure.discount(anotherDay);
        }

        final Date nextMonth = today.add(30);
        new Settings().setEvaluationDate(nextMonth);
        /*@DiscountFactor*/ final double[] calculated = new /*@DiscountFactor*/ double[days.length];

        for (int i=0; i<days.length; i++) {
            final Date anotherDay = nextMonth.add(days[i]);
            calculated[i] = localTermStructure.discount(anotherDay);
        }

        for (int i=0; i<days.length; i++) {
            if (!Closeness.isClose(expected[i],calculated[i])) {
                fail("\n  Discount at " + days[i] + " days:\n"
View Full Code Here

        // FIXME: This code was added instead. Please remove when PiecewiseYieldCurve becomes ready
        //
        final Quote quote = new SimpleQuote(100.0);
        final Flag anotherFlag = new Flag();
        quote.addObserver(anotherFlag);
        h.linkTo(new FlatForward(today, new Handle<Quote>(quote), new Actual360()));
        if (!anotherFlag.isUp()) {
            fail("Observer was not notified of term structure change");
        }

        if (!flag.isUp()) {
View Full Code Here

    //
    // private methods
    //

    private YieldTermStructure flatRate(final Date referenceDate, final Handle<SimpleQuote> rate, final DayCounter dc) {
        return new FlatForward(referenceDate, rate, dc);
    }
View Full Code Here

    //
    // private methods
    //

    private YieldTermStructure flatRate(final Date referenceDate, final Handle<SimpleQuote> rate, final DayCounter dc) {
        return new FlatForward(referenceDate, rate, dc);
    }
View Full Code Here

       final double rRate = process.riskFreeRate().currentLink().zeroRate(maturityDate, rfdc, Compounding.Continuous, Frequency.NoFrequency).rate();
       final double qRate = process.dividendYield().currentLink().zeroRate(maturityDate, divdc, Compounding.Continuous, Frequency.NoFrequency).rate();
       final Date referenceDate = process.riskFreeRate().currentLink().referenceDate();

       // binomial trees with constant coefficient
       final Handle<YieldTermStructure> flatRiskFree  = new Handle<YieldTermStructure>(new FlatForward(referenceDate, rRate, rfdc));
       final Handle<YieldTermStructure> flatDividends = new Handle<YieldTermStructure>(new FlatForward(referenceDate, qRate, divdc));
       final Handle<BlackVolTermStructure> flatVol = new Handle<BlackVolTermStructure>(new BlackConstantVol(referenceDate, volcal, v, voldc));
       final PlainVanillaPayoff payoff = (PlainVanillaPayoff) a.payoff;
       QL.require(payoff!=null , "non-plain payoff given"); // QA:[RG]::verified // TODO: message

       final double maturity = rfdc.yearFraction(referenceDate, maturityDate);
View Full Code Here

TOP

Related Classes of org.jquantlib.termstructures.yieldcurves.FlatForward

Copyright © 2018 www.massapicom. 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.