Python 3.x Python为quickfix进行了配置

Python 3.x Python为quickfix进行了配置,python-3.x,quickfix,Python 3.x,Quickfix,这是启动器配置: [SESSION] ConnectionType=initiator BeginString=FIX.4.1 SenderCompID=PS TargetCompID=ND SocketNodelay=Y SocketConnectHost=48.40.87.16 SocketAcceptPort=9840 StartTime=07:00:00 EndTime=22:00:00 FileStorePath=C:/Temp/quickfix/store/initiator Fil

这是启动器配置:

[SESSION]
ConnectionType=initiator
BeginString=FIX.4.1
SenderCompID=PS
TargetCompID=ND
SocketNodelay=Y
SocketConnectHost=48.40.87.16
SocketAcceptPort=9840
StartTime=07:00:00
EndTime=22:00:00
FileStorePath=C:/Temp/quickfix/store/initiator
FileLogPath=C:/Temp/quickfix/logs/initiator
ReconnectInterval=30
HeartBtInt=20
SocketReuseAddress=Y
UseDataDictionary=N
# DataDictionary=datadictionary/FIX41.xml
这是接受器配置

[SESSION]
ConnectionType=acceptor
BeginString=FIX.4.1
TargetCompID=ND
SenderCompID=PS
SocketNodelay=Y
SocketAcceptPort=9840
StartTime=07:00:00
EndTime=22:00:00
FileStorePath=C:/Temp/quickfix/store/acceptor
FileLogPath=C:/Temp/quickfix/logs/acceptor
SocketReuseAddress=Y
UseDataDictionary=N
我要传达一个非常简单的信息:

def create_message(self):

    print ("Composing Message")
    message = fix.Message();
    header = message.getHeader();

    header.setField(fix.BeginString("FIX.4.1"))
    header.setField(fix.SenderCompID("PS"))
    header.setField(fix.TargetCompID("ND"))
    header.setField(fix.MsgType("D"))
    message.setField(fix.OrigClOrdID("123"))
    message.setField(fix.ClOrdID("321"))
    message.setField(fix.Symbol("LNUX"))
    message.setField(fix.Side('B'))
    message.setField(fix.Text("Really Cancel My Order!"))
    return message

def test_fix(self):
    print ("Testing Fix")
    message = self.create_message()
    fix.Session.sendToTarget(message, self.sessionID)
    print ("Testing FIX ends")

我在启动器FIX.4.1-PS-ND.body上的输出确实包含它发送的消息。然而,我在接受者身上看不到任何东西。1我做错了什么/2在这种情况下,发起者如何知道确切的位置-TargetCompID=ND,ND在哪里?

我假设您希望发起者和接受者相互连接。这不适用于您的配置,因为两者都具有相同的TargetCompID和SenderCompID。 要使其工作,需要在连接的每一端交换TargetCompID和SenderCompID

因此,接受方需要具备:

SenderCompID=ND
TargetCompID=PS
只要两端未连接,对Session.sendToTarget的调用将导致消息仅写入消息存储,而不会发送出去。它将在会话连接后立即发送

顺便说一句,您的启动器不需要SocketAcceptPort,只需要SocketConnectPort。 这应该有希望连接两端。如果没有,请粘贴错误消息。

已解决:

我犯了一个愚蠢的错误。 SocketConnectHost=48.40.87.16


此IP地址应为接受者的IP地址。这实际上也回答了我的2个问题。

我不理解问题2,请解释。ND是TargetCompID。我想知道发起者如何识别接受者。如何保持客户端ID的唯一性。可能有数以百万计的TargetCompID=ND。我们正在指定发起方的IP地址,但不是在接受方。谢谢Chris。我现在正在尝试。您从哪里获得错误日志?谢谢,这次我得到了更好的结果:ND,事件>连接到端口9840上的48.40.87.16源:0。。因此,它试图连接到目标端口,但没有任何消息表明消息已传递。消息在哪里传递?我想它应该是目标计算机上的FileStorePath?BTW 48.40.87.16是我的IP地址。如果您还没有找到它,下面是一个配置选项列表,并附有说明: