QuickFIX/J: Not receiving ExecutionReport messages

时间:2016-03-04 17:47:36

标签: fix-protocol quickfixj

After opening an order with our brokerage firm, we desire to obtain the fill price from the ExecutionReport messages. Below you will find the callback code used.

The MarketDataSnapshotFullRefresh messages are received properly, but the second if block is never triggered. Strangely, the corresponding messages.log file does contain multiple 35=8 messages.

We use QuickFIX/J as FIX engine.

@Override
public void fromApp(Message message, SessionID sessionID) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType {
    if (message instanceof MarketDataSnapshotFullRefresh) {
        // do stuff with MarketDataSnapshotFullRefresh
    }

    if(message instanceof ExecutionReport) {
        // do stuff with ExecutionReport
    }

2 个答案:

答案 0 :(得分:3)

消息处理最好由quickfix.MessageCracker完成,但有时在fromApp处理它们是可行的方法。

您可以在此处详细了解邮件破解:QuickFIX/J User Manual - Receiving Messages

我将概述两种方式:

  1. fromApp

    fromApp中的消息不属于QuickFIX / J库中定义的特定消息类型,但属于quickfix.Message类型。如果您想按照现在的方式处理它们(来自fromApp),则必须手动检查MsgType

    MsgType msgType = (MsgType) message.getHeader( ).getField( new MsgType( ) );
    

    根据检索的类型,您可以为特定的消息类型调用处理程序方法:

    if( msgType.valueEquals( MsgType.MARKET_DATA_SNAPSHOT_FULL_REFRESH ) )
        handleMarketDataSnapshotFullRefresh( message, sessionID );
    else if ...
    
    ...
    
    private void handleMarketDataSnapshotFullRefresh( quickfix.Message msg, SessionID sessionID ) {
        // handler implementation
    }
    
    1. 使用MessageCracker

      如前所述处理传入消息的另一种方法是通过MessageCracker。你会...使用quickfix.Application扩展实现quickfix.MessageCracker的类。

      使用两个参数添加onMessage方法,首先是消息类型,第二个是SessionID。从crack方法调用fromApp,该方法将路由到相应的处理程序。

      import quickfix.*;
      
      public class MyApplication extends MessageCracker implements Application
      {
          public void fromApp(Message message, SessionID sessionID)
                throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue {
                crack(message, sessionID);
          }
      
          @Handler
          public void onMessage(quickfix.fix44.MarketDataSnapshotFullRefresh mdsfr, SessionID sessionID) {
               // handler implementation
          }
      }
      

答案 1 :(得分:2)

Why are you doing the message processing in the wrong place ? If you check what is recommended by Quickfix you will see they recommend message processing happens in onMessage (which you might not have implemented). And there should only exist a message cracker in fromApp method.

Or else your fromApp method is going to be a hotchpotch of code and the next person handling your code is not going to be a happy soul.