marketdata-shootout/marketdata.xml

82 lines
4.3 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="UTF-8"?>
<sbe:messageSchema xmlns:sbe="http://fixprotocol.io/2016/sbe"
package="marketdata_sbe"
id="1"
version="0"
semanticVersion="5.2"
description="Trivial market data schema">
<types>
<!-- "common types" used by SBE -->
<composite name="messageHeader" description="Message identifiers and length of message root.">
<type name="blockLength" primitiveType="uint16"/>
<type name="templateId" primitiveType="uint16"/>
<type name="schemaId" primitiveType="uint16"/>
<type name="version" primitiveType="uint16"/>
</composite>
<composite name="groupSizeEncoding" description="Repeating group dimensions.">
<type name="blockLength" primitiveType="uint16"/>
<type name="numInGroup" primitiveType="uint16"/>
</composite>
<composite name="varStringEncoding" description="Variable length UTF-8 String.">
<type name="length" primitiveType="uint32" maxValue="1073741824"/>
<type name="varData" primitiveType="uint8" length="0" characterEncoding="UTF-8"/>
</composite>
<composite name="varAsciiEncoding" description="Variable length ASCII String.">
<type name="length" primitiveType="uint32" maxValue="1073741824"/>
<type name="varData" primitiveType="uint8" length="0" characterEncoding="ASCII"/>
</composite>
<composite name="varDataEncoding" description="Variable length binary blob.">
<type name="length" primitiveType="uint32" maxValue="1073741824"/>
<type name="varData" primitiveType="uint8" length="0"/>
</composite>
<!-- types we're actually interested in implementing -->
<composite name="Trade">
<type name="price" primitiveType="uint64"/>
<type name="size" primitiveType="uint32"/>
</composite>
<composite name="Quote">
<type name="price" primitiveType="uint64"/>
<type name="size" primitiveType="uint32"/>
<type name="flags" primitiveType="uint8"/>
<ref name="side" type="Side"/>
</composite>
<enum name="Side" encodingType="uint8">
<validValue name="Buy">0</validValue>
<validValue name="Sell">1</validValue>
</enum>
<enum name="MsgType" encodingType="uint8">
<validValue name="Trade">0</validValue>
<validValue name="Quote">1</validValue>
</enum>
</types>
<sbe:message name="MultiMessage" id="1" description="Wrapper for sending multiple message chunks at a time">
<field name="sequence_number" id="1" type="uint64"/>
<group name="messages" id="2">
<!--
Can't embed messages within each other, so the "MultiMessage" block
actually includes each `message` via a group
-->
<field name="timestamp" id="3" type="int64"/>
<!--
SBE specifically doesn't have "union" types, so we include both a `trade` and `quote`
here and the tag to identify.
https://github.com/real-logic/simple-binary-encoding/issues/232
In the future, there are a couple options:
1. Create a "payload header" type and promote "trade" and "quote" to <sbe:message>,
since the SBE message header is already able to distinguish between message types
2. Create a "group" for each message type, and just include no elements of that type.
Uses a `u16` for each message type, instead of padding bytes for the message size.
3. Split up the message components and use "session types" to chain things together,
as in https://polysync.io/blog/session-types-for-hearty-codecs
For now, this message format was chosen to approximate the schemas of Cap'n Proto and Flatbuffers
-->
<field name="msg_type" id="4" type="MsgType"/>
<field name="trade" id="5" type="Trade"/>
<field name="quote" id="6" type="Quote"/>
<data name="symbol" id="100" type="varAsciiEncoding"/>
</group>
</sbe:message>
</sbe:messageSchema>