Reputation: 2274
I have a small block of code where I establish the FIX connection and am able to connect successfully.
file = sys.argv[1]
settings = fix.SessionSettings(file)
application = FIX_IO(1)
storeFactory = fix.FileStoreFactory(settings)
initiator = fix.SocketInitiator(application, storeFactory, settings)
initiator.start()
application.run()
# initiator.stop()
I want to logout of the FIX session whenever I close my program. I also defined the quickfix class functions here
import quickfix as fix
class FIX_IO(fix.Application):
def onCreate(self, sessionID):
self.sessionID = sessionID
print("FIX Thread started now > \n")
def onLogon(self, sessionID):
print("We are live now > \n")
def onLogout(self, sessionID):
print("Disconnected..")
def toAdmin(self, message, sessionID):
msgType = fix.MsgType()
message.getHeader().getField(msgType)
msgType = msgType.getValue()
def toApp(self, message, sessionID):
self.handle_incoming_message(message)
def fromApp(self, message, sessionID):
self.handle_incoming_message(message)
def send_message(self, message):
fix.Session.sendToTarget(message, self.sessionID)
def handle_income_message(self, msg):
pass
I tried calling the line initiator.stop()
but my function FIX_IO.onLogout
wasn't called. Is there a way to invoke a logout of the FIX session anywhere in my program with just access to the quickfix.application object I used to connect?
Upvotes: 2
Views: 1279
Reputation: 2274
The python implementation is:
quickfix .Session.lookupSession(sessionID).logout()
Upvotes: 0
Reputation: 3328
In QuickFixJ for your Initiator i
you can use something like
SessionID id = i.getSessions().get(0);
Session.lookupSession(id).logout();
Upvotes: 1