TradingUtils { public static double calculateTakeProfitPrice(double tickSize, TradingSignal signal, double bidPrice, double askPrice, int pipsDesired) { switch (signal) { case LONG: return askPrice + tickSize * pipsDesired; case SHORT: return bidPrice - tickSize * pipsDesired; default: return 0.0; } } 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 calculateTakeProfitPriceTest() { double tpPrice = TradingUtils.calculateTakeProfitPrice(0.0001, TradingSignal.LONG, 1.11351, 1.11364, 45); assertEquals(1.11814, tpPrice, TradingTestConstants.precision); tpPrice = TradingUtils.calculateTakeProfitPrice(0.01, TradingSignal.LONG, 121.456, 121.504, 20); assertEquals(121.704, tpPrice, TradingTestConstants.precision); tpPrice = TradingUtils.calculateTakeProfitPrice(0.0001, TradingSignal.SHORT, 0.95112, 0.95136, 12); assertEquals(0.94992, tpPrice, TradingTestConstants.precision); tpPrice = TradingUtils.calculateTakeProfitPrice(0.01, TradingSignal.SHORT, 135.895, 135.9, 123); assertEquals(134.665, tpPrice, TradingTestConstants.precision); tpPrice = TradingUtils.calculateTakeProfitPrice(0.01, TradingSignal.NONE, 135.895, 135.9, 123); assertEquals(0.0, tpPrice, TradingTestConstants.precision); }