IbUtils { public static String getSecurityType(InstrumentType instrumentType) { if (null != instrumentType) switch (instrumentType) { case STOCK: return "STK"; case FOREX: return "CASH"; case FUTURES: return "FUT"; case OPTION: return "OPT"; case INDEX: return "IND"; case COMBO: return "BAG"; case CFD: return "CFD"; default: throw new IllegalStateException("Unknown instrument type: " + instrumentType); } else { throw new SumZeroException("Instrument type can't be null"); } }  static String translateToIbFuturesSymbol(String symbol); static String getOrderType(TradeOrder.Type orderType); static String getTif(TradeOrder.Duration duration); static String getSecurityType(InstrumentType instrumentType); static String getAction(TradeDirection direction); static QuoteType getQuoteType(int field); static OrderStatus.Status getOrderStatus(String status); static String getExpiryString(int expiryMonth, int expiryYear); static String getExpiryString(int expiryDay, int expiryMonth, int expiryYear); static String getOptionRight( OptionTicker.Right right ); static Image getIconImage(); static BigDecimal getIbMultiplier( Ticker ticker ); static Vector<TagValue> getDefaultTagVector(); static List<TagValue> getDefaultTagList();  }
@Test public void testGetSecurityType() { InstrumentType[] values = InstrumentType.values(); for (InstrumentType value : values) { if( value != InstrumentType.BITCOIN ) { assertNotNull(IbUtils.getSecurityType(value)); } } assertEquals("STK", IbUtils.getSecurityType(InstrumentType.STOCK)); assertEquals("OPT", IbUtils.getSecurityType(InstrumentType.OPTION)); assertEquals("CASH", IbUtils.getSecurityType(InstrumentType.FOREX)); assertEquals("FUT", IbUtils.getSecurityType(InstrumentType.FUTURES)); assertEquals("IND", IbUtils.getSecurityType(InstrumentType.INDEX)); assertEquals("BAG", IbUtils.getSecurityType(InstrumentType.COMBO)); }