How to decode sequences in FAST Protocol

1.2k views Asked by At

I have some problems with sequences in FAST Message
For example I have next template xml

 <template name="DefaultIncrementalRefreshMessage" id="1">
    <string name="ApplVerID" id="1128">
        <constant value="9"/>
    </string>
    <string name="MessageType" id="35">
        <constant value="X"/>
    </string>
    <string name="SenderCompID" id="49">
        <constant value="MOEX"/>
    </string>
    <uInt32 name="MsgSeqNum" id="34"/>
    <uInt64 name="SendingTime" id="52"/>
    <uInt32 name="LastFragment" id="893" presence="optional"/>
    <sequence name="MDEntries">
        <length name="NoMDEntries" id="268"/>
        <uInt32 name="MDUpdateAction" id="279"/>
        <string name="MDEntryType" id="269"/>
        <uInt64 name="SecurityID" id="48" presence="optional"/>
        <uInt32 name="SecurityIDSource" id="22">
            <constant value="8"/>
        </uInt32>
        <string name="Symbol" id="55" presence="optional"/>
        <string name="SecurityGroup" id="1151" presence="optional"/>
        <uInt32 name="ExchangeTradingSessionID" id="5842" presence="optional"/>
        <uInt32 name="RptSeq" id="83"/>
        <uInt32 name="MarketDepth" id="264" presence="optional"/>
        <uInt32 name="MDPriceLevel" id="1023" presence="optional"/>
        <int64 name="MDEntryID" id="278" presence="optional"/>
        <decimal name="MDEntryPx" id="270" presence="optional"/>
        <int64 name="MDEntrySize" id="271" presence="optional"/>
        <uInt32 name="MDEntryDate" id="272" presence="optional"/>
        <uInt32 name="MDEntryTime" id="273"/>
        <int32 name="NumberOfOrders" id="346" presence="optional"/>
        <string name="MDEntryTradeType" id="20003" presence="optional"/>
        <int32 name="TrdType" id="828" presence="optional"/>
        <decimal name="LastPx" id="31" presence="optional"/>
        <int32 name="MDFlags" id="20017" presence="optional"/>
        <string name="Currency" id="15" presence="optional"/>
        <uInt64 name="Revision" id="20018" presence="optional"/>
        <string name="OrderSide" id="10504" presence="optional"/>
    </sequence>
</template>

At first I get PMap of our template, the next step I get template id after that I read bytes one by one and all works fine but if I get sequence 'MDEntries' my data will be incorrect because the sequence of bytes will be broken.

I saw the next picture with FAST Message structure and think that I should read PMap of sequence and length 'NoMDEntries' and then read bytes one by one, is it correct? I used to think that I just should read bytes one by one and delete stop bits FAST Message structure

Help me, how do I parse a 'sequence' correctly

1

There are 1 answers

0
Vitaly Antonov On

According to the FAST protocol specification, if there are no fields in a sequence which require a PMap bit presence (like in your case), then the PMap should not be present in the stream. To understand if a field requires a PMap bit presence, you can use the following table:

             | PMap Bit is required
-----------------------------------
Operator     | Mandatory | Optional
-----------------------------------
None         | no        | no
<constant/>  | no        | yes
<copy/>      | yes       | yes
<default/>   | yes       | yes
<delta/>     | no        | no
<increment/> | yes       | yes
<tail/>      | yes       | yes

You can refer to paragraph 10.5 and Appendix 3.3.1 in this document: http://ftp.moex.com/pub/FAST/ASTS/docs/FAST%20Specification1_1.pdf