public static String getTextOrEncodedText(Message aMessage, String defaultString) { String text = defaultString; if (aMessage.isSetField(Text.FIELD)){ try { text = aMessage.getString(Text.FIELD); } catch (FieldNotFound ignored) { } } else { try { text = aMessage.getString(EncodedText.FIELD); //i18n_string todo use the correct MessageEncoding value } catch (FieldNotFound ignored) { } } return text; }
static String getText(Message inMessage) { if (inMessage.isSetField(Text.FIELD)) { try { return inMessage.getString(Text.FIELD); } catch (FieldNotFound ignore) { } } return null; } static String getBrokerOrderID(Message inMessage) {
static String getExecutionID(Message inMessage) { if (inMessage.isSetField(ExecID.FIELD)) { try { return inMessage.getString(ExecID.FIELD); } catch (FieldNotFound ignore) { } } return null; } static BigDecimal getLastQuantity(Message inMessage) {
static String getLastMarket(Message inMessage) { if (inMessage.isSetField(LastMkt.FIELD)) { try { return inMessage.getString(LastMkt.FIELD); } catch (FieldNotFound ignore) { } } return null; }
static String getBrokerOrderID(Message inMessage) { if (inMessage.isSetField(quickfix.field.OrderID.FIELD)) { try { return inMessage.getString(quickfix.field.OrderID.FIELD); } catch (FieldNotFound ignore) { } } return null; }
static String getAccount(Message inMessage) { if (inMessage.isSetField(Account.FIELD)) { try { return inMessage.getString(Account.FIELD); } catch (FieldNotFound ignore) { } } return null; } static String getExecutionDestination(Message inMessage) {
static String getExecutionDestination(Message inMessage) { if (inMessage.isSetField(quickfix.field.ExDestination.FIELD)) { try { return inMessage.getString(quickfix.field.ExDestination.FIELD); } catch (FieldNotFound ignore) { } } return null; } static OrderType getOrderType(Message inMessage) {
private boolean isOrderExecutable(Message order, Price price) throws FieldNotFound { if (order.getChar(OrdType.FIELD) == OrdType.LIMIT) { BigDecimal limitPrice = new BigDecimal(order.getString(Price.FIELD)); char side = order.getChar(Side.FIELD); BigDecimal thePrice = new BigDecimal("" + price.getValue()); return (side == Side.BUY && thePrice.compareTo(limitPrice) <= 0) || ((side == Side.SELL || side == Side.SELL_SHORT) && thePrice.compareTo(limitPrice) >= 0); } return true; }
static SecurityType getSecurityType(Message inMessage) { if (inMessage.isSetField(quickfix.field.SecurityType.FIELD)) { try { return SecurityType.getInstanceForFIXValue( inMessage.getString( quickfix.field.SecurityType.FIELD)); } catch (FieldNotFound ignore) { } } return null; } static String getText(Message inMessage) {
@Deprecated public static boolean isEquityOptionOrder(Message message) { try { return isOrderSingle(message) && ( message.isSetField(PutOrCall.FIELD) || (message.isSetField(Symbol.FIELD) && optionSymbolPattern.matcher(message.getString(Symbol.FIELD)).matches()) || message.isSetField(CFICode.FIELD) && OptionCFICode.isOptionCFICode(message.getString(CFICode.FIELD)) ); } catch (FieldNotFound e) { // should never happen return false; } }
/** * Create a new MessageWrapper instance. * * @param inMessage a <code>Message</code> value * @throws FieldNotFound if the message is invalid */ private MessageWrapper(Message inMessage) throws FieldNotFound { message = inMessage; msgType = message.getHeader().getString(quickfix.field.MsgType.FIELD); requestId = message.getString(quickfix.field.MDReqID.FIELD); } /**
static OrderID getOriginalOrderID(Message inMessage) { if (inMessage.isSetField(OrigClOrdID.FIELD)) { try { String value = inMessage.getString( OrigClOrdID.FIELD); return value == null ? null : new OrderID(value); } catch (FieldNotFound ignore) { } } return null; } static OrderStatus getOrderStatus(Message inMessage) {
static OrderID getOrderID(Message inMessage) { if (inMessage.isSetField(ClOrdID.FIELD)) { try { String value = inMessage.getString( ClOrdID.FIELD); return value == null ? null : new OrderID(value); } catch (FieldNotFound ignore) { } } return null; } static void setOrderID(Message inMessage, String inOrderID) {
private Price getPrice(Message message) throws FieldNotFound { Price price; if (message.getChar(OrdType.FIELD) == OrdType.LIMIT && alwaysFillLimitOrders) { price = new Price(message.getDouble(Price.FIELD)); } else { if (marketDataProvider == null) { throw new RuntimeException("No market data provider specified for market order"); } char side = message.getChar(Side.FIELD); if (side == Side.BUY) { price = new Price(marketDataProvider.getAsk(message.getString(Symbol.FIELD))); } else if (side == Side.SELL || side == Side.SELL_SHORT) { price = new Price(marketDataProvider.getBid(message.getString(Symbol.FIELD))); } else { throw new RuntimeException("Invalid order side: " + side); } } return price; }
@Override protected void processMessage(IoSession protocolSession, Message message) throws Exception { if (message.getHeader().getString(MsgType.FIELD).equals(MsgType.LOGON)) { final SessionID sessionID = MessageUtils.getReverseSessionID(message); if (sessionID.isFIXT()) { if (message.isSetField(DefaultApplVerID.FIELD)) { final ApplVerID applVerID = new ApplVerID(message.getString(DefaultApplVerID.FIELD)); quickfixSession.setTargetDefaultApplicationVersionID(applVerID); quickfixSession.getLog().onEvent("Setting DefaultApplVerID (" + DefaultApplVerID.FIELD + "=" + applVerID.getValue() + ") from Logon"); } } } eventHandlingStrategy.onMessage(quickfixSession, message); }
@Override protected void processMessage(IoSession protocolSession, Message message) throws Exception { if (message.getHeader().getString(MsgType.FIELD).equals(MsgType.LOGON)) { final SessionID sessionID = MessageUtils.getReverseSessionID(message); if (sessionID.isFIXT()) { if (message.isSetField(DefaultApplVerID.FIELD)) { final ApplVerID applVerID = new ApplVerID(message.getString(DefaultApplVerID.FIELD)); quickfixSession.setTargetDefaultApplicationVersionID(applVerID); quickfixSession.getLog().onEvent("Setting DefaultApplVerID (" + DefaultApplVerID.FIELD + "=" + applVerID.getValue() + ") from Logon"); } } } eventHandlingStrategy.onMessage(quickfixSession, message); }
@Override protected void processMessage(IoSession protocolSession, Message message) throws Exception { if (message.getHeader().getString(MsgType.FIELD).equals(MsgType.LOGON)) { final SessionID sessionID = MessageUtils.getReverseSessionID(message); if (sessionID.isFIXT()) { if (message.isSetField(DefaultApplVerID.FIELD)) { final ApplVerID applVerID = new ApplVerID(message.getString(DefaultApplVerID.FIELD)); quickfixSession.setTargetDefaultApplicationVersionID(applVerID); quickfixSession.getLog().onEvent("Setting DefaultApplVerID (" + DefaultApplVerID.FIELD + "=" + applVerID.getValue() + ") from Logon"); } } } eventHandlingStrategy.onMessage(quickfixSession, message); }
private void generateHeartbeat(Message testRequest) throws FieldNotFound { final Message heartbeat = messageFactory.create(sessionID.getBeginString(), MsgType.HEARTBEAT); initializeHeader(heartbeat.getHeader()); if (testRequest.isSetField(TestReqID.FIELD)) { heartbeat.setString(TestReqID.FIELD, testRequest.getString(TestReqID.FIELD)); } if (enableLastMsgSeqNumProcessed) { heartbeat.getHeader().setInt(LastMsgSeqNumProcessed.FIELD, testRequest.getHeader().getInt(MsgSeqNum.FIELD)); } sendRaw(heartbeat, 0); }
private void generateHeartbeat(Message testRequest) throws FieldNotFound { final Message heartbeat = messageFactory.create(sessionID.getBeginString(), MsgType.HEARTBEAT); initializeHeader(heartbeat.getHeader()); if (testRequest.isSetField(TestReqID.FIELD)) { heartbeat.setString(TestReqID.FIELD, testRequest.getString(TestReqID.FIELD)); } if (enableLastMsgSeqNumProcessed) { heartbeat.getHeader().setInt(LastMsgSeqNumProcessed.FIELD, testRequest.getHeader().getInt(MsgSeqNum.FIELD)); } sendRaw(heartbeat, 0); }
private void generateHeartbeat(Message testRequest) throws FieldNotFound { final Message heartbeat = messageFactory.create(sessionID.getBeginString(), MsgType.HEARTBEAT); initializeHeader(heartbeat.getHeader()); if (testRequest.isSetField(TestReqID.FIELD)) { heartbeat.setString(TestReqID.FIELD, testRequest.getString(TestReqID.FIELD)); } if (enableLastMsgSeqNumProcessed) { heartbeat.getHeader().setInt(LastMsgSeqNumProcessed.FIELD, testRequest.getHeader().getInt(MsgSeqNum.FIELD)); } sendRaw(heartbeat, 0); }