Package com.opengamma.timeseries.date.localdate

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


   
    UniqueId id1 = UniqueId.of("Test", "1");
    UniqueId id2 = UniqueId.of("Test", "2");
    UniqueId id3 = UniqueId.of("Test", "3");
   
    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(id1, tsBuilder.build());
   
    tsBuilder = ImmutableLocalDateDoubleTimeSeries.builder();
    tsBuilder.put(LocalDate.parse("2013-06-04"), 24.0);
    tsBuilder.put(LocalDate.parse("2013-06-05"), 25.0);
    tsBuilder.put(LocalDate.parse("2013-06-06"), 26.0);
    tsBuilder.put(LocalDate.parse("2013-06-07"), 27.0);
    tsBuilder.put(LocalDate.parse("2013-06-08"), 28.0);
    source.updateTimeSeries(id2, tsBuilder.build());

    tsBuilder = ImmutableLocalDateDoubleTimeSeries.builder();
    tsBuilder.put(LocalDate.parse("2013-06-04"), 34.0);
    tsBuilder.put(LocalDate.parse("2013-06-05"), 35.0);
    tsBuilder.put(LocalDate.parse("2013-06-06"), 36.0);
    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;
   
View Full Code Here


   
    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();
View Full Code Here

   
    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();
View Full Code Here

    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());
   
View Full Code Here

    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());
   
View Full Code Here

    System.out.println("Reading " + hts.getTimeSeries().size() + " datapoints took " + totalDurationInSec/ITER_SIZE + " sec");
  }
 
  private HistoricalTimeSeries createSampleHts() {
    UniqueId id = UniqueId.of("HTS", UUID.randomUUID().toString());
    LocalDateDoubleTimeSeriesBuilder builder = ImmutableLocalDateDoubleTimeSeries.builder();
    LocalDate start = LocalDate.now();
    for (int i = 0; i < 50000; i++) {
      builder.put(start.plusDays(i), Math.random());
    }
    return new SimpleHistoricalTimeSeries(id, builder.build());
  }
View Full Code Here

   
    updateTimeSeriesPoint(toRedisKey(uniqueId), valueDate, value);
  }
 
  protected void updateTimeSeriesPoint(String redisKey, LocalDate valueDate, double value) {
    LocalDateDoubleTimeSeriesBuilder builder = ImmutableLocalDateDoubleTimeSeries.builder();
    builder.put(valueDate, value);
    updateTimeSeries(redisKey, builder.build());
  }
View Full Code Here

    @SuppressWarnings({"rawtypes", "unchecked" })
    private static Map<ExternalIdBundle, LocalDateDoubleTimeSeries> convertResult(Map result) {
      // ignore generics, which is safe as of JDK8
      for (Object o : result.entrySet()) {
        Entry entry = (Entry) o;
        LocalDateDoubleTimeSeriesBuilder bld = (LocalDateDoubleTimeSeriesBuilder) entry.getValue();
        entry.setValue(bld.build());
      }
      return (Map<ExternalIdBundle, LocalDateDoubleTimeSeries>) result;
    }
View Full Code Here

      ExternalIdBundle identifiers = reverseBundleMap.get(secDes);
      if (identifiers == null) {
        String message = "Found time series data for unrecognized security" + secDes + " " + reverseBundleMap;
        throw new OpenGammaRuntimeException(message);
      }
      LocalDateDoubleTimeSeriesBuilder bld = result.get(identifiers);
      if (bld == null) {
        bld = ImmutableLocalDateDoubleTimeSeries.builder();
        result.put(identifiers, bld);
      }
      Element fieldDataArray = securityElem.getElement(FIELD_DATA);

      int numValues = fieldDataArray.numValues();
      for (int i = 0; i < numValues; i++) {
        Element fieldData = fieldDataArray.getValueAsElement(i);
        Datetime date = fieldData.getElementAsDate("date");
        LocalDate ldate = LocalDate.of(date.year(), date.month(), date.dayOfMonth());
        double lastPrice = fieldData.getElementAsFloat64(field);
        bld.put(ldate, lastPrice);
      }
    }
View Full Code Here

      }
      return new HistoricalTimeSeriesProviderGetResult(tsMap);
    }

    private LocalDateDoubleTimeSeries makeRandomTimeSeries(LocalDate start, LocalDate end) {
      LocalDateDoubleTimeSeriesBuilder tsMap = ImmutableLocalDateDoubleTimeSeries.builder();
      LocalDate current = start;
      tsMap.put(current, Math.random());
      while (current.isBefore(end)) {
        current = current.plusDays(1);
        if (isWeekday(current)) {
          tsMap.put(current, Math.random());
        }
      }
      return tsMap.build();
    }
View Full Code Here

TOP

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

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.