Package com.opengamma.core.historicaltimeseries

Examples of com.opengamma.core.historicaltimeseries.HistoricalTimeSeries


  @Override
  public HistoricalTimeSeries getHistoricalTimeSeries(
      ExternalIdBundle identifiers, LocalDate identifierValidityDate, String dataSource, String dataProvider, String dataField,
      LocalDate start, boolean includeStart, LocalDate end, boolean includeEnd, int maxPoints) {
    HistoricalTimeSeries hts = getHistoricalTimeSeries(identifiers, identifierValidityDate, dataSource, dataProvider, dataField);
    return getSubSeries(hts, start, includeStart, end, includeEnd, maxPoints);
  }
View Full Code Here


  }
 
  public void clearSpecificDate() {
    RedisSimulationSeriesSource simulationSource = new RedisSimulationSeriesSource(getJedisPool(), getRedisPrefix());
    LocalDate simulationSeriesDate = LocalDate.now();
    HistoricalTimeSeries hts = null;
   
    int numDaysHistory = 5;
    for (int i = 0; i < numDaysHistory; i++) {
      writeOneSimulationSeriesDate(simulationSource, simulationSeriesDate, 5);
      simulationSeriesDate = simulationSeriesDate.minusDays(1);
View Full Code Here

  }

  @Override
  public Pair<LocalDate, Double> getLatestDataPoint(
      ExternalIdBundle identifiers, LocalDate identifierValidityDate, String dataSource, String dataProvider, String dataField) {
    HistoricalTimeSeries hts = getHistoricalTimeSeries(identifiers, identifierValidityDate, dataSource, dataProvider, dataField);
    if (hts == null || hts.getTimeSeries() == null || hts.getTimeSeries().isEmpty()) {
      return null;
    } else {
      return new ObjectsPair<LocalDate, Double>(hts.getTimeSeries().getLatestTime(), hts.getTimeSeries().getLatestValue());
    }
  }
View Full Code Here

  @Override
  public Pair<LocalDate, Double> getLatestDataPoint(
      ExternalIdBundle identifiers, LocalDate identifierValidityDate, String dataSource, String dataProvider, String dataField,
      LocalDate start, boolean includeStart, LocalDate end, boolean includeEnd) {
    HistoricalTimeSeries hts = getSubSeries(
        getHistoricalTimeSeries(identifiers, identifierValidityDate, dataSource, dataProvider, dataField),
        start, includeStart, end, includeEnd, -1);
    if (hts == null || hts.getTimeSeries() == null || hts.getTimeSeries().isEmpty()) {
      return null;
    } else {
      return new ObjectsPair<LocalDate, Double>(hts.getTimeSeries().getLatestTime(), hts.getTimeSeries().getLatestValue());
    }
  }
View Full Code Here

    }
  }

  @Override
  public Pair<LocalDate, Double> getLatestDataPoint(ExternalIdBundle identifierBundle, String dataSource, String dataProvider, String dataField) {
    HistoricalTimeSeries hts = getHistoricalTimeSeries(identifierBundle, (LocalDate) null, dataSource, dataProvider, dataField);
    if (hts == null || hts.getTimeSeries() == null || hts.getTimeSeries().isEmpty()) {
      return null;
    } else {
      return new ObjectsPair<LocalDate, Double>(hts.getTimeSeries().getLatestTime(), hts.getTimeSeries().getLatestValue());
    }
  }
View Full Code Here

  @Override
  public Pair<LocalDate, Double> getLatestDataPoint(
      ExternalIdBundle identifierBundle, String dataSource, String dataProvider, String dataField,
      LocalDate start, boolean includeStart, LocalDate end, boolean includeEnd) {
    HistoricalTimeSeries hts = getSubSeries(
        getHistoricalTimeSeries(identifierBundle, (LocalDate) null, dataSource, dataProvider, dataField),
        start, includeStart, end, includeEnd, -1);

    if (hts == null || hts.getTimeSeries() == null || hts.getTimeSeries().isEmpty()) {
      return null;
    } else {
      return new ObjectsPair<LocalDate, Double>(hts.getTimeSeries().getLatestTime(), hts.getTimeSeries().getLatestValue());
    }
  }
View Full Code Here

    tsBuilder.put(LocalDate.parse("2013-06-07"), 37.0);
    tsBuilder.put(LocalDate.parse("2013-06-08"), 38.0);
    source.updateTimeSeries(id3, tsBuilder.build());
   
    Pair<LocalDate, Double> pair = null;
    HistoricalTimeSeries hts = null;
    LocalDateDoubleTimeSeries ts = null;
   
    pair = source.getLatestDataPoint(id3);
    assertNotNull(pair);
    assertEquals(LocalDate.parse("2013-06-08"), pair.getFirst());
    assertEquals(38.0, pair.getSecond(), 0.000001);
   
    assertNull(source.getHistoricalTimeSeries(UniqueId.of("Test", "5")));
   
    hts = source.getHistoricalTimeSeries(id2);
    assertNotNull(hts);
    assertEquals(id2, hts.getUniqueId());
    ts = hts.getTimeSeries();
    assertNotNull(ts);
    assertEquals(5, ts.size());
    assertEquals(24.0, ts.getValue(LocalDate.parse("2013-06-04")), 0.00001);
    assertEquals(25.0, ts.getValue(LocalDate.parse("2013-06-05")), 0.00001);
    assertEquals(26.0, ts.getValue(LocalDate.parse("2013-06-06")), 0.00001);
    assertEquals(27.0, ts.getValue(LocalDate.parse("2013-06-07")), 0.00001);
    assertEquals(28.0, ts.getValue(LocalDate.parse("2013-06-08")), 0.00001);
   
    hts = source.getHistoricalTimeSeries(ExternalIdBundle.of(ExternalId.of("Test", "1")), LocalDate.now(), "Data Source", "Data Provider", "Data Field");
    assertNotNull(hts);
    assertEquals(id1, hts.getUniqueId());
    ts = hts.getTimeSeries();
    assertNotNull(ts);
    assertEquals(5, ts.size());
    assertEquals(14.0, ts.getValue(LocalDate.parse("2013-06-04")), 0.00001);
    assertEquals(15.0, ts.getValue(LocalDate.parse("2013-06-05")), 0.00001);
    assertEquals(16.0, ts.getValue(LocalDate.parse("2013-06-06")), 0.00001);
View Full Code Here

 
  public void updateDataPoint() {
    NonVersionedRedisHistoricalTimeSeriesSource source = new NonVersionedRedisHistoricalTimeSeriesSource(getJedisPool(), getRedisPrefix());
   
    UniqueId id = UniqueId.of("Test", "1");
    HistoricalTimeSeries hts = source.getHistoricalTimeSeries(id);
    assertNull(hts);
   
    LocalDateDoubleTimeSeriesBuilder tsBuilder = ImmutableLocalDateDoubleTimeSeries.builder();
    tsBuilder.put(LocalDate.parse("2013-06-04"), 14.0);
    tsBuilder.put(LocalDate.parse("2013-06-05"), 15.0);
    tsBuilder.put(LocalDate.parse("2013-06-06"), 16.0);
    tsBuilder.put(LocalDate.parse("2013-06-07"), 17.0);
    tsBuilder.put(LocalDate.parse("2013-06-08"), 18.0);
    source.updateTimeSeries(id, tsBuilder.build());
   
    hts = source.getHistoricalTimeSeries(id);
    assertNotNull(hts);
    assertEquals(id, hts.getUniqueId());
    LocalDateDoubleTimeSeries ts = hts.getTimeSeries();
    assertNotNull(ts);
    assertEquals(5, ts.size());
   
    assertEquals(14.0, ts.getValue(LocalDate.parse("2013-06-04")), 0.00001);
    source.updateTimeSeriesPoint(id, LocalDate.parse("2013-06-04"), 13.0);
    hts = source.getHistoricalTimeSeries(id);
    assertNotNull(hts);
    assertEquals(id, hts.getUniqueId());
    ts = hts.getTimeSeries();
    assertNotNull(ts);
    assertEquals(5, ts.size());
    assertEquals(13.0, ts.getValue(LocalDate.parse("2013-06-04")), 0.00001);
   
    assertEquals(16.0, ts.getValue(LocalDate.parse("2013-06-06")), 0.00001);
    source.updateTimeSeriesPoint(id, LocalDate.parse("2013-06-06"), 12.0);
    hts = source.getHistoricalTimeSeries(id);
    assertNotNull(hts);
    assertEquals(id, hts.getUniqueId());
    ts = hts.getTimeSeries();
    assertNotNull(ts);
    assertEquals(5, ts.size());
    assertEquals(12.0, ts.getValue(LocalDate.parse("2013-06-06")), 0.00001);
   
    assertEquals(18.0, ts.getValue(LocalDate.parse("2013-06-08")), 0.00001);
    source.updateTimeSeriesPoint(id, LocalDate.parse("2013-06-08"), 11.0);
    hts = source.getHistoricalTimeSeries(id);
    assertNotNull(hts);
    assertEquals(id, hts.getUniqueId());
    ts = hts.getTimeSeries();
    assertNotNull(ts);
    assertEquals(5, ts.size());
    assertEquals(11.0, ts.getValue(LocalDate.parse("2013-06-08")), 0.00001);
  }
View Full Code Here

 
  public void appendTimeSeries() {
    NonVersionedRedisHistoricalTimeSeriesSource source = new NonVersionedRedisHistoricalTimeSeriesSource(getJedisPool(), getRedisPrefix());
   
    UniqueId id = UniqueId.of("Test", "1");
    HistoricalTimeSeries hts = source.getHistoricalTimeSeries(id);
    assertNull(hts);
   
    LocalDateDoubleTimeSeriesBuilder tsBuilder = ImmutableLocalDateDoubleTimeSeries.builder();
    tsBuilder.put(LocalDate.parse("2013-06-04"), 14.0);
    tsBuilder.put(LocalDate.parse("2013-06-05"), 15.0);
    tsBuilder.put(LocalDate.parse("2013-06-06"), 16.0);
    tsBuilder.put(LocalDate.parse("2013-06-07"), 17.0);
    tsBuilder.put(LocalDate.parse("2013-06-08"), 18.0);
    source.updateTimeSeries(id, tsBuilder.build());
   
    hts = source.getHistoricalTimeSeries(id);
    assertNotNull(hts);
    assertEquals(id, hts.getUniqueId());
    LocalDateDoubleTimeSeries ts = hts.getTimeSeries();
    assertNotNull(ts);
    assertEquals(5, ts.size());
   
    tsBuilder = ImmutableLocalDateDoubleTimeSeries.builder();
    tsBuilder.put(LocalDate.parse("2013-06-09"), 19.0);
    tsBuilder.put(LocalDate.parse("2013-06-10"), 20.0);
    tsBuilder.put(LocalDate.parse("2013-06-11"), 21.0);
    tsBuilder.put(LocalDate.parse("2013-06-12"), 22.0);
    tsBuilder.put(LocalDate.parse("2013-06-13"), 23.0);
    source.updateTimeSeries(id, tsBuilder.build());
   
    hts = source.getHistoricalTimeSeries(id);
    assertNotNull(hts);
    assertEquals(id, hts.getUniqueId());
    ts = hts.getTimeSeries();
    assertNotNull(ts);
    assertEquals(10, ts.size());
  }
View Full Code Here

  }
 
  public void timeseriesRange() {
    NonVersionedRedisHistoricalTimeSeriesSource htsSource = new NonVersionedRedisHistoricalTimeSeriesSource(getJedisPool(), getRedisPrefix());
    UniqueId id = UniqueId.of("Test", "1");
    HistoricalTimeSeries hts = htsSource.getHistoricalTimeSeries(id);
    assertNull(hts);
   
    LocalDateDoubleTimeSeriesBuilder tsBuilder = ImmutableLocalDateDoubleTimeSeries.builder();
    tsBuilder.put(LocalDate.parse("2013-06-04"), 14.0);
    tsBuilder.put(LocalDate.parse("2013-06-05"), 15.0);
    tsBuilder.put(LocalDate.parse("2013-06-06"), 16.0);
    tsBuilder.put(LocalDate.parse("2013-06-07"), 17.0);
    tsBuilder.put(LocalDate.parse("2013-06-08"), 18.0);
    tsBuilder.put(LocalDate.parse("2013-06-09"), 24.0);
    tsBuilder.put(LocalDate.parse("2013-06-10"), 25.0);
    tsBuilder.put(LocalDate.parse("2013-06-11"), 26.0);
    tsBuilder.put(LocalDate.parse("2013-06-12"), 27.0);
    tsBuilder.put(LocalDate.parse("2013-06-13"), 28.0);
    tsBuilder.put(LocalDate.parse("2013-06-14"), 34.0);
    tsBuilder.put(LocalDate.parse("2013-06-15"), 35.0);
    tsBuilder.put(LocalDate.parse("2013-06-16"), 36.0);
    tsBuilder.put(LocalDate.parse("2013-06-17"), 37.0);
    tsBuilder.put(LocalDate.parse("2013-06-18"), 38.0);
   
    htsSource.updateTimeSeries(id, tsBuilder.build());
   
    hts = htsSource.getHistoricalTimeSeries(id);
    assertNotNull(hts);
    assertEquals(id, hts.getUniqueId());
   
    LocalDateDoubleTimeSeries ts = hts.getTimeSeries();
    assertEquals(15, ts.size());
    assertEquals(14.0, ts.getValue(LocalDate.parse("2013-06-04")), 0.00001);
    assertEquals(15.0, ts.getValue(LocalDate.parse("2013-06-05")), 0.00001);
    assertEquals(16.0, ts.getValue(LocalDate.parse("2013-06-06")), 0.00001);
    assertEquals(17.0, ts.getValue(LocalDate.parse("2013-06-07")), 0.00001);
    assertEquals(18.0, ts.getValue(LocalDate.parse("2013-06-08")), 0.00001);
    assertEquals(24.0, ts.getValue(LocalDate.parse("2013-06-09")), 0.00001);
    assertEquals(25.0, ts.getValue(LocalDate.parse("2013-06-10")), 0.00001);
    assertEquals(26.0, ts.getValue(LocalDate.parse("2013-06-11")), 0.00001);
    assertEquals(27.0, ts.getValue(LocalDate.parse("2013-06-12")), 0.00001);
    assertEquals(28.0, ts.getValue(LocalDate.parse("2013-06-13")), 0.00001);
    assertEquals(34.0, ts.getValue(LocalDate.parse("2013-06-14")), 0.00001);
    assertEquals(35.0, ts.getValue(LocalDate.parse("2013-06-15")), 0.00001);
    assertEquals(36.0, ts.getValue(LocalDate.parse("2013-06-16")), 0.00001);
    assertEquals(37.0, ts.getValue(LocalDate.parse("2013-06-17")), 0.00001);
    assertEquals(38.0, ts.getValue(LocalDate.parse("2013-06-18")), 0.00001);
   
    hts = htsSource.getHistoricalTimeSeries(id, LocalDate.parse("2013-06-04"), true, LocalDate.parse("2013-06-08"), true);
    assertNotNull(hts);
    assertEquals(id, hts.getUniqueId());
    ts = hts.getTimeSeries();
    assertEquals(5, ts.size());
    assertEquals(14.0, ts.getValue(LocalDate.parse("2013-06-04")), 0.00001);
    assertEquals(15.0, ts.getValue(LocalDate.parse("2013-06-05")), 0.00001);
    assertEquals(16.0, ts.getValue(LocalDate.parse("2013-06-06")), 0.00001);
    assertEquals(17.0, ts.getValue(LocalDate.parse("2013-06-07")), 0.00001);
    assertEquals(18.0, ts.getValue(LocalDate.parse("2013-06-08")), 0.00001);
   
    hts = htsSource.getHistoricalTimeSeries(id, LocalDate.parse("2013-06-04"), false, LocalDate.parse("2013-06-08"), true);
    assertNotNull(hts);
    assertEquals(id, hts.getUniqueId());
    ts = hts.getTimeSeries();
    assertEquals(4, ts.size());
    assertEquals(15.0, ts.getValue(LocalDate.parse("2013-06-05")), 0.00001);
    assertEquals(16.0, ts.getValue(LocalDate.parse("2013-06-06")), 0.00001);
    assertEquals(17.0, ts.getValue(LocalDate.parse("2013-06-07")), 0.00001);
    assertEquals(18.0, ts.getValue(LocalDate.parse("2013-06-08")), 0.00001);
   
    hts = htsSource.getHistoricalTimeSeries(id, LocalDate.parse("2013-06-04"), true, LocalDate.parse("2013-06-08"), false);
    assertNotNull(hts);
    assertEquals(id, hts.getUniqueId());
    ts = hts.getTimeSeries();
    assertEquals(4, ts.size());
    assertEquals(14.0, ts.getValue(LocalDate.parse("2013-06-04")), 0.00001);
    assertEquals(15.0, ts.getValue(LocalDate.parse("2013-06-05")), 0.00001);
    assertEquals(16.0, ts.getValue(LocalDate.parse("2013-06-06")), 0.00001);
    assertEquals(17.0, ts.getValue(LocalDate.parse("2013-06-07")), 0.00001);
   
    hts = htsSource.getHistoricalTimeSeries(id, LocalDate.parse("2013-06-04"), false, LocalDate.parse("2013-06-08"), false);
    assertNotNull(hts);
    assertEquals(id, hts.getUniqueId());
    ts = hts.getTimeSeries();
    assertEquals(3, ts.size());
    assertEquals(15.0, ts.getValue(LocalDate.parse("2013-06-05")), 0.00001);
    assertEquals(16.0, ts.getValue(LocalDate.parse("2013-06-06")), 0.00001);
    assertEquals(17.0, ts.getValue(LocalDate.parse("2013-06-07")), 0.00001);
   
View Full Code Here

TOP

Related Classes of com.opengamma.core.historicaltimeseries.HistoricalTimeSeries

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.