Package org.jquantlib.processes

Examples of org.jquantlib.processes.GeneralizedBlackScholesProcess


        final SimpleQuote riskFreeRateQuote = new SimpleQuote(0.3);
        final RelinkableHandle<Quote>  handleToRiskFreeRateQuote = new RelinkableHandle<Quote>(riskFreeRateQuote);
        final YieldTermStructure riskFreeTermStructure = new FlatForward(2,new UnitedStates(Market.NYSE),handleToRiskFreeRateQuote, new Actual365Fixed(), Compounding.Continuous,Frequency.Daily);

        //Creating the process
        final StochasticProcess1D process = new GeneralizedBlackScholesProcess(handleToStockQuote,new RelinkableHandle<YieldTermStructure>(dividendTermStructure),new RelinkableHandle<YieldTermStructure>(riskFreeTermStructure),new RelinkableHandle<BlackVolTermStructure>(varianceCurve),new EulerDiscretization());

        //Calculating the drift of the stochastic process after time = 18th day from today with value of the stock as specified from the quote
        //The drift = (riskFreeForwardRate - dividendForwardRate) - (Variance/2)
        System.out.println("The drift of the process after time = 18th day from today with value of the stock as specified from the quote = "+process.drift(process.time(date18.clone()), handleToStockQuote.currentLink().value()));

        //Calculating the diffusion of the process after time = 18th day from today with value of the stock as specified from the quote
        //The diffusion = volatiltiy of the stochastic process
        System.out.println("The diffusion of the process after time = 18th day from today with value of the stock as specified from the quote = "+process.diffusion(process.time(date18.clone()), handleToStockQuote.currentLink().value()));

        //Calulating the standard deviation of the process after time = 18th day from today with value of the stock as specified from the quote
        //The standard deviation = volatility*sqrt(dt)
        System.out.println("The stdDeviation of the process after time = 18th day from today with value of the stock as specified from the quote = "+process.stdDeviation(process.time(date18.clone()), handleToStockQuote.currentLink().value(), 0.01));

        //Calulating the variance of the process after time = 18th day from today with value of the stock as specified from the quote
        //The variance = volatility*volatility*dt
        System.out.println("The variance of the process after time = 18th day from today with value of the stock as specified from the quote = "+process.variance(process.time(date18.clone()), handleToStockQuote.currentLink().value(), 0.01));

        //Calulating the expected value of the stock quote after time = 18th day from today with the current value of the stock as specified from the quote
        //The expectedValue = intialValue*exp(drift*dt)-----can be obtained by integrating----->dx/x= drift*dt
        System.out.println("Expected value = "+process.expectation(process.time(date18.clone()), handleToStockQuote.currentLink().value(), 0.01));

        //Calulating the exact value of the stock quote after time = 18th day from today with the current value of the stock as specified from the quote
        //The exact value = intialValue*exp(drift*dt)*exp(volatility*sqrt(dt))-----can be obtained by integrating----->dx/x= drift*dt+volatility*sqrt(dt)
        System.out.println("Exact value = "+process.evolve(process.time(date18.clone()), 6.7, .001, new NormalDistribution().op(Math.random())));

        //Calculating the drift of the stochastic process after time = 18th day from today with value of the stock as specified from the quote
        //The drift = (riskFreeForwardRate - dividendForwardRate) - (Variance/2)
        final Array drift = process.drift(process.time(date18.clone()), new Array(1).fill(5.6));
        System.out.println("The drift of the process after time = 18th day from today with value of the stock as specified from the quote");

        //Calculating the diffusion of the process after time = 18th day from today with value of the stock as specified from the quote
        //The diffusion = volatiltiy of the stochastic process
        final Matrix diffusion = process.diffusion(process.time(date18.clone()), new Array(1).fill(5.6));
        System.out.println("The diffusion of the process after time = 18th day from today with value of the stock as specified from the quote");

        //Calulating the standard deviation of the process after time = 18th day from today with value of the stock as specified from the quote
        //The standard deviation = volatility*sqrt(dt)
        final Matrix stdDeviation = process.stdDeviation(process.time(date18.clone()), new Array(1).fill(5.6), 0.01);
        System.out.println("The stdDeviation of the process after time = 18th day from today with value of the stock as specified from the quote");

        //Calulating the expected value of the stock quote after time = 18th day from today with the current value of the stock as specified from the quote
        //The expectedValue = intialValue*exp(drift*dt)-----can be obtained by integrating----->dx/x= drift*dt
        final Array expectation = process.expectation(process.time(date18.clone()), new Array(1).fill(5.6), 0.01);
        System.out.println("Expected value = "+expectation.first());

        //Calulating the exact value of the stock quote after time = 18th day from today with the current value of the stock as specified from the quote
        //The exact value = intialValue*exp(drift*dt)*exp(volatility*sqrt(dt))-----can be obtained by integrating----->dx/x= drift*dt+volatility*sqrt(dt)
        final Array evolve = process.evolve(process.time(date18.clone()), new Array(1).fill(6.7), .001, new Array(1).fill(new NormalDistribution().op(Math.random()) ));
        System.out.println("Exact value = "+evolve.first());

        //Calculating covariance of the process
        final Matrix covariance = process.covariance(process.time(date18.clone())new Array(1).fill(5.6), 0.01);
        System.out.println("Covariance = "+covariance.get(0, 0));

        clock.stopClock();
        clock.log();
    }
View Full Code Here


            final /*@Volatility*/ double minVol,
            final /*@Volatility*/ double maxVol) /* @ReadOnly */ {

        QL.require(!isExpired(), "option expired");
        final SimpleQuote volQuote = new SimpleQuote();
        final GeneralizedBlackScholesProcess newProcess = ImpliedVolatilityHelper.clone(process, volQuote);

        // engines are built-in for the time being
        final PricingEngine engine;
        switch (exercise.type()) {
          case European:
View Full Code Here

            /*@Volatility*/ final double minVol,
            /*@Volatility*/ final double maxVol) /* @ReadOnly */ {

        QL.require(!isExpired(), "option expired");
        final SimpleQuote volQuote = new SimpleQuote();
        final GeneralizedBlackScholesProcess newProcess = ImpliedVolatilityHelper.clone(process, volQuote);

        // engines are built-in for the time being
        final PricingEngine engine;
        switch (exercise.type()) {
            case European:
View Full Code Here

        final RelinkableHandle<YieldTermStructure> riskFreeTS =
            new RelinkableHandle<YieldTermStructure>(process.riskFreeRate().currentLink());
        final RelinkableHandle<BlackVolTermStructure> volTS =
            new RelinkableHandle<BlackVolTermStructure>(process.blackVolatility().currentLink());

        final GeneralizedBlackScholesProcess bsProcess =
            new GeneralizedBlackScholesProcess(stateVariable, dividendTS, riskFreeTS, volTS);

        final AnalyticEuropeanEngine baseEngine = new AnalyticEuropeanEngine(bsProcess);

        final VanillaOption.ArgumentsImpl baseArguments = (VanillaOption.ArgumentsImpl) baseEngine.getArguments();
View Full Code Here

        final PlainVanillaPayoff payoff = (PlainVanillaPayoff) a.payoff;
        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);
View Full Code Here

        Handle<Quote> underlyingH = new Handle<Quote>(new SimpleQuote(underlying));
        Handle<YieldTermStructure> flatDividendTS = new Handle<YieldTermStructure>(new FlatForward(settlementDate, dividendYield, dayCounter));
        Handle<YieldTermStructure> flatTermStructure = new Handle<YieldTermStructure>(new FlatForward(settlementDate, riskFreeRate, dayCounter));
        Handle<BlackVolTermStructure> flatVolTS = new Handle<BlackVolTermStructure>(new BlackConstantVol(settlementDate, calendar, volatility, dayCounter));

        GeneralizedBlackScholesProcess stochasticProcess = new BlackScholesMertonProcess(underlyingH, flatDividendTS, flatTermStructure, flatVolTS);

        VanillaOption europeanOption = new EuropeanOption(payoff, europeanExercise);

        europeanOption.setPricingEngine(new AnalyticEuropeanEngine(stochasticProcess));
View Full Code Here

            final BlackVolTermStructure vol,
            final EngineType engineType,
            final int binomialSteps,
            final int samples) {

        final GeneralizedBlackScholesProcess stochProcess = makeProcess(u,q,r,vol);
        final PricingEngine engine;

        switch (engineType) {
            case Analytic:
                engine = new AnalyticEuropeanEngine(stochProcess);
View Full Code Here

                    final Date exDate = today.add( length );
                    final Exercise exercise = new EuropeanExercise(exDate);
                    final StrikedTypePayoff payoff = new PlainVanillaPayoff(type, strike2);
                    final VanillaOption option = makeOption(payoff, exercise, spot, qTS, rTS, volTS, EngineType.Analytic, 0, 0);

                    final GeneralizedBlackScholesProcess process = makeProcess(spot, qTS, rTS,volTS);

                    for (final double u : underlyings) {
                        for (final double q : qRates) {
                            for (final double r : rRates) {
                                for (final double v : vols) {
View Full Code Here

            final BlackVolTermStructure vol,
            final EngineType engineType,
            /* @Size */final int binomialSteps,
            /* @Size */final int samples) {

        final GeneralizedBlackScholesProcess stochProcess = makeProcess(u, q, r, vol);

        PricingEngine engine;
        switch (engineType) {
        case Analytic:
            engine = new AnalyticEuropeanEngine(stochProcess);
View Full Code Here

       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);

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

TOP

Related Classes of org.jquantlib.processes.GeneralizedBlackScholesProcess

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.