private static Pair<Currency, Currency> getFXPairFromBloombergTicker(final ExternalId id) {
if (id.getScheme().equals(ExternalSchemes.BLOOMBERG_TICKER) || id.getScheme().equals(ExternalSchemes.BLOOMBERG_TICKER_WEAK)) {
final String ticker = id.getValue();
final String[] split = ticker.split(" ");
if (split.length != 2) {
throw new OpenGammaRuntimeException("ticker contained more than one space:" + ticker);
}
if (!split[1].equals("Curncy")) {
throw new OpenGammaRuntimeException("ticker did not end with Curncy:" + ticker);
}
final String ccyPart = split[0];
switch (ccyPart.length()) {
case 3:
{
final Currency ccy = Currency.of(ccyPart);
if (StandardCurrencyPairs.isSingleCurrencyNumerator(ccy)) {
return Pair.of(ccy, Currency.USD);
} else {
return Pair.of(Currency.USD, ccy);
}
}
case 6:
{
final Currency numerator = Currency.of(ccyPart.substring(0, 3));
final Currency denominator = Currency.of(ccyPart.substring(3));
return Pair.of(numerator, denominator);
}
default:
throw new OpenGammaRuntimeException("currency part of ticker did not have 3 or 6 characters" + ticker);
}
} else {
throw new OpenGammaRuntimeException("id was not bloomberg ticker or bloomberg weak ticker" + id);
}
}