Search code examples
pythonpython-2.7quickfixfix-protocol

How to get SessionID in QuickFix


I am using QuickFix with Python. On the back of this question, I've explored the SessionID class a bit, but I am mystified by the behavior.

The SessionID class is described here. It is formed of a BeginString, SenderCompID and TargetCompID.

Say my SessionID in string form looks like this: FIX.4.2:LMXTS->TS68.

fix.SessionID().fromString() returns :->

Which if you look, are the three filler characters separating the BeginString, SenderCompID and TargetCompID.

fix.SessionID().getBeginString returns 8=☺ (i.e. the BeginString is nowhere). And the same thing applies to getSenderCompID and getTargetCompID, they return 49=☺ and 56=☺ respectively.

fix.SessionID().getTargetCompID().getValue() returns the empty string ''.

Trying another way, fix.SessionID().fromString('FIX.4.2:LMXTS->TS68') returns None.

I am trying to get these values after the session is created (which I can explicitly see happening when I pass fix.ScreenLogFactory(settings) to the initiator. So I am confused.


Solution

  • The method void onLogon( const SessionID& ) {} in Application.h is fired when the session is logged on, and gives you a reference to a SessionID. You could inspect the SessionID object inside onLogon to see how it behaves.