@SuppressWarnings("boxing") public void testMajorToMinor() { double majorPx = 25.12; ClientNewOrderSingleImpl nos = FixTestUtils.getClientNOS(_decoder, "TST0000001", 100, majorPx, _upMsgHandler); nos.setCurrency(Currency.GBP); ((InstrumentWrite) nos.getInstrument()).setCurrency(Currency.GBp); _proc.handle(nos); MarketNewOrderSingleImpl mnos = (MarketNewOrderSingleImpl) getMessage(_downQ, MarketNewOrderSingleImpl.class); // MARKET IS IN POUNDS assertSame(Currency.GBp, mnos.getCurrency()); assertEquals((majorPx * 100.0), mnos.getPrice(), Constants.PRICE_DP); Order order = _proc.getOrder(nos.getClOrdId()); NewOrderAck mack = FixTestUtils.getMarketACK(_decoder, "TST0000001", 100, 25.12, _mktOrderId, _execId); _proc.handle(mack); checkQueueSize(1, 0, 0); ClientNewOrderAckImpl cack = (ClientNewOrderAckImpl) getMessage(_upQ, ClientNewOrderAckImpl.class); assertSame(Currency.GBP, cack.getCurrency()); assertEquals(majorPx, cack.getPrice(), Constants.WEIGHT); ClientProfile client = order.getClientProfile(); double totVal = nos.getPrice() * nos.getOrderQty() * nos.getCurrency().toUSDFactor(); assertEquals(totVal, client.getTotalOrderValueUSD()); }
public final Message XXdecodeNewOrderSingle() { ClientNewOrderSingleImpl msg = _newOrderSingleFactory.get(); int tag = getTag(); int start; int valLen; while (tag != 0) { switch (tag) { case 1: start = _idx; valLen = getValLength(); msg.setAccount(start, valLen); break; case 11: start = _idx; valLen = getValLength(); msg.setClOrdId(start, valLen); break; case 15: start = _idx; valLen = getValLength(); msg.setCurrency(Currency.getVal(_fixMsg, start, valLen)); break; case 21: msg.setHandlInst(HandlInst.getVal(_fixMsg[_idx++])); break; case 22: msg.setSecurityIDSource(SecurityIDSource.getVal(_fixMsg[_idx++])); break; case 38: msg.setOrderQty(getIntVal()); break; case 40: msg.setOrdType(OrdType.getVal(_fixMsg[_idx++])); break; case 44: msg.setPrice(getDoubleVal()); break; case 48: start = _idx; valLen = getValLength(); msg.setSecurityId(start, valLen); break; case 49: decodeSenderCompID(); break; case 50: decodeSenderSubID(); break; case 52: msg.setSendingTime(getMSFromStartDayUTC()); break; case 54: msg.setSide(Side.getVal(_fixMsg[_idx++])); break; case 55: start = _idx; valLen = getValLength(); msg.setSymbol(start, valLen); break; case 56: decodeTargetCompID(); break; case 57: decodeTargetSubID(); break; case 58: start = _idx; valLen = getValLength(); msg.setText(start, valLen); break; case 59: msg.setTimeInForce(TimeInForce.getVal(_fixMsg[_idx++])); break; case 60: msg.setTransactTime(getMSFromStartDayUTC()); break; case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 12: case 13: case 14: case 16: case 17: case 18: case 19: case 20: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 39: case 41: case 42: case 43: case 45: case 46: case 47: case 51: case 53: getValLength(); break; default: switch (tag) { case 100: start = _idx; valLen = getValLength(); msg.setExDest(start, valLen); break; case 528: msg.setOrderCapacity(OrderCapacity.getVal(_fixMsg[_idx++])); break; case 207: start = _idx; valLen = getValLength(); msg.setSecurityExchange(start, valLen); break; case 211: getValLength(); throwDecodeException("Tag 211 not supported in NewOrderSingle"); break; } break; } _idx++; /* past delimiter */ tag = getTag(); } if (_idx > SizeType.VIEW_NOS_BUFFER.getSize()) { throw new RuntimeDecodingException( "NewOrderSingleMessage too big " + _idx + ", max=" + SizeType.VIEW_NOS_BUFFER.getSize()); } msg.setViewBuf(_fixMsg, _offset, _idx); // TODO instrument enrichment & ccy major/minor changes return msg; }
// decode methods public Message decodeNewOrderSingle() { // TODO get from pool ClientNewOrderSingleImpl msg = _newOrderSingleFactory.get(); int tag = getTag(); int start; int valLen; while (tag != 0) { switch (tag) { case 0: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 12: case 13: case 14: case 16: case 17: case 18: case 19: case 20: // forced table switch from 0 to 60 start = _idx; valLen = getValLength(); break; case 1: start = _idx; valLen = getValLength(); msg.setAccount(start, valLen); break; case 11: start = _idx; valLen = getValLength(); msg.setClOrdId(start, valLen); break; case 15: start = _idx; valLen = getValLength(); msg.setCurrency(Currency.getVal(_fixMsg, start, valLen)); break; case 21: msg.setHandlInst(HandlInst.getVal(_fixMsg[_idx++])); break; case 22: msg.setSecurityIDSource(SecurityIDSource.getVal(_fixMsg[_idx++])); break; case 38: msg.setOrderQty(getIntVal()); break; case 40: msg.setOrdType(OrdType.getVal(_fixMsg[_idx++])); break; case 44: msg.setPrice(getDoubleVal()); break; case 48: start = _idx; valLen = getValLength(); msg.setSecurityId(start, valLen); break; case 49: decodeSenderCompID(); break; case 52: msg.setSendingTime(getMSFromStartDayUTC()); break; case 54: msg.setSide(Side.getVal(_fixMsg[_idx++])); break; case 55: start = _idx; valLen = getValLength(); msg.setSymbol(start, valLen); break; case 56: decodeTargetCompID(); break; case 58: start = _idx; valLen = getValLength(); msg.setText(start, valLen); break; case 59: msg.setTimeInForce(TimeInForce.getVal(_fixMsg[_idx++])); break; case 60: msg.setTransactTime(getMSFromStartDayUTC()); break; default: // SKIP switch (tag) { case 100: // exDest start = _idx; valLen = getValLength(); msg.setExDest(start, valLen); break; case 207: // securityExchange start = _idx; valLen = getValLength(); msg.setSecurityExchange(start, valLen); break; case 528: msg.setOrderCapacity(OrderCapacity.getVal(_fixMsg[_idx++])); break; default: start = _idx; valLen = getValLength(); break; } } _idx++; // past delimiter tag = getTag(); } if (_idx > SizeType.VIEW_NOS_BUFFER.getSize()) { throw new RuntimeDecodingException( "NewOrderSingle Message too big " + _idx + ", max=" + SizeType.VIEW_NOS_BUFFER.getSize()); } msg.setViewBuf(_fixMsg, _offset, _idx); // TODO instrument enrichment & ccy major/minor changes return msg; }