Package com.opengamma.timeseries

Examples of com.opengamma.timeseries.TimeSeriesException


    while (iter1.hasNext()) {
      final int date = iter1.nextTimeFast();
      final Double value2 = ts2.getValue(date);
      if (value2 == null || Math.abs(value2) < ZERO) {
        if (getMode().equals(CalculationMode.STRICT)) {
          throw new TimeSeriesException("No data in second series for time " + iter1.currentTime());
        }
      } else {
        times[i] = iter1.currentTimeFast();
        returns[i++] = Math.log(iter1.currentValue() / value2);
      }
View Full Code Here


  public abstract LocalDateDoubleTimeSeries evaluate(LocalDateDoubleTimeSeries... x);

  protected boolean isValueNonZero(final double value) {
    if (CompareUtils.closeEquals(value, 0)) {
      if (_mode == CalculationMode.STRICT) {
        throw new TimeSeriesException("Cannot have zero in time series in strict mode");
      }
      return false;
    }
    return true;
  }
View Full Code Here

   */
  @Override
  public LocalDateDoubleTimeSeries evaluate(final LocalDateDoubleTimeSeries... x) {
    Validate.notNull(x, "x");
    if (x.length < 4) {
      throw new TimeSeriesException("Time series array must contain at least four elements");
    }
    if (getMode() == CalculationMode.STRICT && x[0].size() != x[2].size()) {
      throw new TimeSeriesException("Asset price series and reference price series were not the same size");
    }
    final LocalDateDoubleTimeSeries assetReturn = x[1] == null ? _returnCalculator.evaluate(x[0]) : _returnCalculator.evaluate(Arrays.copyOfRange(x, 0, 2));
    final LocalDateDoubleTimeSeries referenceReturn = x[3] == null ? _returnCalculator.evaluate(x[2]) : _returnCalculator.evaluate(Arrays.copyOfRange(x, 2, 4));
    return assetReturn.subtract(referenceReturn);
  }
View Full Code Here

  public LocalDateDoubleTimeSeries evaluate(final LocalDateDoubleTimeSeries... x) {
    ArgumentChecker.notEmpty(x, "x");
    ArgumentChecker.notNull(x[0], "first time series");
    final LocalDateDoubleTimeSeries ts = x[0];
    if (ts.size() < 2) {
      throw new TimeSeriesException("Need at least two data points to calculate return series");
    }
    LocalDateDoubleTimeSeries d = null;
    if (x.length > 1) {
      if (x[1] != null) {
        d = x[1];
View Full Code Here

    while (iter1.hasNext()) {
      final int date = iter1.nextTimeFast();
      final Double value2 = ts2.getValue(date);
      if (value2 == null || Math.abs(value2) < ZERO) {
        if (getMode().equals(CalculationMode.STRICT)) {
          throw new TimeSeriesException("No data in second series for time " + iter1.currentTime());
        }
      } else {
        times[i] = iter1.currentTimeFast();
        returns[i++] = (iter1.currentValue() / value2 - 1);
      }
View Full Code Here

  public LocalDateDoubleTimeSeries evaluate(final LocalDateDoubleTimeSeries... x) {
    ArgumentChecker.notEmpty(x, "x");
    ArgumentChecker.notNull(x[0], "first time series");
    final LocalDateDoubleTimeSeries ts = x[0];
    if (ts.size() < 2) {
      throw new TimeSeriesException("Need at least two data points to calculate return series");
    }
    LocalDateDoubleTimeSeries d = null;
    if (x.length > 1) {
      if (x[1] != null) {
        d = x[1];
View Full Code Here

    Validate.notNull(x[1], "second time series");
    if (getMode() == CalculationMode.STRICT) {
      final int size = x[0].size();
      for (int i = 1; i < x.length; i++) {
        if (x[i].size() != size) {
          throw new TimeSeriesException("Time series were not all the same length");
        }
      }
      final List<?> times1 = x[0].times();
      List<?> times2;
      for (int i = 1; i < x.length; i++) {
        times2 = x[1].times();
        for (final Object t : times1) {
          if (!times2.contains(t)) {
            throw new TimeSeriesException("Time series did not contain all the same dates");
          }
        }
      }
    }
  }
View Full Code Here

   */
  @Override
  public LocalDateDoubleTimeSeries evaluate(final LocalDateDoubleTimeSeries... x) {
    Validate.notNull(x, "x");
    if (x.length < 4) {
      throw new TimeSeriesException("Time series array must contain at least four elements");
    }
    if (getMode() == CalculationMode.STRICT && x[0].size() != x[2].size()) {
      throw new TimeSeriesException("Asset price series and reference price series were not the same size");
    }
    final LocalDateDoubleTimeSeries assetReturn = x[1] == null ? _returnCalculator.evaluate(x[0]) : _returnCalculator.evaluate(x[0], x[1]);
    final LocalDateDoubleTimeSeries referenceReturn = x[3] == null ? _returnCalculator.evaluate(x[2]) : _returnCalculator.evaluate(x[2], x[3]);
    return assetReturn.subtract(referenceReturn);
  }
View Full Code Here

  public LocalDateDoubleTimeSeries evaluate(final LocalDateDoubleTimeSeries... x) {
    ArgumentChecker.notEmpty(x, "x");
    ArgumentChecker.notNull(x[0], "first time series");
    final LocalDateDoubleTimeSeries ts = x[0];
    if (ts.size() < 2) {
      throw new TimeSeriesException("Need at least two data points to calculate return series");
    }
    LocalDateDoubleTimeSeries d = null;
    if (x.length > 1) {
      if (x[1] != null) {
        d = x[1];
View Full Code Here

    boolean compare;
    while (highIter.hasNext()) {
      compare = highIter.next() < lowIter.next();
      if (compare) {
        if (_mode == CalculationMode.STRICT) {
          throw new TimeSeriesException("Not all values in the high series were greater than the values in the low series");
        }
        count++;
      }
    }
    final double percent = count / size;
    if (percent > _percentBadDataPoints) {
      throw new TimeSeriesException("Percent " + percent + " of bad data points is greater than " + _percentBadDataPoints);
    }
  }
View Full Code Here

TOP

Related Classes of com.opengamma.timeseries.TimeSeriesException

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.