简体   繁体   English

如何在FIX协议中登录?

[英]How to Logon in FIX Protocol?

I'm new to FIX protocol. 我是FIX协议的新手。 We're using a TCP network stream to establish a connection then we read and write the FIX message to this stream. 我们使用TCP网络流建立连接,然后在该流中读取和写入FIX消息。 But when I send the logon message all I get is 0. 但是,当我发送登录消息时,我得到的只是0。

It would be helpful if someone could share a snippet of working code. 如果有人可以共享一小段工作代码,将很有帮助。

NetworkStream stm = openStream();
ASCIIEncoding asen = new ASCIIEncoding();
byte[] ba = asen.GetBytes(data);
Console.WriteLine("Transmitting.....");
stm.Write(ba, 0, ba.Length);

byte[] bb = new byte[1024];
while (true)
{
    int k = stm.Read(bb, 0, 1024);
    if (k != 0)
    {
        for (int i = 0; i < k; i++)
            Console.Write(Convert.ToChar(bb[i]));
        Console.Write(k);
    }
}

I'm assuming you are the Initiator side once you are sending the LOGON (35=A) message. 我假设发送LOGON (35=A)消息后,您就是发起方。

To login into a FIX server, you need 要登录FIX服务器,您需要

  • connect to a FIX server 连接到FIX服务器
  • send a LOGON message (35=A) 发送LOGON message (35=A)
  • receive the LOGON message (35=A) 收到LOGON message (35=A)
  • send and receive Heartbeat messages (35=0) 发送和接收Heartbeat messages (35=0)

I would like to recommend you to use a FIX library to handle FIX messages. 我建议您使用FIX库来处理FIX消息。 FIX Protocol has several messages ( session messages , application messages , etc), some are very complex messages. FIX协议具有多个消息( session messagesapplication messages等),其中一些消息非常复杂。 I've used http://quickfixengine.org/ for dotnet and c++ and quickfix/j for java. 我已经将http://quickfixengine.org/用于dotnet和c ++,将quickfix / j用于Java。

If you use a library, it will handle all "session messages" and you need to handle just the "application messages" , eg NewOrderSingle(35=D) , ExecutionReport(35=8) , etc. 如果使用库,它将处理所有"session messages"而您只需要处理"application messages" ,例如NewOrderSingle(35=D)ExecutionReport(35=8)等。

To keep the FIX Connection up and running, you (or the library) need exchange several "session messages" to sync the IDs. 为了保持FIX连接的正常运行,您(或库)需要交换多个"session messages"来同步ID。 The IDs (both sides) are very important receive the messages correctly. ID(双方)非常重要,正确接收消息。

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

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