1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| private static Logger logger = LoggerFactory.getLogger(CcPairService.class);
private static final Map<String, Term> termMapByString = new HashMap<>();
private static final Map<FixTenorEnum, Term> termMapByFixTenor = new HashMap<>();
private static final Map<String, CcPair> ccPairMapBySymbol = new ConcurrentHashMap<>();
public static final char TERM_DELIMITER_CHARACTER = '-';
static {
termMapByString.put("", Term.SPOT);
termMapByString.put(Term.ON_Name, Term.T0);
termMapByString.put("T+0", Term.T0);
termMapByString.put(Term.TOM_Name, Term.T1);
termMapByString.put("T+1", Term.T1);
termMapByString.put(Term.SP_NAME, Term.T2);
termMapByString.put(Term.TWODAY_NAME, Term.T2);
termMapByString.put("T+2", Term.T2);
termMapByString.put("1W", Term.T1W);
termMapByString.put("2W", Term.T2W);
termMapByString.put("3W", Term.T3W);
termMapByString.put("1M", Term.T1M);
termMapByString.put("2M", Term.T2M);
termMapByString.put("3M", Term.T3M);
termMapByString.put("4M", Term.T4M);
termMapByString.put("5M", Term.T5M);
termMapByString.put("6M", Term.T6M);
termMapByString.put("7M", Term.T7M);
termMapByString.put("8M", Term.T8M);
termMapByString.put("9M", Term.T9M);
termMapByString.put("10M", Term.T10M);
termMapByString.put("11M", Term.T11M);
termMapByString.put("15M", Term.T15M);
termMapByString.put("18M", Term.T18M);
termMapByString.put("1Y", Term.T1Y);
termMapByString.put("2Y", Term.T2Y);
termMapByString.put("3Y", Term.T3Y);
termMapByString.put("4Y", Term.T4Y);
termMapByString.put("5Y", Term.T5Y);
termMapByString.put("6Y", Term.T6Y);
termMapByString.put("7Y", Term.T7Y);
termMapByString.put("8Y", Term.T8Y);
termMapByString.put("9Y", Term.T9Y);
termMapByString.put("10Y", Term.T10Y);
termMapByFixTenor.put(FixTenorEnum.SPOT, Term.SPOT);
termMapByFixTenor.put(FixTenorEnum.T0, Term.T0);
termMapByFixTenor.put(FixTenorEnum.T1, Term.T1);
termMapByFixTenor.put(FixTenorEnum.T2, Term.T2);
termMapByFixTenor.put(FixTenorEnum.T1W, Term.T1W);
termMapByFixTenor.put(FixTenorEnum.T2W, Term.T2W);
termMapByFixTenor.put(FixTenorEnum.T3W, Term.T3W);
termMapByFixTenor.put(FixTenorEnum.T1M, Term.T1M);
termMapByFixTenor.put(FixTenorEnum.T2M, Term.T2M);
termMapByFixTenor.put(FixTenorEnum.T3M, Term.T3M);
termMapByFixTenor.put(FixTenorEnum.T4M, Term.T4M);
termMapByFixTenor.put(FixTenorEnum.T5M, Term.T5M);
termMapByFixTenor.put(FixTenorEnum.T6M, Term.T6M);
termMapByFixTenor.put(FixTenorEnum.T7M, Term.T7M);
termMapByFixTenor.put(FixTenorEnum.T8M, Term.T8M);
termMapByFixTenor.put(FixTenorEnum.T9M, Term.T9M);
termMapByFixTenor.put(FixTenorEnum.T10M, Term.T10M);
termMapByFixTenor.put(FixTenorEnum.T11M, Term.T11M);
termMapByFixTenor.put(FixTenorEnum.T15M, Term.T15M);
termMapByFixTenor.put(FixTenorEnum.T18M, Term.T18M);
termMapByFixTenor.put(FixTenorEnum.T1Y, Term.T1Y);
termMapByFixTenor.put(FixTenorEnum.T2Y, Term.T2Y);
termMapByFixTenor.put(FixTenorEnum.T3Y, Term.T3Y);
termMapByFixTenor.put(FixTenorEnum.T4Y, Term.T4Y);
termMapByFixTenor.put(FixTenorEnum.T5Y, Term.T5Y);
termMapByFixTenor.put(FixTenorEnum.T6Y, Term.T6Y);
termMapByFixTenor.put(FixTenorEnum.T7Y, Term.T7Y);
termMapByFixTenor.put(FixTenorEnum.T8Y, Term.T8Y);
termMapByFixTenor.put(FixTenorEnum.T9Y, Term.T9Y);
termMapByFixTenor.put(FixTenorEnum.T10Y, Term.T10Y);
}
/**
* Build a CcPair instance according to the given symbol
* @param symbol
* @return CcPair instance
*/
public static CcPair buildCcPair(String symbol) {
CcPair ccPair = ccPairMapBySymbol.get(symbol);
if (ccPair == null) {
List<String> split = splitCcPairSymbol(symbol);
String ccy1 = split.get(0);
String ccy2 = split.get(1);
String term = null;
if (split.size() == 3) {
term = split.get(2);
}
ccPair = buildCcPair(ccy1, ccy2, term);
ccPairMapBySymbol.put(symbol, ccPair);
}
return ccPair;
} |
Partager