C2Util { public static Action getTradeAction( TradeOrder order ) { if( order.getTradeDirection() == TradeDirection.BUY ) { return Action.BTO; } else if( order.getTradeDirection() == TradeDirection.SELL ) { return Action.STC; } else if( order.getTradeDirection() == TradeDirection.BUY_TO_COVER ) { return Action.BTC; } else if( order.getTradeDirection() == TradeDirection.SELL_SHORT ) { return Action.STO; } else { throw new SumZeroException("Unknown trade direction: " + order.getTradeDirection() ); } }  static String getFuturesSymbol(FuturesTicker ticker); static Action getTradeAction( TradeOrder order ); static SymbolType getSymbolType( TradeOrder order ); static OrderType getOrderType( TradeOrder order ); static String getC2RootSymbol(String symbol); static String getTime( ZonedDateTime zonedTime ); static final String ROOT_SYMBOL_RUSSEL2K_NYBOT; static final String ROOT_SYMBOL_RUSSEL2K_GLOBEX; static final String ROOT_SYMBOL_NASDAQ_100; static final String ROOT_SYMBOL_MINI_DOW; static final String ROOT_SYMBOL_SP500; static final String ROOT_SYMBOL_CORN; }
@Test public void testGetTradeAction() { TradeOrder order = new TradeOrder(); order.setTradeDirection(TradeDirection.BUY); assertEquals(SignalInfo.Action.BTO, C2Util.getTradeAction(order)); order.setTradeDirection(TradeDirection.SELL); assertEquals(SignalInfo.Action.STC, C2Util.getTradeAction(order)); order.setTradeDirection(TradeDirection.BUY_TO_COVER); assertEquals(SignalInfo.Action.BTC, C2Util.getTradeAction(order)); order.setTradeDirection(TradeDirection.SELL_SHORT); assertEquals(SignalInfo.Action.STO, C2Util.getTradeAction(order)); try { order.setTradeDirection(null); C2Util.getTradeAction(order); fail(); } catch( SumZeroException ex ) { } }