Package org.jquantlib.methods.lattices

Examples of org.jquantlib.methods.lattices.TrinomialTree$Branching


    @Override
    public Lattice tree(final TimeGrid grid) {
        final TermStructureFittingParameter phi = new TermStructureFittingParameter(termStructureConsistentModelClass.termStructure());
        // needed to activate the above constructor
        final ShortRateDynamics numericDynamics = (new Dynamics(phi, a(), sigma()));
        final TrinomialTree trinomial = new TrinomialTree(numericDynamics.process(), grid, true);
        final ShortRateTree numericTree = new OneFactorModel.ShortRateTree(trinomial, numericDynamics, grid);

        // typedef TermStructureFittingParameter::NumericalImpl NumericalImpl;
        final TermStructureFittingParameter.NumericalImpl impl = (TermStructureFittingParameter.NumericalImpl) phi.implementation();
        impl.reset();
        for (int /* @Size */i = 0; i < (grid.size() - 1); i++) {
            final double /* @Real */discountBond = termStructureConsistentModelClass.termStructure().currentLink().discount(grid.at(i + 1));
            final Array statePrices = numericTree.statePrices(i);
            final int /* @Size */size = numericTree.size(i);
            final double /* @Time */dt = numericTree.timeGrid().dt(i);
            final double /* @Real */dx = trinomial.dx(i);
            double /* @Real */x = trinomial.underlying(i, 0);
            double /* @Real */value = 0.0;
            for (int /* @Size */j = 0; j < size; j++) {
                value += statePrices.get(j) * Math.exp(-x * dt);
                x += dx;
            }
View Full Code Here


    @Override
    public Lattice tree(final TimeGrid grid){
        final TermStructureFittingParameter phi = new TermStructureFittingParameter(termstructureConsistentModel.termStructure());
        final Dynamics numericDynamics =  new Dynamics(phi, theta(), k(), sigma(), x0());
        final TrinomialTree trinominal = new TrinomialTree(numericDynamics.process(), grid, true);
        final TermStructureFittingParameter.NumericalImpl impl = (TermStructureFittingParameter.NumericalImpl)phi.implementation();
        return new OneFactorModel.ShortRateTree(trinominal, numericDynamics, impl, grid);
    }
View Full Code Here

        }
    }

    @Override
    public Lattice tree(final TimeGrid grid) {
        final TrinomialTree trinomial = new TrinomialTree(dynamics().process(), grid, true);
        return new OneFactorModel.ShortRateTree(trinomial, dynamics(), grid);
    }
View Full Code Here

    /**
     * Return by default a trinomial recombining tree.
     */
    @Override
    public  Lattice tree(final TimeGrid  grid) /* @ReadOnly */ {
        final TrinomialTree trinomial = new TrinomialTree(dynamics().process(), grid);
        //XXX return boost::shared_ptr<Lattice>( new ShortRateTree(trinomial, dynamics(), grid) );
        return new ShortRateTree(trinomial, dynamics(), grid);
    }
View Full Code Here

    @Override
    public Lattice tree(final TimeGrid grid){
        final TermStructureFittingParameter phi = new TermStructureFittingParameter(termstructureConsistentModel.termStructure());
        final Dynamics numericDynamics =  new Dynamics(phi, theta(), k(), sigma(), x0());
        final TrinomialTree trinominal = new TrinomialTree(numericDynamics.process(), grid, true);
        final TermStructureFittingParameter.NumericalImpl impl = (TermStructureFittingParameter.NumericalImpl)phi.implementation();
        return new OneFactorModel.ShortRateTree(trinominal, numericDynamics, impl, grid);
    }
View Full Code Here

        }
    }

    @Override
    public Lattice tree(final TimeGrid grid) {
        final TrinomialTree trinomial = new TrinomialTree(dynamics().process(), grid, true);
        return new OneFactorModel.ShortRateTree(trinomial, dynamics(), grid);
    }
View Full Code Here

    @Override
    public Lattice tree(final TimeGrid grid) {
        final TermStructureFittingParameter phi = new TermStructureFittingParameter(termStructureConsistentModelClass.termStructure());
        // needed to activate the above constructor
        final ShortRateDynamics numericDynamics = (new Dynamics(phi, a(), sigma()));
        final TrinomialTree trinomial = new TrinomialTree(numericDynamics.process(), grid, true);
        final ShortRateTree numericTree = new OneFactorModel.ShortRateTree(trinomial, numericDynamics, grid);

        // typedef TermStructureFittingParameter::NumericalImpl NumericalImpl;
        final TermStructureFittingParameter.NumericalImpl impl = (TermStructureFittingParameter.NumericalImpl) phi.implementation();
        impl.reset();
        for (int /* @Size */i = 0; i < (grid.size() - 1); i++) {
            final double /* @Real */discountBond = termStructureConsistentModelClass.termStructure().currentLink().discount(grid.at(i + 1));
            final Array statePrices = numericTree.statePrices(i);
            final int /* @Size */size = numericTree.size(i);
            final double /* @Time */dt = numericTree.timeGrid().dt(i);
            final double /* @Real */dx = trinomial.dx(i);
            double /* @Real */x = trinomial.underlying(i, 0);
            double /* @Real */value = 0.0;
            for (int /* @Size */j = 0; j < size; j++) {
                value += statePrices.get(j) * Math.exp(-x * dt);
                x += dx;
            }
View Full Code Here

    @Override
    public Lattice tree(final TimeGrid grid) {
        final TermStructureFittingParameter phi = new TermStructureFittingParameter(termstructureConsistentModel.termStructure());
        final ShortRateDynamics numericDynamics = (new Dynamics(phi, a(), sigma()));
        final TrinomialTree trinomial = new TrinomialTree(numericDynamics.process(), grid, true);
        final ShortRateTree numericTree = null;//new ShortRateTree(trinomial, numericDynamics, grid);

        final TermStructureFittingParameter.NumericalImpl impl = (TermStructureFittingParameter.NumericalImpl) (phi.implementation());
        impl.reset();
        double /* @Real */value = 1.0;
        final double /* @Real */vMin = -50.0;
        final double /* @Real */vMax = 50.0;
        for (int /* @Size */i = 0; i < (grid.size() - 1); i++) {
            final double /* @Real */discountBond = termstructureConsistentModel.termStructure().currentLink().discount(grid.at(i + 1));
            final double /* @Real */xMin = trinomial.underlying(i, 0);
            final double /* @Real */dx = trinomial.dx(i);

            final Helper finder = new BlackKarasinski.Helper(i, xMin, dx, discountBond, numericTree);
            final Brent s1d = new Brent();
            s1d.setMaxEvaluations(1000);
            value = s1d.solve(finder, 1e-7, value, vMin, vMax);
View Full Code Here

    @Override
    public Lattice tree(final TimeGrid grid) {

        final ShortRateDynamics dyn = dynamics();

        final TrinomialTree tree1 = new TrinomialTree(dyn.xProcess(), grid, true);
        final TrinomialTree tree2 = new TrinomialTree(dyn.yProcess(), grid, true);

        return new ShortRateTree(tree1, tree2, dyn);

    }
View Full Code Here

TOP

Related Classes of org.jquantlib.methods.lattices.TrinomialTree$Branching

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.