简体   繁体   English

无法使用quickfix使用python登录FIX服务器

[英]Unable to logon FIX server with python using quickfix

I´m trying to connect to an available FIX server using quickfix in python and I´m facing some problems I cannot resolve.我正在尝试使用 python 中的 quickfix 连接到可用的 FIX 服务器,但我遇到了一些无法解决的问题。 I´ve checked this question which looks pretty similar what I´m facing, but no clue about how to fix the problem.我检查了这个问题,它看起来与我面临的问题非常相似,但不知道如何解决这个问题。 Apparently it´sa problem related with my configuration file, but I´ve double checked and still not lucky.显然这是一个与我的配置文件有关的问题,但我已经仔细检查过,但仍然不走运。

I´m using this ini file.我正在使用这个ini文件。

[DEFAULT]
PersistMessages=Y
ConnectionType=initiator
UseDataDictionary=Y
StartTime=00:00:00
EndTime=23:59:00
FileStorePath=incoming 
FileLogPath=outgoing 

[SESSION]
StartTime=00:00:00
SenderCompID=8826
SenderSubID=350
EndTime=00:00:00
ConnectionType=initiator
ApplVerID=9
BeginString=FIXT.1.1
DefaultApplVerID=9
TransportDataDictionary=FIXT11.xml
AppDataDictionary=FIX50SP2.xml
TargetCompID=XMEF
TargetSubID=M3
SocketConnectPort=8238
SocketConnectHost=10.166.0.2
SocketUseSSL=Y
SSLEnable=Y
HeartBtInt=20
ReconnectInterval=30
SSLValidateCertificates=Y

When I´m trying to connect I get next result in console当我尝试连接时,我会在控制台中获得下一个结果

Logon msg to Admin
<20211014-14:31:56.000000000, FIXT.1.1:8826->XMEF, outgoing>
  (8=FIXT.1.19=12035=A34=149=882650=35052=20211014-14:31:56.00056=BMEX57=EQ1408=T5.1098=0108=20553=8826350554=*****1137=910=253)
<20211014-14:31:56.000000000, FIXT.1.1:8826->XMEF, event>
  (Initiated logon request)
<20211014-14:31:57.000000000, FIXT.1.1:8826->XMEF, incoming>
  (8=FIXT.1.19=12935=A34=152=20211014-14:31:57.14315949=BMEX50=EQ56=882657=35098=0108=201137=91408=T5.10464=Y21504=100021505=2021072110=245)
<20211014-14:31:57.000000000, FIXT.1.1:8826->XMEF, event>
  (Message 1 Rejected: CompID problem)
<20211014-14:31:57.000000000, FIXT.1.1:8826->XMEF, event>
  (Tried to send a reject while not logged on)
<20211014-14:31:57.000000000, FIXT.1.1:8826->XMEF, event>
  (Disconnecting)

My toAdmin method in application class is this我在应用程序类中的 toAdmin 方法是这样的

def toAdmin(self, message, sessionID):
        msg_type = fix.MsgType()
        message.getHeader().getField(msg_type)
        if msg_type.getString() is fix.MsgType_Logon:
            message.getHeader().setField(fix.StringField(34, "1"))
            message.getHeader().setField(fix.SenderCompID("8826"))
            message.getHeader().setField(fix.SenderSubID("350"))
            message.getHeader().setField(fix.StringField(1408, "T5.10"))
            message.getHeader().setField(fix.TargetCompID("BMEX"))
            message.getHeader().setField(fix.TargetSubID("EQ"))
            message.setField(fix.Username("8826350"))
            message.setField(fix.Password("******"))
            print("Logon msg to Admin") 

And I've also modified FIXT1.1 Logon message in this way, but I think that's ok我也用这种方式修改了 FIXT1.1 登录消息,但我认为没关系

<message msgcat='admin' msgtype='A' name='Logon'>
      <field name='EncryptMethod' required='Y'/>
      <field name='HeartBtInt' required='Y'/>
      <field name='RawDataLength' required='N'/>
      <field name='RawData' required='N'/>
      <field name='ResetSeqNumFlag' required='N'/>
      <field name='NextExpectedMsgSeqNum' required='N'/>
      <field name='MaxMessageSize' required='N'/>
      <field name='TestMessageIndicator' required='N'/>
      <field name='Username' required='N'/>
      <field name='Password' required='N'/>
      <field name='DefaultCstmApplVerID' required='N'/>
      <field name='BusinessSessionDate' required='N'/>
      <field name='MaxMsgPerSecond' required='N'/>    
      <field name='DefaultApplVerID' required='Y'/>
      <component name='MsgTypeGrp' required='N'/>
    </message>
  </messages>
  <components>
    <component name='MsgTypeGrp'>
      <group name='NoMsgTypes' required='N'>
        <field name='RefMsgType' required='N'/>
        <field name='MsgDirection' required='N'/>
        <field name='RefApplVerID' required='N'/>
        <field name='RefCstmApplVerID' required='N'/>
      </group>
    </component>
  </components>
  <fields>
    <field number='1408' name='DefaultCstmApplVerID' type='STRING'/>
    <field name='MaxMsgPerSecond' number='21504' type='INT'/>
    <field name='BusinessSessionDate' number='21505' type='LOCALMKTDATE'/>

I´ve double checked FIX message I´m sending or receiving using Wireshark and I´m just sending a Logon message (MsgType=A) and receiving a Logon msg, a Network Status Response (MsgType=BD) and several Registration Instructions Response (MsgType=p) in an endless loop.我已经仔细检查了我使用 Wireshark 发送或接收的 FIX 消息,我只是发送登录消息(MsgType=A)并接收登录消息、网络状态响应(MsgType=BD)和几个注册指令响应( MsgType=p) 无限循环。 I assume this is due to ReconnectInterval sets to 30 in my ini file.我认为这是由于我的 ini 文件中的 ReconnectInterval 设置为 30。 But mystery here is my machine is not sending any RejectMsg (MsgType=3 I guess), reject information is just displayed in console, but not sent to the network.但这里的谜团是我的机器没有发送任何 RejectMsg(我猜是 MsgType=3),reject 信息只是显示在控制台中,而不是发送到网络。 I think tunnel itself is being cut off from quickfix as default behavior when something is wrong, but not even sure.我认为当出现问题时,隧道本身会从 quickfix 中作为默认行为被切断,但甚至不确定。

My question is, what I'm doing wrong?我的问题是,我做错了什么? I think quickfix is interrumpting a conexion which is accepted and pertectly ok from server, but I don't know why, so I cannot fix it.我认为 quickfix 正在中断一个被服务器接受并且完全正常的 conexion,但我不知道为什么,所以我无法修复它。

Any idea?任何的想法?

Thanks a lot for your help非常感谢你的帮助

I think I´ve found the problem.我想我已经找到了问题所在。 Config file info referring to TargetCompID and TargetSubID are not being considered to create Logon message but apparently they are considered to double check server response.不考虑引用 TargetCompID 和 TargetSubID 的配置文件信息来创建登录消息,但显然它们被视为仔细检查服务器响应。 I had different values in ini file and in toAdmin method.我在 ini 文件和 toAdmin 方法中有不同的值。 Modifying these values in ini file in order to they are aligned with the ones provided in toAdmin seems to fix the problem.修改 ini 文件中的这些值以使它们与 toAdmin 中提供的值保持一致似乎可以解决问题。

Thanks for reading me :_)感谢您阅读我 :_)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM