Package org.jquantlib.instruments

Examples of org.jquantlib.instruments.VanillaOption$Engine


                    new Handle<YieldTermStructure>(qTS),
                    new Handle<YieldTermStructure>(rTS),
                    new Handle<BlackVolTermStructure>(volTS));
            final PricingEngine engine = new BjerksundStenslandApproximationEngine(stochProcess);

            final VanillaOption option = new VanillaOption(payoff, exercise);
            option.setPricingEngine(engine);

            final double /* @Real */calculated = option.NPV();
            final double /* @Real */error = Math.abs(calculated - value.result);

            if (error > tolerance) {
                reportFailure(
                        "value", payoff, exercise,
View Full Code Here


                    new Handle<YieldTermStructure>(rTS),
                    new Handle<BlackVolTermStructure>(volTS));

            final PricingEngine engine = new BaroneAdesiWhaleyApproximationEngine(stochProcess);

            final VanillaOption option = new VanillaOption(payoff, exercise);
            option.setPricingEngine(engine);

            final double /* @Real */calculated = option.NPV();
            final double /* @Real */error = Math.abs(calculated - value.result);

            if (error > tolerance) {
                reportFailure(
                        "value", payoff, exercise,
View Full Code Here

                    new Handle<YieldTermStructure>(rTS),
                    new Handle<BlackVolTermStructure>(volTS));

            final PricingEngine engine = new JuQuadraticApproximationEngine(stochProcess);

            final VanillaOption option = new VanillaOption(payoff, exercise);
            option.setPricingEngine(engine);

            final double calculated = option.NPV();
            final double error = Math.abs(calculated - juValue.result);

            if (error > tolerance) {
                reportFailure(
                        "value", payoff, exercise,
View Full Code Here

                    new Handle<YieldTermStructure>(qTS),
                    new Handle<YieldTermStructure>(rTS),
                    new Handle<BlackVolTermStructure>(volTS));

            final PricingEngine engine = new FDAmericanEngine(stochProcess, 100, 100);
            final VanillaOption option = new VanillaOption(payoff, exercise);
            option.setPricingEngine(engine);

            final double calculated = option.NPV();
            final double error = Math.abs(calculated - juValue.result);

            if (error > tolerance) {
                reportFailure(
                        "value", payoff, exercise,
View Full Code Here

                    } catch (final Exception e) {
                        e.printStackTrace();
                        fail("failed to create pricing engine");
                    }

                    final VanillaOption option = new VanillaOption(payoff, exercise);
                    option.setPricingEngine(engine);

                    for (final double u : underlyings) {
                        for (final double q : qRates) {
                            for (final double r : rRates) {
                                for (final double v : vols) {
                                    spot.setValue(u);
                                    qRate.setValue(q);
                                    rRate.setValue(r);
                                    vol.setValue(v);
                                    // FLOATING_POINT_EXCEPTION
                                    final double value = option.NPV();
                                    final double delta = option.delta();
                                    final double gamma = option.gamma();
                                    //final double theta = option.theta();

                                    calculated.put("delta", delta);
                                    calculated.put("gamma", gamma);
                                    //calculated.put("theta", theta);

                                    if (value > spot.value() * 1.0e-5) {
                                        // perturb spot and get delta and gamma
                                        final double du = u * 1.0e-4;
                                        spot.setValue(u + du);
                                        final double value_p = option.NPV();
                                        final double delta_p = option.delta();
                                        spot.setValue(u - du);
                                        final double value_m = option.NPV();
                                        final double delta_m = option.delta();
                                        spot.setValue(u);
                                        expected.put("delta", (value_p - value_m) / (2 * du));
                                        expected.put("gamma", (delta_p - delta_m) / (2 * du));

                                        /*
 
View Full Code Here

TOP

Related Classes of org.jquantlib.instruments.VanillaOption$Engine

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.