VERY basic questions from a FIX newbie
Looking at the documentation at http://www.quickfixengine.org and reading posts here on stackoverflow I see lots of talk about message ‘cracking’. I think I sort of get the idea, but feel like I’m still not totally clear.
Can some explain in general what exactly this is (why is it necessary? it sounds like a hack), why it only seems relates to received FIX messages, and is not used at all when using Python?
Thank you!
In practice, all you need to know is this:
Your
fromApp()callback gets aMessageobject. That message is actually a NewOrderSingle or ExecutionReport or something. Rather than making you figure it out, QF lets you inherit fromMessageCracker. To use it, callcrack()in yourfromApp(), as follows:What
crack()does is this:Messageinto the proper subclass (e.g.NewOrderSingle,ExecutionReport, etc)onMessage(subtype)callback, if defined. If not defined, it throws anUnsupportedMessageTypeexception and your app will automatically send a BusinessMessageReject (35=j) to the counterparty.So, do you want to handle NewOrderSingle messages? Great, just define an
onMessage(NewOrderSingle)callback.Do you want to handle ExecutionReports? Define
onMessage(ExecutionReport). And so on.But what about those message types you don’t want to handle? It would suck if you had to add handlers to reject all those other message types, but luckily, you don’t have to. As I said earlier, if you don’t define an
onMessage(), QF will reject it for you. (If you want to swallow a particular message type and ignore it without rejection, then just define anonMessage()call with no body.)Does that clear it up a bit? Perhaps now this page in the QF docs might read a little easier — the bottom section talks about the MessageCracker.
Note: The MessageCracker does not handle session-level (aka “admin”) messages. If you want to add custom handling for, say, Logon or Heartbeat messages, you must do it explicitly in
fromAdmin()(see this question for more info).