I'm new to FIX protocol. We're using a TCP network stream to establish a connection then we read and write the FIX message to this stream. But when I send the logon message all I get is 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.
To login into a FIX server, you need
LOGON message (35=A)
LOGON message (35=A)
Heartbeat messages (35=0)
I would like to recommend you to use a FIX library to handle FIX messages. FIX Protocol has several messages (session messages
, application messages
, etc), some are very complex messages.
I've used http://quickfixengine.org/ for dotnet and c++ and quickfix/j for java.
If you use a library, it will handle all "session messages"
and you need to handle just the "application messages"
, e.g. NewOrderSingle(35=D)
, ExecutionReport(35=8)
, etc.
To keep the FIX Connection up and running, you (or the library) need exchange several "session messages"
to sync the IDs. The IDs (both sides) are very important receive the messages correctly.