// Filter points by date range and max points to return
// Heeds LocalDateDoubleTimeSeries convention: inclusive start, exclusive end
LocalDateDoubleTimeSeries subSeries = existingSeries.subSeries(fromDateInclusive, toDateInclusive.plusDays(1));
Integer maxPoints = filter.getMaxPoints();
if (((maxPoints != null) && (Math.abs(maxPoints) < subSeries.size()))) {
subSeries = maxPoints >= 0 ? subSeries.head(maxPoints) : subSeries.tail(-maxPoints);
}
final ManageableHistoricalTimeSeries result = new ManageableHistoricalTimeSeries();
result.setUniqueId(objectId.atLatestVersion());
result.setTimeSeries(subSeries);