Package org.jquantlib.time

Examples of org.jquantlib.time.Date$ISODate


    }

    @Override
    protected void initializeDates() {

        final Date settlement = iborIndex.fixingCalendar().advance(evaluationDate,
           new Period(iborIndex.fixingDays(),TimeUnit.Days), BusinessDayConvention.Following, false);
        earliestDate = iborIndex.fixingCalendar().advance(
                settlement,
                new Period(monthsToStart,TimeUnit.Months),
                iborIndex.businessDayConvention(),
View Full Code Here


        greeks.gamma = black.gamma(spot);

        final DayCounter rfdc = process.riskFreeRate().currentLink().dayCounter();
        final DayCounter divdc = process.dividendYield().currentLink().dayCounter();
        final DayCounter voldc = process.blackVolatility().currentLink().dayCounter();
        final Date refDate = process.riskFreeRate().currentLink().referenceDate();
        /* @Time */double t = rfdc.yearFraction(refDate, a.exercise.lastDate());
        greeks.rho = black.rho(t);

        t = divdc.yearFraction(process.dividendYield().currentLink().referenceDate(), a.exercise.lastDate());
        greeks.dividendRho = black.dividendRho(t);
View Full Code Here

        } else // it is being used as control variate
            runningLog = 1.0;
            pastFixings = 0;
        }

        final Date referenceDate = process.riskFreeRate().currentLink().referenceDate();
        final DayCounter rfdc  = process.riskFreeRate().currentLink().dayCounter();
        final DayCounter divdc = process.dividendYield().currentLink().dayCounter();
        final DayCounter voldc = process.blackVolatility().currentLink().dayCounter();

        // TODO: consider double[] instead
        final List<Double> fixingTimes = new ArrayList<Double>();
        /*@Size*/ int i;
        for (i=0; i<a.fixingDates.size(); i++) {
            if (a.fixingDates.get(i).ge(referenceDate)) {
                /*@Time*/ final double t = voldc.yearFraction(referenceDate,
                        a.fixingDates.get(i));
                fixingTimes.add(Double.valueOf(t));
            }
        }

        /*@Size*/ final int remainingFixings = fixingTimes.size();
        /*@Size*/ final int numberOfFixings = pastFixings + remainingFixings;
        /*@Real*/ final double N = numberOfFixings;

        /*@Real*/ final double pastWeight = pastFixings/N;
        /*@Real*/ final double futureWeight = 1.0-pastWeight;

        double timeSum = 0.0;
        for (int k=0; k<fixingTimes.size(); k++) {
            timeSum += fixingTimes.get(k);
        }

        /*@Volatility*/ final double vola = process.blackVolatility().currentLink().blackVol(a.exercise.lastDate(), payoff.strike());

        /*@Real*/ double temp = 0.0;
        for (i=pastFixings+1; i<numberOfFixings; i++) {
            temp += fixingTimes.get(i-pastFixings-1)*(N-i);
        }

        /*@Real*/ final double variance = vola*vola /N/N * (timeSum+ 2.0*temp);
        /*@Real*/ final double dsigG_dsig = Math.sqrt((timeSum + 2.0*temp))/N;
        /*@Real*/ final double sigG = vola * dsigG_dsig;
        /*@Real*/ final double dmuG_dsig = -(vola * timeSum)/N;

        final Date exDate = a.exercise.lastDate();
        /*@Rate*/ final double dividendRate = process.dividendYield().currentLink().
        zeroRate(exDate, divdc, Compounding.Continuous, Frequency.NoFrequency).rate();
        /*@Rate*/ final double riskFreeRate = process.riskFreeRate().currentLink().
        zeroRate(exDate, rfdc, Compounding.Continuous, Frequency.NoFrequency).rate();
        /*@Rate*/ final double nu = riskFreeRate - dividendRate - 0.5*vola*vola;
 
View Full Code Here

        final Bond.ArgumentsImpl a = (Bond.ArgumentsImpl)arguments;
        final Bond.ResultsImpl   r = (Bond.ResultsImpl)results;

      final Leg cashflows = a.cashflows;
      final Date settlementDate = a.settlementDate;
      final Date valuationDate = discountCurve.currentLink().referenceDate();
        QL.require(! discountCurve.empty() , "no discounting term structure set"); //// TODO: message

        r.value           = CashFlows.getInstance().npv(cashflows, discountCurve, valuationDate,  valuationDate);
        r.settlementValue = CashFlows.getInstance().npv(cashflows, discountCurve, settlementDate, settlementDate);
    }
View Full Code Here

    @Override
    public void calculate() /*@ReadOnly*/ {
        QL.require(a.averageType==AverageType.Geometric , "not a geometric average option"); // QA:[RG]::verified // TODO: message
        QL.require(a.exercise.type()==Exercise.Type.European , "not an European Option"); // QA:[RG]::verified // TODO: message
        final Date exercise = a.exercise.lastDate();

        QL.require(a.payoff instanceof PlainVanillaPayoff , "non-plain payoff given"); // QA:[RG]::verified // TODO: message
        final PlainVanillaPayoff payoff = (PlainVanillaPayoff)arguments.payoff;

        /*@Volatility*/ final double volatility = process.blackVolatility().currentLink().blackVol(exercise, payoff.strike());
View Full Code Here

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

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

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

        for (final Type type : types)
            for (final double strike : strikes)
                for (final int length : lengths) {
                    final Date exDate = today.add(length * 360);
                    final Exercise exercise = new EuropeanExercise(exDate);
                    final StrikedTypePayoff payoff = new PlainVanillaPayoff(type, strike);

                    // reference option
                    final VanillaOption refOption = makeOption(payoff, exercise, spot, qTS, rTS, volTS, EngineType.Analytic,
View Full Code Here

        // When Case 2
        this.moving = true;
        this.updated = false;

        // observes date changes
        final Date today = new Settings().evaluationDate();
        today.addObserver(this);

        this.referenceDate = calendar.advance(today, settlementDays, TimeUnit.Days);
    }
View Full Code Here

     * @see org.jquantlib.termstructures.TermStructure#referenceDate()
     */
    @Override
    public Date referenceDate() /* @ReadOnly */ {
        if (!updated) {
          final Date today = new Settings().evaluationDate();
          referenceDate = calendar().advance(today, settlementDays, TimeUnit.Days);
            updated = true;
        }
        return referenceDate;
    }
View Full Code Here

    }

    @Test
    public void testAdvance() {
        final NullCalendar nullCalendar = new NullCalendar();
        final Date d = new Date(11, Month.October, 2009);
        final Date dCopy = d.clone();
        assertEquals(dCopy, d);
        final Date advancedDate = nullCalendar.advance(d, new Period(3, TimeUnit.Months));
        assertEquals(dCopy, d);
        assertFalse(advancedDate.equals(d));
    }
View Full Code Here

    public void testEndOfMonth() {
        QL.info("Testing end-of-month calculation...");

        final Calendar c = new Target(); // any calendar would be OK

        Date eom;
        final Date counter = Date.minDate();
        final Date last = Date.maxDate().sub(new Period(2, TimeUnit.Months));

        while (counter.le(last)) {
            eom = c.endOfMonth(counter);
            // check that eom is eom
            if (!c.isEndOfMonth(eom)) {
View Full Code Here

TOP

Related Classes of org.jquantlib.time.Date$ISODate

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.