x86
x86

Reputation: 73

QuickFIX/J: Not receiving ExecutionReport messages

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
    }

Upvotes: 2

Views: 2004

Answers (2)

TT.
TT.

Reputation: 16137

Message handling is ideally done by a quickfix.MessageCracker, though sometimes handling them in fromApp is the way to go.

You can read more about message cracking here: QuickFIX/J User Manual - Receiving Messages.

I'll outline both ways:


  1. In fromApp

    Messages coming in fromApp are not of specific message types as defined in the QuickFIX/J library, but are of type quickfix.Message. If you wanted to process them the way you are doing now (from fromApp), you would have to inspect the MsgType manually:

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

    Based on the type retrieved, you would call a handler method for the specific message type:

    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. Using MessageCracker

    Another way to handle incoming messages as mentioned before, is through a MessageCracker. You would e.g. extend the class that implements quickfix.Application with quickfix.MessageCracker.

    Add an onMessage method with two parameters, first being the message type, second a SessionID. Call crack from the fromApp method which will route to the appropriate handler.

    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
        }
    }
    

Upvotes: 3

DumbCoder
DumbCoder

Reputation: 5766

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.

Upvotes: 2

Related Questions