Template Id in Presence Map?

Imported from previous forum

I have a template with seven things in it and the first time I get it I get the presence map in one byte. There is no space for the template id to be in the pmap and the template id is sent. Yet I am told that the template id is optional and may be in the first bit. Sometimes I am getting funny looking pmaps and no template id.

How does this work…

I can see this in the document:

A segment has a header consisting of a Presence Map followed by an optional Template Identifier. The segment has a template identifier either if it is a message segment, or if the segment appears as the result of a dynamic template reference instruction. A template identifier is encoded as if a copy operator was specified. The operator uses the global dictionary and has an internal key common to all template identifier fields. This means that a segment with a template identifier does not always contain the template identifier physically. However, the first bit in the presence map is allocated by its copy operator.

But I have no idea what it means…

Sorry please help…

The template identifier is logically mandatory, that is, the decoder must always know the TID in order to decode the message. However, the TID is not present in the stream for every message since it uses an implicit copy operator. This implicit copy operator always allocates the first bit in the presence map. If the bit is 1, then the TID is present in the stream, and if the bit is 0, then the TID is the same as the TID of the previous message.

Another thing to note is that a presence map has variable length and will always be as long as necessary to accommodate all the required bits, but not longer. If the fields of your template require seven bits, then the maximum number of bits in the PMAP will be eight since the TID copy operator uses the first bit. This means that the PMAP will be one or two bytes depending of the value of the last bit. If it is 1, then a two byte PMAP is used and if it is 0, then a single byte is used since trailing zeroes are truncated.

The text you’ve quoted describes two different types of segments, those used at the message level, which have a TID, and those used in groups and sequences which don’t have a TID. The word “optional” here refers to that difference.

/David

I have a template with seven things in it and the first time I get it I
get the presence map in one byte. There is no space for the template id
to be in the pmap and the template id is sent. Yet I am told that the
template id is optional and may be in the first bit. Sometimes I am
getting funny looking pmaps and no template id.

How does this work…

I can see this in the document:

A segment has a header consisting of a Presence Map followed by an
optional Template Identifier. The segment has a template identifier
either if it is a message segment, or if the segment appears as the
result of a dynamic template reference instruction. A template
identifier is encoded as if a copy operator was specified. The
operator uses the global dictionary and has an internal key common to
all template identifier fields. This means that a segment with a
template identifier does not always contain the template identifier
physically. However, the first bit in the presence map is allocated by
its copy operator.

But I have no idea what it means…

Sorry please help…

This does not make sense… you are saying the fist bit in the presence map is always the template id copy bit…

But here is my template:

// BIT ONE // BIT TWO // BIT THREE // BIT FOUR // BIT FIVE // BIT SIX // BIT SEVEN

And here is a log od my fist message from ebs live:

rcv message 2 --------------------------------------------------------------
0023 , 125 , 7d(fd) , 11111101 , } =pmap
0024 , 002 , 02(82) , 10000010 , HeatBeat message
0025 , 056 , 38(b8) , 10111000 , 8 =BodyLength
0026 , 069 , 45(45) , 01000101 , E
0027 , 066 , 42(42) , 01000010 , B
0028 , 083 , 53(53) , 01010011 , S
0029 , 070 , 46(46) , 01000110 , F
0030 , 105 , 69(69) , 01101001 , i
0031 , 120 , 78(78) , 01111000 , x
0032 , 083 , 53(53) , 01010011 , S
0033 , 101 , 65(65) , 01100101 , e
0034 , 114 , 72(72) , 01110010 , r
0035 , 118 , 76(76) , 01110110 , v
0036 , 101 , 65(65) , 01100101 , e
0037 , 114 , 72(f2) , 11110010 , r =SenderCompID
0038 , 048 , 30(b0) , 10110000 , 0 =TargetCompID
0039 , 001 , 01(81) , 10000001 , =MsgSeqNum
0040 , 000 , 00(80) , 10000000 , =SendingTime
0041 , 050 , 32(32) , 00110010 , 2
0042 , 048 , 30(30) , 00110000 , 0
0043 , 048 , 30(30) , 00110000 , 0
0044 , 057 , 39(39) , 00111001 , 9
0045 , 048 , 30(30) , 00110000 , 0
0046 , 049 , 31(31) , 00110001 , 1
0047 , 049 , 31(31) , 00110001 , 1
0048 , 054 , 36(36) , 00110110 , 6
0049 , 045 , 2d(2d) , 00101101 , -
0050 , 048 , 30(30) , 00110000 , 0
0051 , 055 , 37(37) , 00110111 , 7
0052 , 058 , 3a(3a) , 00111010 , :
0053 , 049 , 31(31) , 00110001 , 1
0054 , 056 , 38(38) , 00111000 , 8
0055 , 058 , 3a(3a) , 00111010 , :
0056 , 052 , 34(34) , 00110100 , 4
0057 , 049 , 31(31) , 00110001 , 1
0058 , 046 , 2e(2e) , 00101110 , .
0059 , 050 , 32(32) , 00110010 , 2
0060 , 056 , 38(38) , 00111000 , 8
0061 , 048 , 30(b0) , 10110000 , 0 =SendingTime
0062 , 049 , 31(31) , 00110001 , 1
0063 , 050 , 32(32) , 00110010 , 2
0064 , 057 , 39(b9) , 10111001 , 9 =CheckSum
That was a Heartbeat Message

Notice here the first bit of the presence map is not the template id.
I know this (a) because the template needs seven bits and is sent in one byte (b) The TestRequestId correctly has a zero maked in the place it sould be if the template id is omitted.

The message I get is another heartbeat and looks like this:

rcv message 3 --------------------------------------------------------------
0065 , 001 , 01(81) , 10000001 , =pmap
0066 , 008 , 08(88) , 10001000 , must be Sending Time delta
0067 , 057 , 39(39) , 00111001 , 9
0068 , 058 , 3a(3a) , 00111010 , :
0069 , 052 , 34(34) , 00110100 , 4
0070 , 049 , 31(31) , 00110001 , 1
0071 , 046 , 2e(2e) , 00101110 , .
0072 , 050 , 32(32) , 00110010 , 2
0073 , 056 , 38(38) , 00111000 , 8
0074 , 051 , 33(b3) , 10110011 , 3 must be Sending Time string
0075 , 049 , 31(31) , 00110001 , 1
0076 , 051 , 33(33) , 00110011 , 3
0077 , 052 , 34(b4) , 10110100 , 4 must be Checksum

Yet here we are getting only one bit in the template id and two fields changing - again impossible according to my understanding of the spec.

Template had makes in the web site did not like. Here it is again:

template name=“Heartbeat” id="2"
typeRef name=“Heartbeat”/
string name=“BeginString” id="8"constant value=“FIX.4.4”//string
int32 name=“BodyLength” id="9"copy//int32 // BIT ONE
string name=“MsgType” id="35"constant value=“0”//string
string name=“SenderCompID” id="49"copy//string // BIT TWO
string name=“TargetCompID” id="56"copy//string // BIT THREE
uInt64 name=“MsgSeqNum” id="34"increment//uInt64 // BIT FOUR
string name=“SendingTime” id="52"delta//string // BIT FIVE
string name=“TestRequestId” presence=“optional” id="112"copy//string // BIT SIX
string name=“CheckSum” id="10"copy//string // BIT SEVEN

The delta operator doesn’t use a bit in the presence map so your template only use 7 bits (6 bits + the TID bit).

/David

This does not make sense… you are saying the fist bit in the presence
map is always the template id copy bit…

But here is my template:

// BIT ONE // BIT TWO // BIT THREE // BIT FOUR // BIT FIVE //
BIT SIX // BIT SEVEN

And here is a log od my fist message from ebs live:

rcv message 2 --------------------------------------------------------------
0023 , 125 , 7d(fd) , 11111101 , } =pmap 0024 , 002 , 02(82) , 10000010
, HeatBeat message 0025 , 056 , 38(b8) , 10111000 , 8 =BodyLength 0026 ,
069 , 45(45) , 01000101 , E 0027 , 066 , 42(42) , 01000010 , B 0028 ,
083 , 53(53) , 01010011 , S 0029 , 070 , 46(46) , 01000110 , F 0030 ,
105 , 69(69) , 01101001 , i 0031 , 120 , 78(78) , 01111000 , x 0032 ,
083 , 53(53) , 01010011 , S 0033 , 101 , 65(65) , 01100101 , e 0034 ,
114 , 72(72) , 01110010 , r 0035 , 118 , 76(76) , 01110110 , v 0036 ,
101 , 65(65) , 01100101 , e 0037 , 114 , 72(f2) , 11110010 , r
=SenderCompID 0038 , 048 , 30(b0) , 10110000 , 0 =TargetCompID 0039 ,
001 , 01(81) , 10000001 , =MsgSeqNum 0040 , 000 , 00(80) , 10000000 ,
=SendingTime 0041 , 050 , 32(32) , 00110010 , 2 0042 , 048 , 30(30) ,
00110000 , 0 0043 , 048 , 30(30) , 00110000 , 0 0044 , 057 , 39(39) ,
00111001 , 9 0045 , 048 , 30(30) , 00110000 , 0 0046 , 049 , 31(31) ,
00110001 , 1 0047 , 049 , 31(31) , 00110001 , 1 0048 , 054 , 36(36) ,
00110110 , 6 0049 , 045 , 2d(2d) , 00101101 , - 0050 , 048 , 30(30) ,
00110000 , 0 0051 , 055 , 37(37) , 00110111 , 7 0052 , 058 , 3a(3a) ,
00111010 , : 0053 , 049 , 31(31) , 00110001 , 1 0054 , 056 , 38(38) ,
00111000 , 8 0055 , 058 , 3a(3a) , 00111010 , : 0056 , 052 , 34(34) ,
00110100 , 4 0057 , 049 , 31(31) , 00110001 , 1 0058 , 046 , 2e(2e) ,
00101110 , . 0059 , 050 , 32(32) , 00110010 , 2 0060 , 056 , 38(38) ,
00111000 , 8 0061 , 048 , 30(b0) , 10110000 , 0 =SendingTime 0062 , 049
, 31(31) , 00110001 , 1 0063 , 050 , 32(32) , 00110010 , 2 0064 , 057 ,
39(b9) , 10111001 , 9 =CheckSum That was a Heartbeat Message

Notice here the first bit of the presence map is not the template id. I
know this (a) because the template needs seven bits and is sent in one
byte (b) The TestRequestId correctly has a zero maked in the place it
sould be if the template id is omitted.

The message I get is another heartbeat and looks like this:

rcv message 3 --------------------------------------------------------------
0065 , 001 , 01(81) , 10000001 , =pmap 0066 , 008 , 08(88) , 10001000 ,
must be Sending Time delta 0067 , 057 , 39(39) , 00111001 , 9 0068 , 058
, 3a(3a) , 00111010 , : 0069 , 052 , 34(34) , 00110100 , 4 0070 , 049 ,
31(31) , 00110001 , 1 0071 , 046 , 2e(2e) , 00101110 , . 0072 , 050 ,
32(32) , 00110010 , 2 0073 , 056 , 38(38) , 00111000 , 8 0074 , 051 ,
33(b3) , 10110011 , 3 must be Sending Time string 0075 , 049 , 31(31) ,
00110001 , 1 0076 , 051 , 33(33) , 00110011 , 3 0077 , 052 , 34(b4) ,
10110100 , 4 must be Checksum

Yet here we are getting only one bit in the template id and two fields
changing - again impossible according to my understanding of the spec.

Yes thanks that explains it. So the first bit of the presence map is always the template id. I missed those rules.

Just saw that David already answered. I will still post and hope it helps rather than confuses.

The template ID (TID) itself is never in the Pmap, it optionally follows the Pmap. The first bit of the Pmap tells you whether the TID is physically in the message. The implicit copy operator for the TID means that the TID does not need to be sent if it does not change from one message to the next.

I guess the notion of “first bit” also needs to be explained. A Pmap is a stop-bit encoded entity, i.e. it can span multiple bytes and the most significant bit of each byte tells you whether the next byte still belongs to the Pmap or not. Thus “first bit” is the “first significant bit” and there are at most seven significant bits in each byte.

The message you get is thus either <…> or just <…>.

Seven data fields (=things?) require at most eight bits in the Pmap (exceptions are well defined and mean that no Pmap bit is used but the field is physically in the message). You need one more due to the TID.

I have a template with seven things in it and the first time I get it I
get the presence map in one byte. There is no space for the template id
to be in the pmap and the template id is sent. Yet I am told that the
template id is optional and may be in the first bit. Sometimes I am
getting funny looking pmaps and no template id.

How does this work…

I can see this in the document:

A segment has a header consisting of a Presence Map followed by an
optional Template Identifier. The segment has a template identifier
either if it is a message segment, or if the segment appears as the
result of a dynamic template reference instruction. A template
identifier is encoded as if a copy operator was specified. The
operator uses the global dictionary and has an internal key common to
all template identifier fields. This means that a segment with a
template identifier does not always contain the template identifier
physically. However, the first bit in the presence map is allocated by
its copy operator.

But I have no idea what it means…

Sorry please help…