BloombergDataUtils { public static ExternalIdBundleWithDates parseIdentifiers(final FudgeMsg fieldData, final String firstTradeDateField, final String lastTradeDateField) { ArgumentChecker.notNull(fieldData, "fieldData"); final String bbgUnique = fieldData.getString(FIELD_ID_BBG_UNIQUE); final String cusip = fieldData.getString(FIELD_ID_CUSIP); final String isin = fieldData.getString(FIELD_ID_ISIN); final String sedol1 = fieldData.getString(FIELD_ID_SEDOL1); final String securityIdentifier = fieldData.getString(FIELD_PARSEKYABLE_DES); final String validFromStr = firstTradeDateField != null ? fieldData.getString(firstTradeDateField) : null; final String validToStr = lastTradeDateField != null ? fieldData.getString(lastTradeDateField) : null; final Set<ExternalIdWithDates> identifiers = new HashSet<ExternalIdWithDates>(); if (isValidField(bbgUnique)) { final ExternalId buid = ExternalSchemes.bloombergBuidSecurityId(bbgUnique); identifiers.add(ExternalIdWithDates.of(buid, null, null)); } if (isValidField(cusip)) { final ExternalId cusipId = ExternalSchemes.cusipSecurityId(cusip); identifiers.add(ExternalIdWithDates.of(cusipId, null, null)); } if (isValidField(sedol1)) { final ExternalId sedol1Id = ExternalSchemes.sedol1SecurityId(sedol1); identifiers.add(ExternalIdWithDates.of(sedol1Id, null, null)); } if (isValidField(isin)) { final ExternalId isinId = ExternalSchemes.isinSecurityId(isin); identifiers.add(ExternalIdWithDates.of(isinId, null, null)); } if (isValidField(securityIdentifier)) { final ExternalId tickerId = ExternalSchemes.bloombergTickerSecurityId(securityIdentifier.replaceAll("\\s+", " ")); LocalDate validFrom = null; if (isValidField(validFromStr)) { try { validFrom = LocalDate.parse(validFromStr); } catch (final DateTimeParseException ex) { s_logger.warn("valid from date not in yyyy-mm-dd format - {}", validFromStr); } } LocalDate validTo = null; if (isValidField(validToStr)) { try { validTo = LocalDate.parse(validToStr); } catch (final DateTimeParseException ex) { s_logger.warn("valid to date not in yyyy-mm-dd format - {}", validToStr); } } identifiers.add(ExternalIdWithDates.of(tickerId, validFrom, validTo)); } return new ExternalIdBundleWithDates(identifiers); } private  BloombergDataUtils(); static Collection<NormalizationRuleSet> getDefaultNormalizationRules(final ReferenceDataProvider referenceDataProvider, final CacheManager cacheManager, ExternalScheme bbgScheme); static HistoricalTimeSeriesFieldAdjustmentMap createFieldAdjustmentMap(final ReferenceDataProvider referenceDataProvider, final CacheManager cacheManager); static MarketDataAvailabilityFilter createAvailabilityFilter(); static FudgeMsg parseElement(final Element element); static Object parseValue(final Element valueElement); static String getSingleBUID(final ReferenceDataProvider refDataProvider, final String securityDes); static Map<String, String> getBUID(final ReferenceDataProvider refDataProvider, final Set<String> bloombergKeys); static Set<String> getIndexMembers(final ReferenceDataProvider refDataProvider, final String indexTicker); static Set<ExternalId> getOptionChain(final ReferenceDataProvider refDataProvider, final String securityID); static Set<ExternalId> getFuturechain(final ReferenceDataProvider refDataProvider, final String securityID); static boolean isValidField(final String name); static ExternalIdBundleWithDates parseIdentifiers(final FudgeMsg fieldData, final String firstTradeDateField, final String lastTradeDateField); static ExternalIdBundleWithDates addTwoDigitYearCode(final ExternalIdBundleWithDates bundleWithDates); static Set<ExternalIdBundle> getCurrentIdentifiers(final PositionMaster positionMaster); static String removeDuplicateWhiteSpace(final String field, final String replacement); static Set<ExternalId> identifierLoader(final Reader reader); static BiMap<String, ExternalIdBundle> convertToBloombergBuidKeys(final Collection<ExternalIdBundle> identifiers, final ReferenceDataProvider refDataProvider); static Pair<String, String> splitTickerAtMarketSector(final String ticker); static boolean isValidBloombergTicker(final String ticker); static ExternalId generateEquityOptionTicker(final String underlyingTicker, final Expiry expiry, final OptionType optionType, final double strike); static String dateToBbgCode(final LocalDate date); static ExternalId ricToBbgFuture(final String ric); static ExternalId ricToBbgFutureOption(final String ric, final boolean isCall, final double strike, final LocalDate expiry); static ExternalId futureBundleToGenericFutureTicker(ExternalIdBundle bundle, ZonedDateTime now, OffsetTime futureExpiryTime, ZoneId futureExpiryTimeZone); static String resolveDataProvider(final String dataProvider); static String resolveObservationTime(String dataProvider); static String toBloombergDate(LocalDate localDate); static String futureMonthCode(final Month month); static final List<String> STANDARD_FIELDS_LIST; static final Set<String> STANDARD_FIELDS_SET; }
@Test public void parseIdentifiers() throws Exception { Set<ExternalIdWithDates> identifiers = Sets.newHashSet( ExternalIdWithDates.of(ExternalSchemes.bloombergTickerSecurityId("EDU0 Comdty"), LocalDate.of(2010, Month.SEPTEMBER, 14), LocalDate.of(2020, Month.SEPTEMBER, 14)), ExternalIdWithDates.of(ExternalSchemes.bloombergBuidSecurityId("IX11084074-0"), null, null), ExternalIdWithDates.of(ExternalSchemes.cusipSecurityId("EDU0"), null, null)); ExternalIdBundleWithDates expected = new ExternalIdBundleWithDates(identifiers); MutableFudgeMsg message = new FudgeContext().newMessage(); message.add(FIELD_ID_BBG_UNIQUE, "IX11084074-0"); message.add(FIELD_ID_CUSIP, "EDU0"); message.add(FIELD_PARSEKYABLE_DES, "EDU0 Comdty"); message.add(FIELD_FUT_FIRST_TRADE_DT, "2010-09-14"); message.add(FIELD_FUT_LAST_TRADE_DT, "2020-09-14"); ExternalIdBundleWithDates actual = BloombergDataUtils.parseIdentifiers(message, FIELD_FUT_FIRST_TRADE_DT, FIELD_FUT_LAST_TRADE_DT); assertEquals(expected, actual); }