}
private Set<ExternalIdBundle> loadOptionIdentifiers(final Set<ExternalIdBundle> identifiers) {
Set<String> bloombergKeys = new HashSet<String>();
for (ExternalIdBundle dsids : identifiers) {
ExternalId preferredIdentifier = BloombergDomainIdentifierResolver.resolvePreferredIdentifier(dsids);
bloombergKeys.add(BloombergDomainIdentifierResolver.toBloombergKey(preferredIdentifier));
}
Set<ExternalIdBundle> optionsIdentifiers = new HashSet<ExternalIdBundle>();
Map<String, FudgeMsg> refDataResultMap = _refDataProvider.getReferenceDataIgnoreCache(bloombergKeys, Collections.singleton(FIELD_OPT_CHAIN));
for (Entry<String, FudgeMsg> entry : refDataResultMap.entrySet()) {
FudgeMsg fieldContainer = entry.getValue();
//process the options
int nAdded = 0;
for (FudgeField field : fieldContainer.getAllByName(BloombergConstants.FIELD_OPT_CHAIN)) {
FudgeMsg optionContainer = (FudgeMsg) field.getValue();
String optionTickerStr = optionContainer.getString("Security Description");
String expiryStr = ReferenceDataProviderUtils.singleFieldSearchIgnoreCache(optionTickerStr, FIELD_OPT_EXPIRE_DT, _refDataProvider);
LocalDate expiryLocalDate = null;
try {
expiryLocalDate = LocalDate.parse(expiryStr);
} catch (Exception e) {
throw new OpenGammaRuntimeException(expiryStr + " returned from bloomberg not in format yyyy-mm-dd", e);
}
int year = expiryLocalDate.getYear();
int month = expiryLocalDate.getMonthValue();
int day = expiryLocalDate.getDayOfMonth();
Expiry expiry = new Expiry(DateUtils.getUTCDate(year, month, day));
if (expiry.getExpiry().toInstant().toEpochMilli() < (System.currentTimeMillis() + (25L * 60L * 60L * 1000L))) {
s_logger.info("Option {} in future, so passing on it.", optionTickerStr);
continue;
}
ExternalId optionTicker = ExternalSchemes.bloombergTickerSecurityId(optionTickerStr);
optionsIdentifiers.add(ExternalIdBundle.of(optionTicker));
nAdded++;
if (nAdded >= _optionSize) {
break;