C2Util { public static SymbolType getSymbolType( TradeOrder order ) { Ticker ticker = order.getTicker(); if( ticker instanceof StockTicker ) { return SymbolType.stock; } else if( ticker instanceof FuturesTicker ) { return SymbolType.future; } else if( ticker instanceof CurrencyTicker ) { return SymbolType.forex; } else { throw new SumZeroException("Unsupported symbol type: " + ticker.getClass()); } }  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 testGetSymbolType() { StockTicker stockTicker = new StockTicker("A"); FuturesTicker futuresTicker = new FuturesTicker(); CurrencyTicker fxTicker = new CurrencyTicker(); CFDTicker cfdTicker = new CFDTicker("A"); TradeOrder order = new TradeOrder(); order.setTicker(stockTicker); assertEquals(SignalInfo.SymbolType.stock, C2Util.getSymbolType(order)); order.setTicker(futuresTicker); assertEquals(SignalInfo.SymbolType.future, C2Util.getSymbolType(order)); order.setTicker(fxTicker); assertEquals(SignalInfo.SymbolType.forex, C2Util.getSymbolType(order)); try { order.setTicker(cfdTicker); C2Util.getSymbolType(order); fail(); } catch( SumZeroException ex ) { } }