Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python通过QuickFix连接到多个会话_Python_Quickfix_Fix Protocol_Quickfixj - Fatal编程技术网

python通过QuickFix连接到多个会话

python通过QuickFix连接到多个会话,python,quickfix,fix-protocol,quickfixj,Python,Quickfix,Fix Protocol,Quickfixj,所以我必须连接到两(2)个会话(相同主机不同端口),所以我使用了两个不同的启动器 application = Application() settings = quickfix.SessionSettings(config_file) # stream settings storefactory = quickfix.FileStoreFactory(settings) logfactory = quickfix.FileLogFactory(settings

所以我必须连接到两(2)个会话(相同主机不同端口),所以我使用了两个不同的启动器

    application = Application()

    settings = quickfix.SessionSettings(config_file)  # stream settings
    storefactory = quickfix.FileStoreFactory(settings)
    logfactory = quickfix.FileLogFactory(settings)
    initiator = quickfix.SocketInitiator(
        application, storefactory, settings, logfactory)

    initiator.start()

    application.run()

    initiator.stop()
并为两个会话使用了两个不同的配置(.cfg)文件

# This is a client (initiator)
[DEFAULT]
DefaultApplVerID=FIX.4.4
 #settings which apply to all the Sessions.
ConnectionType=initiator
 # FIX messages have a sequence ID, which shouldn't be used for uniqueness as specification doesn't guarantee anything about them. If Y is provided every time logon message is sent, server will reset the sequence.
FileLogPath=./Logs/
 #Path where logs will be written
StartTime=00:00:00
 # Time when session starts and ends
EndTime=00:00:00
UseDataDictionary=Y
 #Time in seconds before your session will expire, keep sending heartbeat requests if you don't want it to expire
ReconnectInterval=60
LogoutTimeout=5
LogonTimeout=30
 # Time in seconds before reconnecting
ResetOnLogout=N
ResetOnDisconnect=N
SendRedundantResendRequests=Y
# RefreshOnLogon=Y
SocketNodelay=N
# PersistMessages=Y
ValidateUserDefinedFields=N
ValidateFieldsOutOfOrder=N
# CheckLatency=Y



# session stream
[SESSION]
ResetOnLogon=Y
BeginString=FIX.4.4
SenderCompID=TESTING1
TargetCompID=TESTACC1
HeartBtInt=30
SocketConnectPort=4000
SocketConnectHost=127.0.0.1
DataDictionary=./spec/FIX44.xml
FileStorePath=./Sessions/

# session market
[SESSION]
ResetOnLogon=Y
BeginString=FIX.4.4
SenderCompID=TESTING2
TargetCompID=TESTACC2
HeartBtInt=30
SocketConnectPort=5000
SocketConnectHost=127.0.0.1
DataDictionary=./spec/FIX44.xml
FileStorePath=./Sessions/
但这不起作用


我看到一篇帖子,他们建议使用
ThreadedSocketInitiator
,但我认为它不适用于python quickfix库


提前感谢

ThreadedSocketInitiator
与您的问题无关。它仅为每个修复会话维护一个线程,而默认的
SocketInitiator
为所有修复会话使用相同的线程。这是您的完整配置文件吗?通常,在每个会话定义前面都需要一行
[SESSION]
。示例文件:哦,我不确定QuickFIX的Python端口是如何做到这一点的,但通常您只需要一个启动器,并通过多个会话传递一个配置文件。请参阅上面的示例文件。非常感谢Christoph John,我已经重构了我的代码,并在配置文件中添加了两个[SESSION],但现在只有一个端口正在连接,另一个端口没有连接。请用完整的配置文件更新这个问题好吗?@Christoph John我已经更新了配置和代码