3

I'm running QuickFix with the Python API and connecting to a TT FIX Adapter using FIX4.2

I am logging on and sending a market data request for two instruments. That works fine and data from the instruments comes in as expected. I can get all kinds of information from the messages.

However, I am having trouble getting the Symbol (flag 55) field.

    import quickfix as fix

    def fromApp(self, message, sessionID):

        ID = fix.Symbol()
        message.getField(ID)
        print ID

This works for the very first message [the initial Market Data Snapshot (flag 35 = W)] that comes to me. Once I start getting incremental refreshes (flag 35 = X), I can no longer get the Symbol field. Every message that arrives results in a Field Not Found error.

This is confusing me because in the logs, the Symbol field is always present, whether the message type is W or X.

Thinking the Symbol is in the header of refresh messages, I tried get.Field(ID) when 35 = W and get.Header().getField(ID) when 35 = X, however this did not work.

Can somebody help me figure out what is going on here? I would like to be able to explicitly tell my computer what instruments it is looking at.

Thanks

Wapiti
  • 1,851
  • 2
  • 20
  • 40

1 Answers1

5

Your question is pretty simple, but you've mixed in some misconceptions as well.

1) Symbol will never be in the header. It is a body field.

2) In X messages, the symbol is in a repeating group. You first have to get a group object with msg.GetGroup(), then get the symbol from that. See this example code, from the repeating groups doc page.

3) In W messages, the symbol is not in a group. That's why it works for you there.

It seems clear you are pretty new to QuickFIX and FIX in general. I think you should take few minutes and skim through the "Working with Messages" section of the docs.

Also, the FIXimate website can be your best friend.

Grant Birchmeier
  • 17,809
  • 11
  • 63
  • 98
  • Hi @Grant, Yes, I am new to everything, programming itself. I have solved about forty problems myself and only ask when I am totally stumped. I appreciate your help. I have been getting data out of repeating groups, have been up and down the QuickFix documentation, and visit FIXimate all the time. Just so you know I'm not trying to get someone else to solve my problems for me. I didn't think that Symbol was in a group because in my logs, it was NEVER repeated. This must be an idiosyncrasy, or maybe scrolling I didn't reach the few messages where it was repeated. Thanks again. – Wapiti Mar 19 '13 at 01:13
  • 2
    The repeating group might have a size of one, e.g. it doesn't actually repeat :) Look at field 268; it tells how many MDEntries are in the MDIncGroup. I bet it's 268=1 for that particular message you're parsing. – Grant Birchmeier Mar 19 '13 at 01:45
  • 1
    (If my answer solves your problem, don't forget to mark it as 'accepted'. And maybe upvote it.) – Grant Birchmeier Mar 19 '13 at 01:46
  • I am sure this is the answer, since my code works for 35 = W. I have yet to test but know you nailed it. (I looked at the log and sure enough, 268=1.) Also, I need 15 reputation to upvote otherwise would have upvoted this and your help with my previous question. Thanks. – Wapiti Mar 19 '13 at 01:55