@Override public void onEvent(ExecutionReport report, long sequence, boolean endOfBatch) throws Exception { String orderId = report.getOrderID().getValue(); String side = report.getSide().getValue() == Side.BUY ? "bought" : "sold"; ExecType execType = report.getExecType(); String symbol = report.getSymbol().getValue(); if (execType.getValue() == ExecType.NEW) { logger.debug("Order {} accepted", orderId); } else { double tradeQty = report.getLastShares().getValue(); double tradePrice = report.getLastPx().getValue(); logger.debug("Broker {} {} {} shares of {} at {}", new Object[]{broker, side, tradeQty, symbol, tradePrice}); } } });
@Override public void onMessage(ExecutionReport message, SessionID sessionId) throws FieldNotFound { log.info("[ExecutionReport] ClOrdID: {}, orderID: {}, {} {}@{}, avgPx: {}, cumQty: {}, ordStatus: {}", message.getClOrdID().getValue(), message.getOrderID().getValue(), message.getSide().getValue() == Side.BUY ? "buy" : "sell", message.isSetOrderQty() ? message.getOrderQty().getValue() : null, message.isSetPrice() ? message.getPrice().getValue() : null, message.isSetAvgPx() ? message.getAvgPx().getValue() : null, message.isSetCumQty() ? message.getCumQty().getValue() : null, message.isSetOrdStatus() ? message.getOrdStatus().getValue() : null); if (!TradeClient.this.oneOrderDemoed) { TradeClient.this.oneOrderDemoed = true; log.info("Requesting one order status..."); app.requestOrderStatus( message.getOrderID().getValue(), message.getSide().getValue(), "btccny", sessionId); } }
private OrderEntry convertToOrderEntry(NewOrderSingle orderSingle, String broker) throws FieldNotFound { OrderSide side = orderSingle.getSide().getValue() == Side.BUY ? OrderSide.Buy : OrderSide.Sell; OrderType orderType = null; switch (orderSingle.getOrdType().getValue()) { case OrdType.MARKET: orderType = new Market(); break; case OrdType.LIMIT: orderType = new Limit(orderSingle.getPrice().getValue()); break; } return new OrderEntry( side, broker, (int) orderSingle.getOrderQty().getValue(), orderType); }
orderSide.setValue(quickfix.field.Side.UNDISCLOSED); String side = String.valueOf(orderSide.getValue()); Instrument instrument = InstrumentFromMessage.SELECTOR.forValue(deltaMessage).extract(deltaMessage); SymbolSide symbolSide = new SymbolSide(instrument, side);
private void sendExecutionReport(Trade trade, Side side) throws SessionNotFound { final boolean buy = side.getValue() == Side.BUY; final String orderId = buy ? trade.getBuyOrderId() : trade.getSellOrderId(); final String broker = buy ? trade.getBuyBroker() : trade.getSellBroker(); final SessionID sessionID = sessionByBroker.get(broker); if (sessionID != null) { ExecutionReport executionReport = new ExecutionReport( new OrderID(orderId), generateExecId(), new ExecTransType(ExecTransType.STATUS), new ExecType(ExecType.PARTIAL_FILL), new OrdStatus(OrdStatus.PARTIALLY_FILLED), symbol, side, new LeavesQty(), new CumQty(), new AvgPx()); executionReport.set(new LastShares(trade.getQuantity())); executionReport.set(new LastPx(trade.getPrice())); sendToTarget(executionReport, sessionID); } }