Package org.jquantlib.time

Examples of org.jquantlib.time.TimeGrid


  //
  // protected methods
  //

    protected boolean isOnTime(final /* @Time */ double t) {
        final TimeGrid grid = method().timeGrid();
        return Closeness.isCloseEnough(grid.at(grid.index(t)), time());
    }
View Full Code Here


            throw new LibraryException(e); // QA:[RG]::verified
        }

        final /*@Real*/ double creditSpread = a.creditSpread.currentLink().value();
        final Lattice lattice = new TsiveriotisFernandesLattice<T>(tree, riskFreeRate, maturity, timeSteps_, creditSpread, v, q);
        final DiscretizedConvertible convertible = new DiscretizedConvertible((ConvertibleBondOption.Arguments)a, bs, new TimeGrid(maturity, timeSteps_));

        convertible.initialize(lattice, maturity);
        convertible.rollback(0.0);
        r.value = convertible.presentValue();
    }
View Full Code Here

        QL.require(payoff!=null , "non-plain payoff given"); // QA:[RG]::verified // TODO: message

        final double maturity = rfdc.yearFraction(referenceDate, maturityDate);

        final StochasticProcess1D bs = new GeneralizedBlackScholesProcess(process.stateVariable(), flatDividends, flatRiskFree, flatVol);
        final TimeGrid grid = new TimeGrid(maturity, timeSteps_);
        final Tree tree = (Tree)getTreeInstance(bs, maturity, timeSteps_, payoff.strike());

        final BlackScholesLattice<Tree> lattice = new BlackScholesLattice<Tree>(tree, rRate, maturity, timeSteps_);
        final DiscretizedVanillaOption option = new DiscretizedVanillaOption(a, process, grid);

        option.initialize(lattice, maturity);

        // Partial derivatives calculated from various points in the binomial tree (Odegaard)

        // Rollback to third-last step, and get underlying price (s2) & option values (p2) at this point
        option.rollback(grid.at(2));
        final Array va2 = option.values();
        QL.require(va2.size() == 3 , "expect 3 nodes in grid at second step"); // QA:[RG]::verified // TODO: message
        final double p2h = va2.get(2); // high-price
        final double s2 = lattice.underlying(2, 2); // high price

        // Rollback to second-last step, and get option value (p1) at this point
        option.rollback(grid.at(1));
        final Array va = option.values();
        QL.require(va.size() == 2, "expect 2 nodes in grid at first step"); // QA:[RG]::verified // TODO: message
        final double p1 = va.get(1);

        // Finally, rollback to t=0
View Full Code Here

    //

    public DiscretizedVanillaOption(
            final VanillaOption.Arguments arguments,
            final StochasticProcess process) {
        this(arguments, process, new TimeGrid());
    }
View Full Code Here

        final Lattice lattice = new TsiveriotisFernandesLattice<T>(tree,riskFreeRate,maturity,
                                                 timeSteps_,creditSpread,v,q);

        final DiscretizedConvertible convertible =
                new DiscretizedConvertible(this.a, bs,
                                                 new TimeGrid(maturity, timeSteps_));

        convertible.initialize(lattice, maturity);
        convertible.rollback(0.0);
        this.r.value = convertible.presentValue();
    }
View Full Code Here

  //
  // protected methods
  //

    protected boolean isOnTime(final /* @Time */ double t) {
        final TimeGrid grid = method().timeGrid();
        return Closeness.isCloseEnough(grid.at(grid.index(t)), time());
    }
View Full Code Here

    //

    public DiscretizedVanillaOption(
            final VanillaOption.Arguments arguments,
            final StochasticProcess process) {
        this(arguments, process, new TimeGrid());
    }
View Full Code Here

        QL.require(payoff!=null , "non-plain payoff given"); // TODO: message

        final double maturity = rfdc.yearFraction(referenceDate, maturityDate);

        final StochasticProcess1D bs = new GeneralizedBlackScholesProcess(process.stateVariable(), flatDividends, flatRiskFree, flatVol);
        final TimeGrid grid = new TimeGrid(maturity, timeSteps_);
        final Tree tree = (Tree)getTreeInstance(bs, maturity, timeSteps_, payoff.strike());

        final BlackScholesLattice<Tree> lattice = new BlackScholesLattice<Tree>(tree, rRate, maturity, timeSteps_);
        final DiscretizedVanillaOption option = new DiscretizedVanillaOption(a, process, grid);

        option.initialize(lattice, maturity);

        // Partial derivatives calculated from various points in the binomial tree (Odegaard)

        // Rollback to third-last step, and get underlying price (s2) & option values (p2) at this point
        option.rollback(grid.at(2));
        final Array va2 = option.values();
        QL.require(va2.size() == 3 , "expect 3 nodes in grid at second step"); // TODO: message
        final double p2h = va2.get(2); // high-price
        final double s2 = lattice.underlying(2, 2); // high price

        // Rollback to second-last step, and get option value (p1) at this point
        option.rollback(grid.at(1));
        final Array va = option.values();
        QL.require(va.size() == 2, "expect 2 nodes in grid at first step"); // TODO: message
        final double p1 = va.get(1);

        // Finally, rollback to t=0
View Full Code Here

            throw new UnsupportedOperationException("Work in progress");
        }
        this.brownianBridge_ = brownianBridge;
        this.generator_ = generator;
        this.dimension_ = generator.dimension();
        this.timeGrid_ = new TimeGrid(length, timeSteps);
        this.process_ = process;
        //XXX this.next_ = new Sample<Path>( new Path(this.timeGrid_), 1.0 );
        this.temp_ = new double[this.dimension_];
        this.bb_ = new BrownianBridge(this.timeGrid_);
       
View Full Code Here

       QL.require(payoff!=null , "non-plain payoff given"); // QA:[RG]::verified // TODO: message

       final double maturity = rfdc.yearFraction(referenceDate, maturityDate);

       final StochasticProcess1D bs = new GeneralizedBlackScholesProcess(process.stateVariable(), flatDividends, flatRiskFree, flatVol);
       final TimeGrid grid = new TimeGrid(maturity, timeSteps);
       final Tree tree = (Tree)getTreeInstance(bs, maturity, timeSteps, payoff.strike());

       final BlackScholesDividendLattice<Tree> lattice = new BlackScholesDividendLattice<Tree>(tree, rRate, maturity, timeSteps,
                                                                           rfdc, grid, referenceDate, a.cashFlow);
       final DiscretizedVanillaOption option = new DiscretizedVanillaOption(a, process, grid);

       option.initialize(lattice, maturity);

       // Partial derivatives calculated from various points in the binomial tree (Odegaard)

       // Rollback to third-last step, and get underlying price (s2) & option values (p2) at this point
       option.rollback(grid.at(2));
       final Array va2 = option.values();
       QL.require(va2.size() == 3 , "expect 3 nodes in grid at second step"); // QA:[RG]::verified // TODO: message
       final double p2h = va2.get(2); // high-price
       final double s2 = lattice.underlying(2, 2); // high price

       // Rollback to second-last step, and get option value (p1) at this point
       option.rollback(grid.at(1));
       final Array va = option.values();
       QL.require(va.size() == 2, "expect 2 nodes in grid at first step"); // QA:[RG]::verified // TODO: message
       final double p1 = va.get(1);

       // Finally, rollback to t=0
View Full Code Here

TOP

Related Classes of org.jquantlib.time.TimeGrid

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.