예제 #1
0
 private void processFieldData(
     Element securityElem,
     String field,
     Map<String, ExternalIdBundle> bbgSecDomainMap,
     Map<ExternalIdBundle, HistoricalTimeSeries> result) {
   String secDes = securityElem.getElementAsString(BloombergConstants.SECURITY);
   ExternalIdBundle identifiers = bbgSecDomainMap.get(secDes);
   if (identifiers == null) {
     String message =
         "Found time series data for unrecognized security" + secDes + " " + bbgSecDomainMap;
     throw new OpenGammaRuntimeException(message);
   }
   HistoricalTimeSeries hts = result.get(identifiers);
   MapLocalDateDoubleTimeSeries timeSeries;
   if (hts == null) {
     timeSeries = new MapLocalDateDoubleTimeSeries();
     hts = new SimpleHistoricalTimeSeries(UID_SUPPLIER.get(), timeSeries);
     result.put(identifiers, hts);
   } else {
     timeSeries = (MapLocalDateDoubleTimeSeries) hts.getTimeSeries();
   }
   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");
     double lastPrice = fieldData.getElementAsFloat64(field);
     int year = date.year();
     int month = date.month();
     int day = date.dayOfMonth();
     timeSeries.putDataPoint(LocalDate.of(year, month, day), lastPrice);
   }
 }
예제 #2
0
 protected void processFieldData(
     final Element fieldDataArray,
     String field,
     final List<LocalDate> dates,
     final List<Double> values) {
   int numValues = fieldDataArray.numValues();
   for (int i = 0; i < numValues; i++) {
     Element fieldData = fieldDataArray.getValueAsElement(i);
     Datetime date = fieldData.getElementAsDate("date");
     double fieldValue = fieldData.getElementAsFloat64(field);
     dates.add(LocalDate.of(date.year(), date.month(), date.dayOfMonth()));
     values.add(fieldValue);
   }
 }