使用Python的quickfix包,如何强制注销FIX连接?
Using Python's quickfix package, how can I forcibly logout of the FIX connection?
我有一小段代码可以建立 FIX 连接并能够成功连接。
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()
我想在关闭程序时注销 FIX 会话。我还在此处定义了 quickfix class 函数
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
我尝试调用行 initiator.stop()
但我的函数 FIX_IO.onLogout
没有被调用。有没有一种方法可以在我的程序中的任何地方调用注销 FIX 会话,只需访问我用来连接的 quickfix.application 对象?
在 Initiator i
的 QuickFixJ 中,您可以使用
SessionID id = i.getSessions().get(0);
Session.lookupSession(id).logout();
python 实现是:
quickfix .Session.lookupSession(sessionID).logout()
我有一小段代码可以建立 FIX 连接并能够成功连接。
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()
我想在关闭程序时注销 FIX 会话。我还在此处定义了 quickfix class 函数
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
我尝试调用行 initiator.stop()
但我的函数 FIX_IO.onLogout
没有被调用。有没有一种方法可以在我的程序中的任何地方调用注销 FIX 会话,只需访问我用来连接的 quickfix.application 对象?
在 Initiator i
的 QuickFixJ 中,您可以使用
SessionID id = i.getSessions().get(0);
Session.lookupSession(id).logout();
python 实现是:
quickfix .Session.lookupSession(sessionID).logout()