[erlang-questions] Erlang and FIX protocol

Per Melin <>
Fri May 4 17:56:25 CEST 2012

Max Lapshin wrote:

> On Thu, May 3, 2012 at 6:31 PM, Per Melin <> wrote:
>> The problem with the syntax is that it is simplistic. It does not even give you enough information to be able to tokenize a message or to find message boundaries. See binary fields below.
> It is not exactly so. Standard tells that whole packet must start from
> field 8 with proto version and next field must be byte length without
> checksum. So this is a good way to detect real byte length.

When you said that the syntax was VERY simple I assumed you took the view that FIX lives on top of a format of Tag=Value<SOH> that you can first tokenize independent of the dictionary (which of course has some 900 fields and can be freely extended). It was that basic format I commented on.

If we were to define a grammar that covered header/body/trailer separation, optional/required fields, optional/required repeating nested context-dependent groups and components, binary data fields, etc, then it wouldn't be very simple anymore, right? Or do you regard these as semantic concepts, not syntax? Since none of them have any lexical clues I find it weirdly hard to draw a clear line between syntax and semantics.

How complete and strict an implementation are you aiming for? For example, if a required field or group is missing, a field appears in a message where it does not belong, a header field appears in the body, fields are out of order in a group, a value is not valid according to the spec, etc, are you going to detect it? Are you going to send a reject message? If you take a more relaxed stance many complexities melt away. My mistake was to be very strict in my implementation.

>> You are not verifying the message checksum, which in the end is not as straight forward as it may first seem.
> What is bad with it?

I had a distinct memory of a corner case, but now I can't remember what it was, and it doesn't come back to me when I read my own implementation. I must have been mistaken.

>> 1> fix:decode(<<"8=FIX.4.4",1,"9=23",1,"35=0",1,"93=10",1,"89=A",1,"89=234",1,"10=999",1>>).
> Specification tells:
> Data fields are always immediately preceded by a length field. The
> length field should specify the number of bytes of the value of the
> data field (up to but not
> including the terminating SOH).
> "A|89=234|1" is 10 bytes but there must be terminating SOH after this.

I picked 10 as length just to demonstrate that you ignore it. If you change signature length from 10 to 8 you should get a message that is valid, but still incorrectly parsed.

I just noticed that a length of "ZZ" is parsed as 462 while ".." is parsed as -0.2 and "-1" is parsed as -29. ;)

More information about the erlang-questions mailing list