TradingUtils { public static final int getSign(String currencyInstrument, TradingSignal side, String currency) { int sign = 0; if (currencyInstrument.contains(currency)) { String[] ccyPairs = splitInstrumentPair(currencyInstrument); if ((currency.equals(ccyPairs[0]) && side == TradingSignal.LONG) || (currency.equals(ccyPairs[1]) && side == TradingSignal.SHORT)) { return 1; } else { return -1; } } return sign; } private  TradingUtils(); static final String executingRequestMsg(HttpRequest request); static long toUnixTime(DateTime dateTime); static long toMillisFromNanos(long nanos); static String[] splitCcyPair(String instrument, String currencySeparator); static double calculateTakeProfitPrice(double tickSize, TradingSignal signal, double bidPrice,
			double askPrice, int pipsDesired); static final String responseToString(HttpResponse response); static final boolean isEmpty(Collection<?> collection); static final boolean isEmpty(Map<?, ?> map); static String[] splitInstrumentPair(String instrument); static final int getSign(String currencyInstrument, TradingSignal side, String currency); static void closeSilently(CloseableHttpClient httpClient); static void printErrorMsg(HttpResponse response); static String getResponse(HttpResponse response); static final int CCY_PAIR_LEN; static final int CCY_SEP_CHR_POS; }
@Test public void getSignTest() { assertEquals(1, TradingUtils.getSign("CAD_CHF", TradingSignal.LONG, "CAD")); assertEquals(-1, TradingUtils.getSign("NZD_USD", TradingSignal.LONG, "USD")); assertEquals(-1, TradingUtils.getSign("AUD_JPY", TradingSignal.SHORT, "AUD")); assertEquals(1, TradingUtils.getSign("EUR_CHF", TradingSignal.SHORT, "CHF")); assertEquals(0, TradingUtils.getSign("EUR_GBP", TradingSignal.SHORT, "USD")); }