Package com.opengamma.timeseries.date.localdate

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


    }
  }

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


    while (date.isBefore(lastDate)) {
      dates.add(date);
      fixings.add(FIXING_RATE);
      date = date.plusDays(1);
    }
    final LocalDateDoubleTimeSeries fixingSeries = ImmutableLocalDateDoubleTimeSeries.of(dates, fixings);
    final Set<InstrumentDefinition<?>> floatingInstruments = new HashSet<>(INSTRUMENTS_WITH_MANDATORY_FIXING_SERIES);
    floatingInstruments.addAll(INSTRUMENTS_WITH_OPTIONAL_FIXING_SERIES);
    for (final InstrumentDefinition<?> definition : floatingInstruments) {
      try {
        definition.accept(VISITOR, fixingSeries);
View Full Code Here

    F.getSampledTimeSeries(TS_NO_MISSING_DATA, null);
  }

  @Test
  public void testNoMissingDataDaily() {
    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 testNoMissingDataWeekly() {
    final LocalDateDoubleTimeSeries result = F.getSampledTimeSeries(TS_NO_MISSING_DATA, TUESDAY_SCHEDULE);
    assertEquals(TUESDAY_SCHEDULE.length, result.size());
    int i = 0, j = 3;
    for (final Entry<LocalDate, Double> entry : result) {
      assertEquals(TUESDAY_SCHEDULE[i++], entry.getKey());
      assertEquals(j, entry.getValue(), 0);
      j += 5;
View Full Code Here

    }
  }

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

  @Override
  protected LocalDateDoubleTimeSeries getReturnSeries(final LocalDateDoubleTimeSeries spotSeries, final ValueRequirement desiredValue) {
    final double lambda = Double.parseDouble(desiredValue.getConstraint(VolatilityWeightingFunctionUtils.VOLATILITY_WEIGHTING_LAMBDA_PROPERTY));
    final TimeSeriesWeightedVolatilityOperator weightedVolOp = new TimeSeriesWeightedVolatilityOperator(lambda);
    final LocalDateDoubleTimeSeries weightedVolSeries = (LocalDateDoubleTimeSeries) weightedVolOp.evaluate(spotSeries);
    return (LocalDateDoubleTimeSeries) RELATIVE_WEIGHTED_DIFFERENCE.evaluate(spotSeries, weightedVolSeries);
  }
View Full Code Here

  public Pair<LocalDate, Double> getLatestDataPoint(
      ExternalIdBundle externalIdBundle, String dataSource, String dataProvider, String dataField) {
   
    HistoricalTimeSeriesProviderGetRequest request = HistoricalTimeSeriesProviderGetRequest.createGetLatest(externalIdBundle, dataSource, dataProvider, dataField);
    HistoricalTimeSeriesProviderGetResult result = getHistoricalTimeSeries(request);
    LocalDateDoubleTimeSeries series = result.getResultMap().get(externalIdBundle);
    if (series == null || series.isEmpty()) {
      return null;
    }
    return Pair.of(series.getLatestTime(), series.getLatestValue());
  }
View Full Code Here

  public Pair<LocalDate, Double> getLatestDataPoint(
      ExternalIdBundle externalIdBundle, String dataSource, String dataProvider, String dataField) {
   
    HistoricalTimeSeriesProviderGetRequest request = HistoricalTimeSeriesProviderGetRequest.createGetLatest(externalIdBundle, dataSource, dataProvider, dataField);
    HistoricalTimeSeriesProviderGetResult result = getHistoricalTimeSeries(request);
    LocalDateDoubleTimeSeries series = result.getResultMap().get(externalIdBundle);
    if (series == null || series.isEmpty()) {
      return null;
    }
    return Pair.of(series.getLatestTime(), series.getLatestValue());
  }
View Full Code Here

   */
  protected HistoricalTimeSeriesProviderGetResult filterResult(
      HistoricalTimeSeriesProviderGetResult result, LocalDateRange dateRange, Integer maxPoints) {
   
    for (Map.Entry<ExternalIdBundle, LocalDateDoubleTimeSeries> entry : result.getResultMap().entrySet()) {
      LocalDateDoubleTimeSeries hts = entry.getValue();
      if (hts != null) {
        LocalDateDoubleTimeSeries filtered = filterResult(hts, dateRange, maxPoints);
        entry.setValue(filtered);
      }
    }
    return result;
  }
View Full Code Here

   
    // find in cache
    Set<ExternalIdBundle> remainingIds = new HashSet<ExternalIdBundle>();
    for (ExternalIdBundle bundle : request.getExternalIdBundles()) {
      HistoricalTimeSeriesProviderGetRequest key = createCacheKey(request, bundle, false);
      LocalDateDoubleTimeSeries cached = doSingleGetInCache(key);
      if (cached != null) {
        if (cached == NO_HTS) {
          result.getResultMap().put(bundle, null);
        } else {
          result.getResultMap().put(bundle, cached);
        }
      } else {
        remainingIds.add(bundle);
      }
    }
   
    // find in underlying
    if (remainingIds.size() > 0) {
      HistoricalTimeSeriesProviderGetRequest underlyingAllRequest = JodaBeanUtils.clone(request);
      underlyingAllRequest.setExternalIdBundles(remainingIds);
      underlyingAllRequest.setDateRange(LocalDateRange.ALL);
      underlyingAllRequest.setMaxPoints(null);
      HistoricalTimeSeriesProviderGetResult underlyingAllResult = _underlying.getHistoricalTimeSeries(underlyingAllRequest);
     
      // cache result for whole time-series
      for (ExternalIdBundle bundle : remainingIds) {
        LocalDateDoubleTimeSeries underlyingWholeHts = underlyingAllResult.getResultMap().get(bundle);
        if (underlyingWholeHts == null) {
          underlyingWholeHts = NO_HTS;
        }
        HistoricalTimeSeriesProviderGetRequest wholeHtsKey = createCacheKey(underlyingAllRequest, bundle, true);
        _cache.put(new Element(wholeHtsKey, underlyingWholeHts));
      }
     
      // cache result for requested time-series
      HistoricalTimeSeriesProviderGetResult fiteredResult = filterResult(underlyingAllResult, request.getDateRange(), request.getMaxPoints());
      for (ExternalIdBundle bundle : remainingIds) {
        LocalDateDoubleTimeSeries filteredHts = fiteredResult.getResultMap().get(bundle);
        result.getResultMap().put(bundle, filteredHts);
        if (filteredHts == null) {
          filteredHts = NO_HTS;
        }
        HistoricalTimeSeriesProviderGetRequest key = createCacheKey(request, bundle, false);
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.