Examples of SimpleQuote


Examples of org.jquantlib.quotes.SimpleQuote

        final DayCounter dc = new Actual360();
        final Date today = Date.todaysDate();
        new Settings().setEvaluationDate(today);

        final SimpleQuote spot = new SimpleQuote(0.0);
        final SimpleQuote qRate = new SimpleQuote(0.0);
        final Handle<YieldTermStructure> qTS = new Handle<YieldTermStructure>(Utilities.flatRate(qRate, dc));
        final SimpleQuote rRate = new SimpleQuote(0.0);
        final Handle<YieldTermStructure> rTS = new Handle<YieldTermStructure>(Utilities.flatRate(rRate, dc));
        final SimpleQuote vol = new SimpleQuote(0.0);
        final Handle<BlackVolTermStructure> volTS = new Handle<BlackVolTermStructure>(Utilities.flatVol(vol, dc));

        for (final Type type : types)
            for (final double strike : strikes)
                for (final int length : lengths) {
                  final Date exDate = today.add(new Period(length, TimeUnit.Years));
                  final Exercise exercise = new EuropeanExercise(exDate);

                  final List<Date> dividendDates = new ArrayList<Date>();
                  final List</* @Real */ Double> dividends = new ArrayList<Double>();
                  for (final Date d = today.add(new Period(3, TimeUnit.Months));
                             d.lt(exercise.lastDate());
                             d.addAssign(new Period(6, TimeUnit.Months))) {
                      dividendDates.add(d.clone());
                      dividends.add(5.0);
                  }

                  final StrikedTypePayoff payoff = new PlainVanillaPayoff(type, strike);
                  final BlackScholesMertonProcess stochProcess = new BlackScholesMertonProcess(new Handle<Quote>(spot), qTS, rTS, volTS);
                  final PricingEngine engine = new FDDividendEuropeanEngine(stochProcess, timeSteps, gridPoints);
                  final PricingEngine ref_engine = new AnalyticDividendEuropeanEngine(stochProcess);

                  final DividendVanillaOption option = new DividendVanillaOption(payoff, exercise, dividendDates, dividends);
                  option.setPricingEngine(engine);

                  final DividendVanillaOption ref_option = new DividendVanillaOption(payoff, exercise, dividendDates, dividends);
                  ref_option.setPricingEngine(ref_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
                                /* @Real */ final double calculated = option.NPV();
                                if (calculated > spot.value()*1.0e-5) {
                                    /* @Real */ final double expected = ref_option.NPV();
                                    /* @Real */ final double error = Math.abs(calculated-expected);
View Full Code Here

Examples of org.jquantlib.quotes.SimpleQuote

        /* @Rate */ final double rRates[] = { 0.01, 0.05, 0.15 };
        /* @Volatility */ final double vols[] = { 0.05, 0.20, 0.50 };

        final DayCounter dc = new Actual360();

        final SimpleQuote spot = new SimpleQuote(0.0);
        final SimpleQuote qRate = new SimpleQuote(0.0);
        final Handle<YieldTermStructure> qTS = new Handle<YieldTermStructure>(Utilities.flatRate(qRate, dc));
        final SimpleQuote rRate = new SimpleQuote(0.0);
        final Handle<YieldTermStructure> rTS = new Handle<YieldTermStructure>(Utilities.flatRate(rRate, dc));
        final SimpleQuote vol = new SimpleQuote(0.0);
        final Handle<BlackVolTermStructure> volTS = new Handle<BlackVolTermStructure>(Utilities.flatVol(vol, dc));

        for (final Type type : types)
            for (final double strike : strikes) {

                final List<Date> dividendDates = new ArrayList<Date>();
                final List</* @Real */ Double> dividends = new ArrayList<Double>();
                for (final Date d = today.add(new Period(3, TimeUnit.Months));
                           d.lt(exercise.lastDate());
                           d.addAssign(new Period(6, TimeUnit.Months))) {
                    dividendDates.add(d.clone());
                    dividends.add(5.0);
                }

                final BlackScholesMertonProcess stochProcess = new BlackScholesMertonProcess(new Handle<Quote>(spot), qTS, rTS, volTS);
                final PricingEngine engine;
                try {
                    final Constructor<T> baseConstructor = engineClass.getConstructor(GeneralizedBlackScholesProcess.class);
                    engine = baseConstructor.newInstance(stochProcess);
                } catch (final Exception e) {
                    throw new LibraryException(e);
                }
                final StrikedTypePayoff payoff = new PlainVanillaPayoff(type, strike);

                final DividendVanillaOption option = new DividendVanillaOption(payoff, exercise, dividendDates, dividends);
                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
                                /* @Real */ final double value = option.NPV();
                                calculated.put("delta", option.delta() );
                                calculated.put("gamma", option.gamma() );
View Full Code Here

Examples of org.jquantlib.quotes.SimpleQuote

    }


    private <T extends FDEngineAdapter> void testFdDegenerate(final Class<T> engineClass, final Date today, final Exercise exercise) {
        final DayCounter dc = new Actual360();
        final SimpleQuote spot = new SimpleQuote(54.625);
        final Handle<YieldTermStructure> rTS = new Handle<YieldTermStructure>(Utilities.flatRate(0.052706, dc));
        final Handle<YieldTermStructure> qTS = new Handle<YieldTermStructure>(Utilities.flatRate(0.0, dc));
        final Handle<BlackVolTermStructure> volTS = new Handle<BlackVolTermStructure>(Utilities.flatVol(0.282922, dc));
        final BlackScholesMertonProcess process = new BlackScholesMertonProcess(new Handle<Quote>(spot), qTS, rTS, volTS);
View Full Code Here

Examples of org.jquantlib.quotes.SimpleQuote

            final Date referenceDate,
            final Calendar cal,
            /*@Volatility*/ final double volatility,
            final DayCounter dc) {
        super(referenceDate, cal, BusinessDayConvention.Following, dc);
        this.volatility = new Handle<Quote>(new SimpleQuote(volatility));
    }
View Full Code Here

Examples of org.jquantlib.quotes.SimpleQuote

                /*@Natural*/ final int settlementDays,
                final Calendar cal,
                /*@Volatility*/ final double volatility,
                final DayCounter dc) {
        super(settlementDays, cal, BusinessDayConvention.Following, dc);
        this.volatility = new Handle<Quote>(new SimpleQuote(volatility));
    }
View Full Code Here

Examples of org.jquantlib.quotes.SimpleQuote

              blackTS.currentLink().dayCounter());

        this.blackTS_ = blackTS;
        this.riskFreeTS_ = riskFreeTS;
        this.dividendTS_ = dividendTS;
        this.underlying_ = new Handle<Quote>(new SimpleQuote(underlying));

        this.blackTS_.addObserver(this);
        this.riskFreeTS_.addObserver(this);
        this.dividendTS_.addObserver(this);
    }
View Full Code Here

Examples of org.jquantlib.quotes.SimpleQuote

        }
    }

    @Override
    public void generateArguments() {
        v0_.linkTo(new SimpleQuote((SimpleQuote) v0_.currentLink()));
        kappa_.linkTo(new SimpleQuote((SimpleQuote) kappa_.currentLink()));
        theta_.linkTo(new SimpleQuote((SimpleQuote) theta_.currentLink()));
        sigma_.linkTo(new SimpleQuote((SimpleQuote) sigma_.currentLink()));
        rho_.linkTo(new SimpleQuote((SimpleQuote) rho_.currentLink()));
    }
View Full Code Here

Examples of org.jquantlib.quotes.SimpleQuote

                        final BusinessDayConvention convention,
                        final boolean endOfMonth,
                        final DayCounter dayCounter,
                        final/* Rate */double convAdj) {
    super(price);
    this.convAdj = new Handle<Quote>(new SimpleQuote(convAdj));

    QL.require(new IMM().isIMMdate(immDate, false), NOT_A_VALID_IMM_DATE);

    earliestDate = immDate;
    latestDate = calendar.advance(immDate, new Period(lengthInMonths,
View Full Code Here

Examples of org.jquantlib.quotes.SimpleQuote

    public FuturesRateHelper(final /* Real */ double price,
                              final Date immDate,
                              final IborIndex i,
                              final /* Rate */ double convAdj) {
        super(price);  
        this.convAdj = new Handle<Quote>(new SimpleQuote(convAdj));
       
        QL.require(new IMM().isIMMdate(immDate, false) , NOT_A_VALID_IMM_DATE);
       
        earliestDate = immDate;
        final Calendar cal = i.fixingCalendar();
View Full Code Here

Examples of org.jquantlib.quotes.SimpleQuote

        this.quote = quote;
        this.quote.addObserver(this);
    }

    public BootstrapHelper(final double quote) {
        this.quote = new Handle<Quote>(new SimpleQuote(quote));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.