Package com.opengamma.timeseries.date.localdate

Examples of com.opengamma.timeseries.date.localdate.LocalDateDoubleTimeSeries


      throw new IllegalArgumentException("Need high, low and close time series to calculate high-low-close volatility");
    }
    if (x.length > 3) {
      s_logger.info("Time series array contained more than three series; only using the first three");
    }
    final LocalDateDoubleTimeSeries high = x[0];
    final LocalDateDoubleTimeSeries low = x[1];
    final LocalDateDoubleTimeSeries close = x[2];
    testHighLowClose(high, low, close);
    final LocalDateDoubleTimeSeries closeReturns = _returnCalculator.evaluate(close);
    final LocalDateDoubleTimeSeries highLowReturns = _relativeReturnCalculator.evaluate(new LocalDateDoubleTimeSeries[] {high, low});
    final Iterator<Double> highLowIterator = highLowReturns.valuesIterator();
    final Iterator<Double> closeReturnIterator = closeReturns.valuesIterator();
    double value, highLowValue;
    double sumHL = 0;
    double sum = 0;
    highLowIterator.next();
View Full Code Here


        rate);
    final HistoricalTimeSeries ts = _timeSeries.get(MarketDataRequirementNames.MARKET_VALUE, priceIndexConvention.getPriceIndexId());
    if (ts == null) {
      throw new OpenGammaRuntimeException("Could not get price index time series with id " + priceIndexConvention.getPriceIndexId());
    }
    final LocalDateDoubleTimeSeries localDateTS = ts.getTimeSeries();
    final DoubleTimeSeries<ZonedDateTime> priceIndexTimeSeries = convertTimeSeries(zone, localDateTS);
    final int conventionalMonthLag = inflationLegConvention.getMonthLag();
    final int monthLag = inflationLegConvention.getMonthLag();
    final IndexPrice index = new IndexPrice(priceIndexConvention.getName(), currency);
    switch (inflationNode.getInflationNodeType()) {
View Full Code Here

  @Test(enabled = false)
  public void largePerformanceTestOneDataPoint() {
    NonVersionedRedisHistoricalTimeSeriesSource source = new NonVersionedRedisHistoricalTimeSeriesSource(getJedisPool(), getRedisPrefix());
    HistoricalTimeSeries hts = createSampleHts();
    long start = System.nanoTime();
    LocalDateDoubleTimeSeries timeSeries = hts.getTimeSeries();
    for (Entry<LocalDate, Double> entry : timeSeries) {
      source.updateTimeSeriesPoint(hts.getUniqueId(), entry.getKey(), entry.getValue());
    }
    long end = System.nanoTime();
    double durationInSec = ((double) (end - start)) / 1e9;
View Full Code Here

   
  protected LocalDateDoubleTimeSeries loadTimeSeriesFromRedis(String redisKey, LocalDate start, LocalDate end) {
    // This is the only method that needs implementation.
    try (Timer.Context context = _getSeriesTimer.time()) {
      Jedis jedis = getJedisPool().getResource();
      LocalDateDoubleTimeSeries ts = null;
      try {
        String redisHtsDaysKey = toRedisHtsDaysKey(redisKey);
        double min = Double.NEGATIVE_INFINITY;
        double max = Double.POSITIVE_INFINITY;
        if (start != null) {
View Full Code Here

      } else {
        actualEnd = end.minusDays(1);
      }
    }
   
    LocalDateDoubleTimeSeries ts = loadTimeSeriesFromRedis(toRedisKey(uniqueId), actualStart, actualEnd);
    SimpleHistoricalTimeSeries result = null;
    if (ts != null) {
      result = new SimpleHistoricalTimeSeries(uniqueId, ts);
    }
    return result;
View Full Code Here

  }

  public HistoricalTimeSeries getHistoricalTimeSeries(UniqueId uniqueId) {
    ArgumentChecker.notNull(uniqueId, "uniqueId");
   
    LocalDateDoubleTimeSeries ts = loadTimeSeriesFromRedis(toRedisKey(uniqueId), null, null);
    if (ts == null) {
      return null;
    } else {
      return new SimpleHistoricalTimeSeries(uniqueId, ts);
    }
View Full Code Here

  @Override
  public Pair<LocalDate, Double> getLatestDataPoint(UniqueId uniqueId) {
    ArgumentChecker.notNull(uniqueId, "uniqueId");
   
    Pair<LocalDate, Double> latestPoint = null;
    LocalDateDoubleTimeSeries ts = loadTimeSeriesFromRedis(toRedisKey(uniqueId), null, null);
    if (ts != null) {
      latestPoint = Pair.of(ts.getLatestTime(), ts.getLatestValue());
    }
    return latestPoint;
  }
View Full Code Here

  }
 
  protected HistoricalTimeSeries getHistoricalTimeSeries(ExternalIdBundle identifierBundle) {
    UniqueId uniqueId = toUniqueId(identifierBundle);
   
    LocalDateDoubleTimeSeries ts = getLocalDateDoubleTimeSeries(identifierBundle);
    HistoricalTimeSeries hts = new SimpleHistoricalTimeSeries(uniqueId, ts);
    return hts;
  }
View Full Code Here

    F.getSampledTimeSeries(TS_NO_MISSING_DATA, null);
  }

  @Test
  public void testNoMissingData() {
    final LocalDateDoubleTimeSeries result = F.getSampledTimeSeries(TS_NO_MISSING_DATA, DAILY_SCHEDULE);
    assertEquals(TS_NO_MISSING_DATA.size(), result.size());
    int i = 0;
    for (final Entry<LocalDate, Double> entry : result) {
      assertEquals(TS_NO_MISSING_DATA.getTimeAtIndex(i), entry.getKey());
      assertEquals(TS_NO_MISSING_DATA.getValueAtIndex(i++), entry.getValue(), 0);
    }
View Full Code Here

    }
  }

  @Test
  public void testOneDayMissingData() {
    final LocalDateDoubleTimeSeries result = F.getSampledTimeSeries(TS_MISSING_DATA, DAILY_SCHEDULE);
    assertEquals(result.size(), TS_MISSING_DATA.size());
    int i = 0;
    for (final Entry<LocalDate, Double> entry : result) {
      assertEquals(TS_MISSING_DATA.getTimeAtIndex(i), entry.getKey());
      if (entry.getKey().equals(MISSING_DAY_TUESDAY)) {
        assertEquals(TS_MISSING_DATA.getValueAtIndex(i - 1), entry.getValue(), 0);
View Full Code Here

TOP

Related Classes of com.opengamma.timeseries.date.localdate.LocalDateDoubleTimeSeries

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.