private List<FactorExposure> convertToFactorExposure( List<FactorExposureData> factorExposureDataList) { List<FactorExposure> results = new ArrayList<FactorExposure>(); for (FactorExposureData exposure : factorExposureDataList) { HistoricalTimeSeries exposureHTS = data() .getHistoricalTimeSeriesSource() .getHistoricalTimeSeries( "EXPOSURE", exposure.getExposureExternalId().toBundle(), null); HistoricalTimeSeries convexityHTS = data() .getHistoricalTimeSeriesSource() .getHistoricalTimeSeries( "CONVEXITY", exposure.getExposureExternalId().toBundle(), null); HistoricalTimeSeries priceHTS = data() .getHistoricalTimeSeriesSource() .getHistoricalTimeSeries("PX_LAST", exposure.getFactorExternalId().toBundle(), null); results.add( new FactorExposure( exposure.getFactorType().getFactorType(), exposure.getFactorName(), exposure.getNode(), priceHTS != null ? priceHTS.getUniqueId() : null, priceHTS != null ? priceHTS.getTimeSeries().getLatestValue() : null, exposureHTS != null ? exposureHTS.getUniqueId() : null, exposureHTS != null ? exposureHTS.getTimeSeries().getLatestValue() : null, convexityHTS != null ? convexityHTS.getUniqueId() : null, convexityHTS != null ? convexityHTS.getTimeSeries().getLatestValue() : null)); } return results; }
private FactorExposureData searchForBondTenorMatch( final Collection<FactorExposureData> exposures, final FixedIncomeStripWithSecurity strip) { for (final FactorExposureData exposure : exposures) { if (exposure.getFactorType().equals(FactorType.YIELD) && exposure.getFactorName().contains(BOND_TEXT)) { if (exposure.getNode() != null && exposure.getNode().length() > 0) { final Period nodePeriod = Period.parse("P" + exposure.getNode()); if (strip.getTenor().getPeriod().toTotalMonths() == nodePeriod.toTotalMonths()) { return exposure; } } } } return null; }