diff --git a/.gitignore b/.gitignore index 2762bb4..3463097 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .settings .project -*.docx +target +.DS_Store diff --git a/README.md b/README.md index 9aadb0c..81f4ac4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,11 @@ # fix-simple-binary-encoding This project contains specifications and resources for Simple Binary Encoding (SBE). -SBE is a FIX standard for binary message encoding. +SBE is a FIX standard for binary message encoding. + +## *News* + +[application/sbe](https://www.iana.org/assignments/media-types/application/sbe) has been registered as a media type (formerly MIME type) at Internet Assigned Numbers Authority (IANA). A media type defines the format of the contents of an Internet message. ## Protocol stack SBE is part of a family of protocols created by the High Performance Working Group @@ -13,16 +17,16 @@ SBE is part of a family of protocols created by the High Performance Working Gro The planned lifecycle of this project is to roll out new features in a series of release candidates. After each release candidate is approved, it will be exposed to public review. Issues may be entered here in GitHub or in a discussion forum on the FIX Trading Community site. When a version is considered complete, the last release candidate will be promoted to Draft Standard. Following further public review, a Draft Standard may be promoted to the final specification for that version. Only minor errata are permitted. To reach the final stage, the Draft Standard must be reviewed for no less than 6 months, and at least two interoperable implementations must be certified. That version is henceforth immutable. -SBE version 1.0 has reached the final technical specification stage while release candidates have been developed for proposed version 2.0. +SBE version 1.0 has reached the final technical specification stage while release candidates have been developed for proposed version 2.0. ### Version 2.0 Release Candidate 2 -Version 2.0 RC2 was approved by the Global Technical Committee on August 15, 2019 for 90 day public review. +Version 2.0 RC2 was approved by the Global Technical Committee on August 15, 2019 for 90 day public review. Themes of this release: * Clarification about single-byte character sets -* Improvement of the XML schema, including support for XIinclude +* Improvement of the XML schema, including support for XInclude ### Version 2.0 Release Candidate 1 @@ -39,9 +43,9 @@ Version 1.0 Draft Standard was promoted to SBE version 1.0 Technical Specificati The standard met these criteria for promotion: * More than 6 months public review. During the period, some minor errors were found, and the errata were incorporated into the final specification. Thanks to users who detected those errors. -* At least two interopable implementations. This was demonstrated with the conformance test suite described below. +* At least two interoperable implementations. This was demonstrated with the conformance test suite described below. -SBE standards are available here in GitHub and on the [FIX Trading Community](http://www.fixtradingcommunity.org/pg/structure/tech-specs/simple-binary-encoding) site. +SBE standards are available here in GitHub and on the [FIX Trading Community](http://www.fixtradingcommunity.org/pg/structure/tech-specs/simple-binary-encoding) site. SBE version 1.0 specification with errata was posted July 27, 2018. @@ -57,10 +61,6 @@ Interested parties who wish to participate in the FIX High Performance Working G The [SBE Conformance project](https://github.com/FIXTradingCommunity/fix-sbe-conformance) provides a conformance test suite to verify interoperability of SBE implementations. All implementors are invited to demonstrate their conformance to the standard. ## License -FIX Simple Binary Encoding specifications are © Copyright 2014-2019 FIX Protocol Ltd. +FIX Simple Binary Encoding specifications are © Copyright 2014-2020 FIX Protocol Ltd. FIX Simple Binary Encoding by FIX Protocol Ltd. is licensed under a Creative Commons Attribution-NoDerivatives 4.0 International License.Based on a work at https://github.com/FIXTradingCommunity/fix-simple-binary-encoding - - - - diff --git a/v1-0-RC1/doc/publication/FIX-Simple-Binary-Encoding-Specification-v0.9.2_RC1.pdf b/v1-0-RC1/doc/publication/FIX-Simple-Binary-Encoding-Specification-v0.9.2_RC1.pdf new file mode 100644 index 0000000..011b763 Binary files /dev/null and b/v1-0-RC1/doc/publication/FIX-Simple-Binary-Encoding-Specification-v0.9.2_RC1.pdf differ diff --git a/v1-0-RC2/doc/publication/Simple-Binary-Encoding-Release-Candidate-2.pdf b/v1-0-RC2/doc/publication/Simple-Binary-Encoding-Release-Candidate-2.pdf new file mode 100644 index 0000000..ba6bdfd Binary files /dev/null and b/v1-0-RC2/doc/publication/Simple-Binary-Encoding-Release-Candidate-2.pdf differ diff --git a/v1-0-RC3/doc/04MessageSchema.md b/v1-0-RC3/doc/04MessageSchema.md index d9e89a1..1a2e7fa 100644 --- a/v1-0-RC3/doc/04MessageSchema.md +++ b/v1-0-RC3/doc/04MessageSchema.md @@ -312,7 +312,7 @@ The `name` attribute of the `` uniquely identifies it. | sinceVersion | Documents the version of a schema in which a choice was added | nonNegativeInteger | default = 0 | | | deprecated | Documents the version of a schema in which a choice was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | -#### `< choice >` element content +#### `` element content The element is required to carry a value, which is an unsigned integer representing a zero-based index to a bit within a bitset. Zero is the @@ -558,4 +558,4 @@ Reserved element names | unit | timestamp, TZ time | | version | messageHeader | | week | MonthYear | -| year | MonthYear | \ No newline at end of file +| year | MonthYear | diff --git a/v1-0-RC3/doc/publication/Simple-Binary-Encoding-Release-Candidate-3.pdf b/v1-0-RC3/doc/publication/Simple-Binary-Encoding-Release-Candidate-3.pdf new file mode 100644 index 0000000..a8d36af Binary files /dev/null and b/v1-0-RC3/doc/publication/Simple-Binary-Encoding-Release-Candidate-3.pdf differ diff --git a/v1-0-RC4/doc/publication/Simple-Binary-Encoding-Release-Candidate-4.pdf b/v1-0-RC4/doc/publication/Simple-Binary-Encoding-Release-Candidate-4.pdf new file mode 100644 index 0000000..463871c Binary files /dev/null and b/v1-0-RC4/doc/publication/Simple-Binary-Encoding-Release-Candidate-4.pdf differ diff --git a/v1-0-STANDARD/doc/00Title.md b/v1-0-STANDARD/doc/00Title.md deleted file mode 100644 index a81e663..0000000 --- a/v1-0-STANDARD/doc/00Title.md +++ /dev/null @@ -1,24 +0,0 @@ - - -# Simple Binary Encoding -## Technical Specification - -Version 1.0 – February 9, 2017 - -THIS DOCUMENT IS THE FINAL VERSION OF A FIX TECHNICAL STANDARD. THIS VERSION HAS BEEN APPROVED BY THE GLOBAL TECHNICAL COMMITTEE AS THE FINAL STEP IN CREATING A NEW FIX TECHNICAL STANDARD OR A NEW VERSION OF AN EXISTING FIX TECHNICAL STANDARD. POTENTIAL ADOPTERS ARE STRONGLY ENCOURAGED TO USE ONLY THE FINAL VERSION. EXISTING ADOPTERS ARE STRONGLY ENCOURAGED TO UPGRADE TO THE FINAL VERSION. - -DISCLAIMER - -THE INFORMATION CONTAINED HEREIN AND THE FINANCIAL INFORMATION EXCHANGE PROTOCOL (COLLECTIVELY, THE "FIX PROTOCOL") ARE PROVIDED "AS IS" AND NO PERSON OR ENTITY ASSOCIATED WITH THE FIX PROTOCOL MAKES ANY REPRESENTATION OR WARRANTY, EXPRESS OR IMPLIED, AS TO THE FIX PROTOCOL (OR THE RESULTS TO BE OBTAINED BY THE USE THEREOF) OR ANY OTHER MATTER AND EACH SUCH PERSON AND ENTITY SPECIFICALLY DISCLAIMS ANY WARRANTY OF ORIGINALITY, ACCURACY, COMPLETENESS, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SUCH PERSONS AND ENTITIES DO NOT WARRANT THAT THE FIX PROTOCOL WILL CONFORM TO ANY DESCRIPTION THEREOF OR BE FREE OF ERRORS. THE ENTIRE RISK OF ANY USE OF THE FIX PROTOCOL IS ASSUMED BY THE USER. - -NO PERSON OR ENTITY ASSOCIATED WITH THE FIX PROTOCOL SHALL HAVE ANY LIABILITY FOR DAMAGES OF ANY KIND ARISING IN ANY MANNER OUT OF OR IN CONNECTION WITH ANY USER'S USE OF (OR ANY INABILITY TO USE) THE FIX PROTOCOL, WHETHER DIRECT, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL (INCLUDING, WITHOUT LIMITATION, LOSS OF DATA, LOSS OF USE, CLAIMS OF THIRD PARTIES OR LOST PROFITS OR REVENUES OR OTHER ECONOMIC LOSS), WHETHER IN TORT (INCLUDING NEGLIGENCE AND STRICT LIABILITY), CONTRACT OR OTHERWISE, WHETHER OR NOT ANY SUCH PERSON OR ENTITY HAS BEEN ADVISED OF, OR OTHERWISE MIGHT HAVE ANTICIPATED THE POSSIBILITY OF, SUCH DAMAGES. - -**DRAFT OR NOT RATIFIED PROPOSALS** (REFER TO PROPOSAL STATUS AND/OR SUBMISSION STATUS ON COVER PAGE) ARE PROVIDED "AS IS" TO INTERESTED PARTIES FOR DISCUSSION ONLY. PARTIES THAT CHOOSE TO IMPLEMENT THIS DRAFT PROPOSAL DO SO AT THEIR OWN RISK. IT IS A DRAFT DOCUMENT AND MAY BE UPDATED, REPLACED, OR MADE OBSOLETE BY OTHER DOCUMENTS AT ANY TIME. THE FIX GLOBAL TECHNICAL COMMITTEE WILL NOT ALLOW EARLY IMPLEMENTATION TO CONSTRAIN ITS ABILITY TO MAKE CHANGES TO THIS SPECIFICATION PRIOR TO FINAL RELEASE. IT IS INAPPROPRIATE TO USE FIX WORKING DRAFTS AS REFERENCE MATERIAL OR TO CITE THEM AS OTHER THAN “WORKS IN PROGRESS”. THE FIX GLOBAL TECHNICAL COMMITTEE WILL ISSUE, UPON COMPLETION OF REVIEW AND RATIFICATION, AN OFFICIAL STATUS ("APPROVED") OF/FOR THE PROPOSAL AND A RELEASE NUMBER. - -No proprietary or ownership interest of any kind is granted with respect to the FIX Protocol (or any rights therein). - -Copyright 2013-2017 FIX Protocol Ltd., all rights reserved. - - -FIX Simple Binary Encoding by [FIX Protocol Ltd.](http://www.fixtradingcommunity.org/) is licensed under a [Creative Commons Attribution-NoDerivatives 4.0 International License](http://creativecommons.org/licenses/by-nd/4.0/). -Based on a work at diff --git a/v1-0-STANDARD/doc/01Introduction.md b/v1-0-STANDARD/doc/01Introduction.md index 27509e1..466c854 100644 --- a/v1-0-STANDARD/doc/01Introduction.md +++ b/v1-0-STANDARD/doc/01Introduction.md @@ -1,26 +1,95 @@ -Introduction -========================================================================================================================================================= +# Scope -FIX Simple Binary Encoding (SBE) targets high performance trading -systems. It is optimized for low latency of encoding and decoding while -keeping bandwidth utilization reasonably small. For compatibility, it is -intended to represent all FIX semantics. +This document provides the normative specification of Simple Binary Encoding (SBE), which is one of the possible syntaxes for FIX messages, but not limited to FIX messages. The scope comprises the encoding (wire format) and the message schema for SBE. + +# Normative references + +The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies. + +--- IETF RFC 2119 -- *Key words for use in RFCs to Indicate Requirement Levels* March 1997 + +# Terms and definitions + +For the purposes of this document, the terms and definitions given in ISO/IEC 11404 and the following apply. + +ISO and IEC maintain terminological databases for use in standardization at the following addresses: + +—-- ISO Online browsing platform: available at [https://www.iso.org/obp](https://www.iso.org/obp) + +—-- IEC Electropedia: available at [http://www.electropedia.org/](http://www.electropedia.org/) + + +## datatype +field type with its associated encoding attributes + +Note 1 to entry: Includes backing primitive types and valid values or range. Some types +have additional attributes, e.g. epoch of a date. + +## encoding +message format for interchange + +Note 1 to entry: The term is commonly used +to mean the conversion of one data format to another, such as text to +binary. However, SBE strives to use native binary +datatypes in order to make conversion unnecessary, or at least trivial. + +Note 2 to entry: Encoding also refers to the act of formatting a message, as opposed to decoding. + +## field +unit of data contained by a message + +## message schema +metadata that specifies messages and their data types and identifiers + +Note 1 to entry: Message schemas may be disseminated out of band. + +Note 2 to entry: For SBE, message schemas are expressed as an XML +document that conforms to an XML schema that is published as part of this standard. + +## message template +metadata that specifies the fields that belong to one particular message type + +Note 1 to entry: A message template is contained by a +message schema. + +## session protocol +protocol concerned with the reliable delivery of messages over a transport. + +Note 1 to entry: FIX makes a distinction between +session protocol and the encoding of a message payload, as described by +this document. See the [specifications section](https://www.fixtrading.org/standards/) of the FIX Protocol web site +for supported session protocols and encodings. + +## XML schema +defines the elements and attributes that may appear in an XML document. + +Note 1 to entry: The SBE message schema is defined in W3C (XSD) schema +language since it is the most widely adopted format for XML schemas. + +## Specification terms +These key words in this document are to be interpreted as described in IETF RFC 2119. + +# Objectives + +## General + +SBE was designed to meet the needs of high performance trading systems, but it may also be applicable to other applications with similar performance characteristics. It is optimized for low latency of encoding and decoding while +keeping bandwidth utilization reasonably small. For compatibility, it is intended to represent all FIX semantics. This encoding specification describes the wire protocol for messages. Thus, it provides a standard for interoperability between communicating parties. Users are free to implement the standard in a way that best suits their needs. -The encoding standard is complimentary to other FIX standards for +The encoding standard is complementary to other FIX standards for session protocol and application level behavior. -Binary type system ----------------------------------------------------------------------------------------------------------------- +## Binary type system In order to support traditional FIX semantics, all the documented field types are supported. However, instead of printable character representations of tag-value encoding, the type system binds to native -binary data types, and defines derived types as needed. +binary datatypes, and defines derived types as needed. The binary type system has been enhanced in these ways: @@ -34,21 +103,19 @@ The binary type system has been enhanced in these ways: - Provides a consistent system of enumerations, Boolean switches and multiple-choice fields. -Design principles ---------------------------------------------------------------------------------------------------------------- +## Design principles The message design strives for direct data access without complex transformations or conditional logic. This is achieved by: -- Usage of native binary data types and simple types derived from +- Usage of native binary datatypes and simple types derived from native binaries, such as prices and timestamps. - Preference for fixed positions and fixed length fields, supporting direct access to data and avoiding the need for management of heaps of variable-length elements which must be sequentially processed. -Message schema ------------------------------------------------------------------------------------------------------------- +## Message schema This standard describes how fields are encoded and the general structure of messages. The content of a message type is specified by a message @@ -57,46 +124,12 @@ their location within a message. Additionally, the metadata describes valid value ranges and information that need not be sent on the wire, such as constant values. -Message schemas may be based on standard FIX message specifications, or +Message schemas may be based on standard FIX message specifications or may be customized as needed by agreement between counterparties. -Glossary ------------------------------------------------------------------------------------------------------- - -**Data type** - A field type with its associated encoding attributes, -including backing primitive types and valid values or range. Some types -have additional attributes, e.g. epoch of a date. - -**Encoding** - a message format for interchange. The term is commonly used -to mean the conversion of one data format to another, such as text to -binary. However, Simple Binary Encoding strives to use native binary -data types in order to make conversion unnecessary, or at least trivial. -Encoding also refers to the act of formatting a message, as opposed to -decoding. - -**Message schema** - metadata that specifies messages and their data -types and identifiers. Message schemas may be disseminated out of band. -For Simple Binary Encoding, message schemas are expressed as an XML -document that conforms to an XML schema that is published as part of -this standard. - -**Message template** - metadata that specifies the fields that belong to -one particular message type. A message template is contained by a -message schema. +## Documentation -**Session protocol** - a protocol concerned with the reliable delivery of -messages over a transport. FIX protocol makes a distinction between -session protocol and the encoding of a message payload, as described by -this document. See the specifications section of FIX protocol web site -for supported protocols. The original FIX session protocol is known as -FIXT. - -**XML schema** - defines the elements and attributes that may appear in an -XML document. The SBE message schema is defined in W3C (XSD) schema -language since it is the most widely adopted format for XML schemas. - -Documentation ------------------------------------------------------------------------------------------------------------ +### General This document explains: @@ -106,28 +139,7 @@ This document explains: and relationship to a message header that may be provided by a session protocol. -- The Simple Binary Encoding message schema. - -### Specification terms - -These key words in this document are to be interpreted as described in -[Internet Engineering Task Force RFC2119](http://www.apps.ietf.org/rfc/rfc2119.html). These terms indicate -an absolute requirement for implementations of the standard: "**must**", -or "**required**". - -This term indicates an absolute prohibition: "**must not**". - -These terms indicate that a feature is allowed by the standard but not -required: "**may**", "**optional**". An implementation that does not -provide an optional feature must be prepared to interoperate with one -that does. - -These terms give guidance, recommendation or best practices: -"**should**" or "**recommended**". A recommended choice among -alternatives is described as "**preferred**". - -These terms give guidance that a practice is not recommended: "**should not**" -or "**not recommended**". +- The SBE message schema. ### Document format @@ -137,52 +149,9 @@ and data examples. This is a sample encoding specification ```xml - + ``` This is sample data as it would be transmitted on the wire `10270000` - -References -------------------------------------------------------------------------------------------------------------------------------------------------------- - -### Related FIX Standards - -*Simple Open Framing Header*, FIX Protocol, Limited. Version 1.0 Draft Standard -specification has been published at - - -For FIX semantics, see the current FIX message specification, which is -currently [FIX 5.0 Service Pack 2](http://www.fixtradingcommunity.org/pg/structure/tech-specs/fix-version/50-service-pack-2) -with Extension Packs. - -### Dependencies on other standards - -SBE is dependent on several industry standards. Implementations must -conform to these standards to interoperate. Therefore, they are -normative for SBE. - -[IEEE 754-2008](http://ieeexplore.ieee.org/servlet/opac?punumber=4610933) A -Standard for Binary Floating-Point Arithmetic - -[ISO 639-1:2002](http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=22109) -Codes for the representation of names of languages - Part 1: Alpha-2 -code - -[ISO 3166-1:2013](http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=63545) -Codes for the representation of names of countries and their -subdivisions - Part 1: Country codes - -[ISO 4217:2015](https://www.iso.org/standard/64758.html) -Codes for the representation of currencies and funds - -[ISO 8601:2004](http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=40874) -Data elements and interchange formats - Information interchange - -Representation of dates and times - -[ISO 10383:2012](http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=61067) -Securities and related financial instruments - Codes for exchanges and -market identification (MIC) - -XML 1.1 schema standards are located here [W3C XML Schema](http://www.w3.org/XML/Schema.html#dev) diff --git a/v1-0-STANDARD/doc/02FieldEncoding.md b/v1-0-STANDARD/doc/02FieldEncoding.md index 4ebe190..4226ee7 100644 --- a/v1-0-STANDARD/doc/02FieldEncoding.md +++ b/v1-0-STANDARD/doc/02FieldEncoding.md @@ -1,47 +1,55 @@ -Field Encoding -=========================================================================================================================================================== +# Field Encoding -Field aspects ------------------------------------------------------------------------------------------------------------ +## Field aspects -A field is a unit of data contained by a FIX message. Every field has -the following aspects: semantic data type, encoding, and metadata. They -will be specified in more detail in the sections on data type encoding +### General + +Every field has +the following aspects: semantic datatype, encoding, and metadata. They +will be specified in more detail in the sections on datatype encoding and message schema but are introduced here as an overview. -### Semantic data type +### Semantic datatype + +#### FIX datatype -The FIX semantic data type of a field tells a data domain in a broad +The FIX semantic datatype of a field tells a data domain in a broad sense, for example, whether it is numeric or character data, or whether it represents a time or price. Simple Binary Encoding represents all of -the semantic data types that FIX protocol has defined across all -encodings. In message specifications, FIX data type is declared with -attribute semanticType. See the section 2.2 below for a listing of those -FIX types. +the semantic datatypes that FIX protocol has defined across all +encodings. In message specifications, FIX datatype is declared with +attribute semanticType. See the section [*FIX datatype summary*](#fix-data-type-summary) for details. + +#### Generic datatype + +A datatype is defined as a combination of a value space and a lexical space. Value +space is the range of its possible values while lexical space is how those values are represented in a message encoding, in this case SBE. +Value space of datatypes is defined using the vocabulary in ISO/IEC 11404:2007 *Information technology – General-Purpose Datatypes (GPD)*. +That standard defines types independently of platform and programming language. ### Encoding -Encoding tells how a field of a specific data type is encoded on the -wire. An encoding maps a FIX data type to either a simple, primitive -data type, such as a 32 bit signed integer, or to a composite type. A +Encoding tells how a field of a specific datatype is encoded on the +wire. An encoding maps a FIX datatype to either a simple, primitive +datatype, such as a 32-bit signed integer, or to a composite type. A composite type is composed of two or more simple primitive types. For -example, the FIX data type Price is encoded as a decimal, a composite +example, the FIX datatype Price is encoded as a decimal, a composite type containing a mantissa and an exponent. Note that many fields may -share a data type and an encoding. The sections that follow explain the -valid encodings for each data type. +share a datatype and an encoding. The sections that follow explain the +valid encodings for each datatype. ### Metadata Field metadata, part of a message schema, describes a field to application developers. Elements of field metadata are: -- Field ID, also known as FIX tag, is a unique identifier of a field +- Field ID, also known as FIX tag number, is a unique identifier of a field for semantic purposes. For example, tag 55 identifies the Symbol field of an instrument. - Field name, as it is known in FIX specifications -- The FIX semantic data type and encoding type that it maps to +- The FIX semantic datatype and encoding type that it maps to - Valid values or data range accepted @@ -53,14 +61,14 @@ encode a message in order to decode it. In other words, Simple Binary Encoding messages are not self-describing. Rather, message schemas are typically exchanged out-of-band between counterparties. -See section 4 below for a detailed message schema specification. +See section [*Message Schema*](#message-schema-1) for details. ### Field presence By default, fields are assumed to be required in a message. However, fields may be specified as optional. To indicate that a value is not set, a special null indicator value is sent on the wire. The null value -varies according to data type and encoding. Global defaults for null +varies according to datatype and encoding. Global defaults for null value may be overridden in a message schema by explicitly specifying the value that indicates nullness. @@ -75,72 +83,70 @@ value of an optional field does not necessarily imply that a default value should be applied. Rather, default handling is left to application layer specifications. -FIX data type summary ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +## FIX datatype summary FIX semantic types are mapped to binary field encodings as follows. See sections below for more detail about each type. Schema attributes may restrict the range of valid values for a field. -See Common field schema attributes below. - -| FIX semantic type | Binary type | Section | Description | -|----------------------------------|-------------------------------------------------------------------------------------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| int | Integer encoding | 2.4 | An integer number | -| Length | Integer encoding | 2.4 | Field length in octets. Value must be non-negative. | -| TagNum | Integer encoding | 2.4 | A field's tag number. Value must be positive. | -| SeqNum | Integer encoding | 2.4 | A field representing a message sequence number. Value must be positive | -| NumInGroup | Group dimension encoding | 3.4.8 | A counter representing the number of entries in a repeating group. Value must be positive. | -| DayOfMonth | Integer encoding | 2.4 | A field representing a day during a particular month (values 1 to 31). | -| Qty | Decimal encoding | 2.5 | A number representing quantity of a security, such as shares. The encoding may constrain values to integers, if desired. | -| float | Float encoding | 2.5 | A real number with binary representation of specified precision | -| Price | Decimal encoding | 2.5 | A decimal number representing a price | -| PriceOffset | Decimal encoding | 2.5 | A decimal number representing a price offset, which can be mathematically added to a Price. | -| Amt | Decimal encoding | 2.5 | A field typically representing a Price times a Qty. | -| Percentage | Decimal encoding | 2.5 | A field representing a percentage (e.g. 0.05 represents 5% and 0.9525 represents 95.25%). | -| char | Character | 2.7.1 | Single US-ASCII character value. Can include any alphanumeric character or punctuation. All char fields are case sensitive (i.e. m != M). | -| String | Fixed-length character array | 2.7.2 | A fixed-length character array of ASCII encoding | -| String | Variable-length data encoding | 2.7.3 | Alpha-numeric free format strings can include any character or punctuation. All String fields are case sensitive (i.e. morstatt != Morstatt). ASCII encoding. | -| String—EncodedText | String encoding | 2.7.3 | Non-ASCII string. The character encoding may be specified by a schema attribute. | -| XMLData | String encoding | 2.7.3 | Variable-length XML. Must be paired with a Length field. | -| data | Fixed-length data | 2.8.1 | Fixed-length non-character data | -| data | Variable-length data encoding | 2.8.2 | Variable-length data. Must be paired with a Length field. | -| Country | Fixed-length character array; size = 2 or a subset of values may use Enumeration encoding | 2.7.2 | ISO 3166-1:2013 Country code | -| Currency | Fixed-length character array; size = 3 or a subset of values may use Enumeration encoding | 2.7.2 | ISO 4217:2015 Currency code (3 character) | -| Exchange | Fixed-length character array; size = 4 or a subset of values may use Enumeration encoding | 2.7.2 | ISO 10383:2012 Market Identifier Code (MIC) | -| Language | Fixed-length character array; size = 2 or a subset of values may use Enumeration encoding | 2.7.2 | National language - uses ISO 639-1:2002 standard | -| Implicit enumeration—char or int | Enumeration encoding | 2.12 | A single choice of alternative values | -| Boolean | Boolean encoding | 2.12.6 | Values true or false | -| MultipleCharValue | Multi-value choice encoding | 2.13 | Multiple choice of a set of values | -| MultipleStringValue | Multi-value choice encoding**.** String choices must be mapped to int values. | 2.13 | Multiple choice of a set of values | -| MonthYear | MonthYear encoding | 2.8 | A flexible date format that must include month and year at least, but may also include day or week. | -| UTCTimestamp | Date and time encoding | 2.9 | Time/date combination represented in UTC (Universal Time Coordinated, also known as "GMT") | -| UTCTimeOnly | Date and time encoding | 2.9 | Time-only represented in UTC (Universal Time Coordinated, also known as "GMT") | -| UTCDateOnly | Date and time encoding | 2.9 | Date represented in UTC (Universal Time Coordinated, also known as "GMT") | -| LocalMktDate | Local date encoding | 2.9 | Local date(as oppose to UTC) | -| TZTimeOnly | TZTimeOnly | 2.11.3 | Time of day | -| TZTimestamp | TZTimestamp | 2.11.1 | Time/date combination representing local time with an offset to UTC to allow identification of local time and timezone offset of that time. The representation is based on ISO 8601:2004 | +See section [*Common field schema attributes*](#common-field-schema-attributes) for details. + +| FIX semantic type | Binary type | Value space (ISO/IEC 11404:2007) | Description | +|--------------|-------------------------|-------------|-------------------| +| int | [Integer encoding](#integer-encoding) | integer range | An integer number | +| Length | [Integer encoding](#integer-encoding) | size | Field length in octets. Value must be non-negative. | +| TagNum | [Integer encoding](#integer-encoding) | ordinal | A field's tag number. Value must be positive. | +| SeqNum | [Integer encoding](#integer-encoding) | ordinal | A field representing a message sequence number. Value must be positive | +| NumInGroup | [Group dimension encoding](#group-dimension-encoding) | size | A counter representing the number of entries in a repeating group. Value must be positive. | +| DayOfMonth | [Integer encoding](#integer-encoding) | integer range 1..31 | A field representing a day during a particular month (values 1 to 31). | +| Qty | [Decimal encoding](#decimal-encoding) | Scaled | A number representing quantity of a security, such as shares. The encoding may constrain values to integers, if desired. | +| float | [Float encoding](#float-encoding) | real | A real number with binary representation of specified precision | +| Price | [Decimal encoding](#decimal-encoding) | Scaled | A decimal number representing a price | +| PriceOffset | [Decimal encoding](#decimal-encoding) | Scaled | A decimal number representing a price offset, which can be mathematically added to a Price. | +| Amt | [Decimal encoding](#decimal-encoding) | Scaled | A field typically representing a Price times a Qty. | +| Percentage | [Decimal encoding](#decimal-encoding) | Scaled | A field representing a percentage (e.g. 0.05 represents 5% and 0.9525 represents 95.25%). | +| char | [Character](#character) | character | Single US-ASCII character value. Can include any alphanumeric character or punctuation. All char fields are case sensitive (i.e. m != M). | +| String | [Fixed-length character array](#fixed-length-character-array) | array element = character | A fixed-length character array of ASCII encoding | +| String | [Variable-length data encoding](#variable-length-string-encoding) | characterstring | Alpha-numeric free format strings can include any character or punctuation. All String fields are case sensitive (i.e. morstatt != Morstatt). ASCII encoding. | +| String—EncodedText | [String encoding](#variable-length-string-encoding) | characterstring | Non-ASCII string. The character encoding may be specified by a schema attribute. | +| XMLData | [String encoding](#variable-length-string-encoding) | characterstring |Variable-length XML. Must be paired with a Length field. | +| data | [Fixed-length data](#fixed-length-data) | array element=octet | Fixed-length non-character data | +| data | [Variable-length data encoding](#variable-length-data-encoding) | octetstring | Variable-length data. Must be paired with a Length field. | +| Country | [Fixed-length character array](#fixed-length-character-array); size = 2 or a subset of values may use [Enumeration encoding](#enumeration-encoding) | array (1..2) of character | ISO 3166-1:2013 Country code | +| Currency | [Fixed-length character array](#fixed-length-character-array); size = 3 or a subset of values may use [Enumeration encoding](#enumeration-encoding) | array (1..3) of character | ISO 4217:2015 Currency code (3 character) | +| Exchange | [Fixed-length character array](#fixed-length-character-array); size = 4 or a subset of values may use [Enumeration encoding](#enumeration-encoding) | array (1..4) of character | ISO 10383:2012 Market Identifier Code (MIC) | +| Language | [Fixed-length character array](#fixed-length-character-array); size = 2 or a subset of values may use [Enumeration encoding](#enumeration-encoding) | array (1..2) of character | National language - uses ISO 639-1:2002 standard | +| Implicit enumeration—char or int | [Enumeration encoding](#enumeration-encoding) | state | A single choice of alternative values | +| Boolean | [Boolean encoding](#boolean-encoding) | boolean | Values true or false | +| MultipleCharValue | [Multi-value choice encoding](#multi-value-choice-encoding) | set element = character | Multiple choice of a set of values | +| MultipleStringValue| [Multi-value choice encoding](#multi-value-choice-encoding). String choices must be mapped to int values. | set element = characterstring | Multiple choice of a set of values | +| MonthYear | [MonthYear encoding](#monthyear-encoding) | record | A flexible date format that must include month and year at least but may also include day or week. | +| UTCTimestamp | [Date and time encoding](#date-and-time-encoding) | time | Time/date combination represented in UTC (Universal Time Coordinated, also known as "GMT") | +| UTCTimeOnly | [Date and time encoding](#date-and-time-encoding) | time | Time-only represented in UTC (Universal Time Coordinated, also known as "GMT") | +| UTCDateOnly | [Date and time encoding](#date-and-time-encoding) | time | Date represented in UTC (Universal Time Coordinated, also known as "GMT") | +| LocalMktDate | [Local date encoding](#local-date-encoding) | time | Local date (as opposed to UTC) | +| TZTimeOnly | [TZTimeOnly encoding](#tztimeonly-encoding) | time | Time of day | +| TZTimestamp | [TZTimestamp encoding](#tztimestamp-encoding) | time | Time/date combination representing local time with an offset to UTC to allow identification of local time and timezone offset of that time. The representation is based on ISO 8601:2004 | The FIX semantic types listed above are spelled and capitalized exactly as they are in the FIX repository from which official FIX documents and references are derived. -Common field schema attributes ------------------------------- +## Common field schema attributes -Schema attributes alter the range of valid values for a field. -Attributes are optional unless specified otherwise. +### General +Schema attributes alter the range of valid values for a field. Attributes are optional unless specified otherwise. -| Schema attribute | Description | -|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| presence=required | The field must always be set. This is the default presence. Mutually exclusive with nullValue. | -| presence=constant | The field has a constant value that need not be transmitted on the wire. Mutually exclusive with value attributes. | -| presence=optional | The field need not be populated. A special null value indicates that a field is not set. The presence attribute may be specified on either on a field or its encoding. | +| Schema attribute | Description | +|-------------------|-------------------------------------------------------------------| +| presence=required | The field must always be set. This is the default presence. Mutually exclusive with nullValue. | +| presence=constant | The field has a constant value that need not be transmitted on the wire. Mutually exclusive with value attributes. | +| presence=optional | The field need not be populated. A special null value indicates that a field is not set. The presence attribute may be specified on either on a field or its encoding. | | nullValue | A special value that indicates that an optional value is not set. See encodings below for default nullValue for each type. Mutually exclusive with presence=required and constant. | -| minValue | The lowest valid value of a range. Applies to scalar data types, but not to String or data types. | -| maxValue | The highest valid value of a range (inclusive unless specified otherwise). Applies to scalar data types, but not to String or data types. | -| semanticType | Tells the FIX semantic type of a field or encoding. It may be specified on either a field or its encoding. | +| minValue | The lowest valid value of a range. Applies to scalar datatypes, but not to String or datatypes. | +| maxValue | The highest valid value of a range (inclusive unless specified otherwise). Applies to scalar datatypes, but not to String or datatypes. | +| semanticType | Specifies the FIX semantic type of a field or encoding. It may be specified on either a field or its encoding. | ### Inherited attributes @@ -151,25 +157,26 @@ fields that use that encoding. ### Non-FIX types Encodings may be added to SBE messages that do not correspond to listed -FIX data types. In that case, the encoding and fields that use the +FIX datatypes. In that case, the encoding and fields that use the encoding will not have a semanticType attribute. -Integer encoding -------------------------------------------------------------------------------------------------------------------------------------------------------------- +## Integer encoding + +### General Integer encodings should be used for cardinal or ordinal number fields. Signed integers are encoded in a two's complement binary format. ### Primitive type encodings -Numeric data types may be specified by range and signed or unsigned +Numeric datatypes may be specified by range and signed or unsigned attribute. Integer types are intended to convey common platform -primitive data types as they reside in memory. An integer type should be +primitive datatypes as they reside in memory. An integer type should be selected to hold the maximum range of values that a field is expected to hold. | Primitive type | Description | Length (octets) | -|----------------|---------------------------------------|----------------:| +|----------------|---------------------------------------|:---------------:| | int8 | Signed byte | 1 | | uint8 | Unsigned byte / single-byte character | 1 | | int16 | 16-bit signed integer | 2 | @@ -181,7 +188,7 @@ hold. ### Range attributes for integer fields -The default data ranges and null indicator are listed below for each +The default data range and null indicator are listed below for each integer encoding. A message schema may optionally specify a more restricted range of valid @@ -194,11 +201,11 @@ overridden by a message schema. Required and optional fields of the same primitive type have the same data range. The null value must not be set for a required field. - Schema attribute | int8 | uint8 | int16 | uint16 | int32 | uint32 | int64 | uint64 | -|------------------|-----:|------:|-------:|-------:|--------------------:|-------------------:|--------------------:|-------------------:| -| minValue | –127 | 0 | –32767 | 0 | –231 + 1 | 0 | –263 + 1 | 0 | -| maxValue | 127 | 254 | 32767 | 65534 | 231 – 1 | 232 – 2 | 263 – 1 | 264 – 2 | -| nullValue | –128 | 255 | –32768 | 65535 | –231 | 232 – 1 | –263 | 264 – 1 | + Schema attribute | int8 | uint8 | int16 | uint16 | int32 | uint32 | int64 | uint64 | +|-----------|-----:|------:|-------:|-------:|--------:|-------:|--------:|-------:| +| minValue | –127 | 0 | –32767 | 0 | –2^31^ + 1 | 0 | –2^63^ + 1 | 0 | +| maxValue | 127 | 254 | 32767 | 65534 | 2^31^ – 1 | 2^32^ – 2 | 2^63^ – 1 | 2^64^ – 2 | +| nullValue | –128 | 255 | –32768 | 65535 | –2^31^ | 2^32^ – 1 | –2^63^ | 2^64^ – 1 | ### Byte order @@ -207,7 +214,7 @@ components, is specified globally in a message schema. Little-Endian order is the default encoding, meaning that the least significant byte is serialized first on the wire. -See section 4.3.1 for specification of message schema attributes, +See section [*Message schema attributes*](#messageschema-attributes) for the specification, including byteOrder. Message schema designers should specify the byte order most appropriate to their system architecture and that of their counterparties. @@ -236,8 +243,7 @@ hexadecimal digits in Little-Endian byte order. Example integer field specification ```xml - + ``` Value on the wire - uint32 value decimal 10,000, hexadecimal 2710. @@ -247,10 +253,8 @@ Value on the wire - uint32 value decimal 10,000, hexadecimal 2710. Optional field with a valid range 0-6 ```xml - - + + ``` Wire format of uint8 value decimal 3. @@ -260,8 +264,7 @@ Wire format of uint8 value decimal 3. Sequence number field with integer encoding ```xml - + ``` Wire format of uint64 value decimal 100,000,000,000, hexadecimal @@ -273,12 +276,13 @@ Wire format of uint16 value decimal 10000, hexadecimal 2710. `1027` -Wire format of uint32 null value 232 - 1 +Wire format of uint32 null value 2^32^ - 1 `ffffffff` -Decimal encoding ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +## Decimal encoding + +### General Decimal encodings should be used for prices and related monetary data types like PriceOffset and Amt. @@ -289,6 +293,8 @@ is appropriate to the application or market. ### Composite encodings +#### General + Prices are encoded as a scaled decimal, consisting of a signed integer mantissa and signed exponent. For example, a mantissa of 123456 and exponent of -4 represents the decimal number 12.3456. @@ -310,16 +316,16 @@ fixed-point decimal specifies a fixed exponent in a message schema. A constant negative exponent specifies a number of assumed decimal places to the right of the decimal point. -Implementations should support both 32 bit and 64 bit mantissa. The +Implementations should support both 32-bit and 64-bit mantissa. The usage depends on the data range that must be represented for a -particular application. It is expected that an 8 bit exponent should be +particular application. It is expected that an 8-bit exponent should be sufficient for all FIX uses. | Encoding type | Description | Backing primitives | Length (octets) | -|---------------|------------------------|--------------------|----------------:| -| decimal | Floating-point decimal | Composite: int64 mantissa, int8 exponent | 9 | -| decimal64 | Fixed-point decimal | int64 mantissa, constant exponent | 8 | -| decimal32 | Fixed-point decimal | int32 mantissa, constant exponent | 4 | +|---------------|------------------------|--------------------|:---------------:| +| decimal | Floating-point decimal | Composite: int64 mantissa, int8 exponent | 9 | +| decimal64 | Fixed-point decimal | int64 mantissa, constant exponent | 8 | +| decimal32 | Fixed-point decimal | int32 mantissa, constant exponent | 4 | Optionally, implementations may support any other signed integer types for mantissa and exponent. @@ -333,14 +339,13 @@ A message schema may optionally specify a more restricted range of valid values for a field. For optional fields, a special mantissa value is used to indicate that a field value is null. -| Schema attribute | decimal | decimal64 | decimal32 | -|------------------|------------------------------------------:|------------------------------------------:|------------------------------------------:| -| exponent range | –128 to 127 | –128 to 127 | –128 to 127 | -| mantissa range | –263 + 1 to 263 – 1 | –263 + 1 to 263 – 1 | –231 + 1 to 231 – 1 | -| minValue | (–263 + 1) \* 10127 | (–263 + 1) \* 10127 | (–231 + 1) \* 10127 | -| maxValue | (263 – 1) \* 10127 | (263 – 1) \* 10127 | (231 – 1) \* 10127 | -| nullValue | mantissa=–263, exponent=–128 | mantissa =–263 | mantissa =–231 | - +| Schema attribute | decimal | decimal64 | decimal32 | +|------------------|------------------------:|-------------------:|-------------------:| +| exponent range | –128 to 127 | –128 to 127 | –128 to 127 | +| mantissa range | –2^63^ + 1 to 2^63^ – 1 | –2^63^ + 1 to 2^63^ – 1 | –2^31^ + 1 to 2^31^ – 1 | +| minValue | (–2^63^ + 1) \* 10^127^ | (–2^63^ + 1) \* 10^127^ | (–2^31^ + 1) \* 10^127^ | +| maxValue | (2^63^ – 1) \* 10^127^ | (2^63^ – 1) \* 10^127^ | (2^31^ – 1) \* 10^127^ | +| nullValue | mantissa=–2^63^, exponent=–128 | mantissa =–2^63^ | mantissa =–2^31^ | ### Encoding specifications for decimal types @@ -359,14 +364,12 @@ Decimal encoding specifications that an implementation must support - -2 + -2 - -2 + -2 ``` @@ -375,29 +378,27 @@ Decimal encoding specifications that an implementation must support When both mantissa and exponent are sent on the wire for a decimal, the elements are packed by default. However, byte alignment may be controlled by specifying offset of the exponent within the composite -encoding. See section 4.4.4.3 below. +encoding. See section [*Element offset within a composite type*](#element-offset-within-a-composite-type) for details. ### Examples of decimal fields Examples show encoded bytes on the wire as hexadecimal digits, little-endian. -FIX Qty data type is a float type, but a decimal may be constrained to +FIX Qty datatype is a float type, but a decimal may be constrained to integer values by setting exponent to zero. ```xml - 0 + 0 ``` -Field inherits semanticType from encoding +Field inherits attribute semanticType from encoding ```xml - + ``` Wire format of decimal 123.45 with 2 significant decimal places. @@ -414,24 +415,25 @@ Schema attribute exponent = -2 `39300000` -Float encoding ------------------------------------------------------------------------------------------------------------- +## Float encoding + +### General Binary floating point encodings are compatible with IEEE Standard for -Floating-Point Arithmetic (IEEE 754-2008). They should be used for +Floating-Point Arithmetic (IEEE 754-2019). They should be used for floating point numeric fields that do not represent prices or monetary amounts. Examples include interest rates, volatility and dimensionless quantities such as ratios. On the other hand, decimal prices should be -encoded as decimals; see section 2.5 above. +encoded as decimals; see section [*Decimal encoding*](#decimal-encoding) for details. ### Primitive types Both single and double precision encodings are supported as primitive -data types. See the IEEE 754-2008 standard for ranges and details of the +datatypes. See the IEEE 754-2019 standard for ranges and details of the encodings. -| Primitive type | Description | IEEE 754-2008 format | Length (octets) | -|----------------|---------------------------------|----------------------|----------------:| +| Primitive type | Description | IEEE 754-2019 format | Length (octets) | +|----------------|---------------------------------|----------------------|:---------------:| | float | Single precision floating point | binary32 | 4 | | double | Double precision floating point | binary64 | 8 | @@ -443,9 +445,7 @@ encoding. Technically, it indicated by the so-called quiet NaN. ### Byte order -Like integer encodings, floating point encodings follow the byte order -specified by message schema. See section 4.3.1 for specification of -message schema attributes, including byteOrder. +Like integer encodings, floating point encodings follow the byte order specified by message schema. See section [*Message schema attributes*](#messageschema-attributes) for the specification, including byteOrder. ### Float encoding specifications @@ -467,8 +467,7 @@ A single precision ratio ```xml - + ``` Wire format of float 255.678 @@ -479,8 +478,9 @@ Wire format of double 255.678 `04560e2db2f56f40` -String encodings ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +## String encodings + +### General Character data may either be of fixed size or variable size. In Simple Binary Encoding, fixed-length fields are recommended in order to support @@ -490,13 +490,14 @@ also be used for non-ASCII encoded strings. ### Character +#### General + Character fields hold a single character. They are most commonly used -for field with character code enumerations. See section 2.12 below for -discussion of enum fields. +for field with character code enumerations. See section [*Enumeration encoding*](#enumeration-encoding) for details. -| FIX data type | Description | Backing primitive | Length (octet) | -|---------------|-----------------------------|-------------------|---------------:| -| char | A single US-ASCII character | char | 1 | +| FIX datatype | Description | Backing primitive | Length (octet) | +|--------------|-----------------------------|-------------------|:--------------:| +| char | A single US-ASCII character | char | 1 | #### Range attributes for char fields @@ -524,17 +525,19 @@ Wire format of char encoding of "A" (ASCII value 65, hexadecimal 41) ### Fixed-length character array +#### General + Character arrays are allocated a fixed space in a message, supporting direct access to fields. A fixed size character array is distinguished from a variable length string by the presence of a length schema attribute or a constant attribute. -| FIX data type | Description | Backing primitives | Length (octets) | Required schema attribute | -|---------------|-----------------|-----------------------------------------------------------------------------------------------------------------------------|-------------------------------|--------------------------------------------------------------------| -| String | character array | Array of char of specified length, delimited by NUL character if a string is shorter than the length specified for a field. | Specified by length attribute | length (except may be inferred from a constant value, if present). | +| FIX datatype | Description | Backing primitives | Length (octets) | Required schema attribute| +|-----------------|-----------------|---------------------------------|--------------------------|-------------------------------| +| String | character array | Array of char of specified length, padded by NUL character if a string is shorter than the length specified for a field. | Specified by length attribute | length (except may be inferred from a constant value, if present). | A length attribute set to zero indicates variable length. See section -2.7.3 below for variable-length data encoding. +[*Variable-length string encoding*](#variable-length-string-encoding) for details. #### Encoding specifications for fixed-length character array @@ -553,8 +556,7 @@ encoding. A typical string encoding specification ```xml - + ``` @@ -568,9 +570,7 @@ M S F T A character array constant specification ```xml -XEUR +XEUR ``` @@ -589,10 +589,10 @@ is made at an encoding layer between an empty string and a null string. Semantics of an empty variable-length string should be specified at an application layer. -| FIX data type | Description | Backing primitives | Length (octets) | -|---------------|---------------------------------------|----------------------------------------------------------------------------------------------------------------------------|-----------------| -| Length | The length of variable data in octets | primitiveType="uint8" or "uint16" May not hold null value. | 1 or 2 | -| data | Raw data | Array of octet of size specified in associated Length field. The data field itself should be specified as variable length. primitiveType="uint8" length="0" indicates variable length | variable | +| FIX datatype | Description | Backing primitives | Length (octets) | +|---------------|------------------|------------------------------------|-----------------| +| Length | The length of variable data in octets | primitiveType="uint8" or "uint16" May not hold null value. | 1 or 2 | +| data | Raw data | Array of octet of size specified in associated Length field. The data field itself should be specified as variable length. primitiveType="uint8" length="0" indicates variable length | variable | Optionally, implementations may support any other unsigned integer types for length. @@ -629,8 +629,7 @@ Encoding specification for variable length data up to 65535 octets ```xml - + @@ -652,8 +651,9 @@ M S F T `04004d534654` -Data encodings --------------- +## Data encodings + +### General Raw data is opaque to SBE. In other words, it is not constrained by any value range or structure known to the messaging layer other than length. @@ -661,20 +661,22 @@ Data fields simply convey arrays of octets. Data may either be of fixed-length or variable-length. In Simple Binary Encoding, fixed-length data encoding may be used for data of -predetermined length, even though it does not represent a FIX data type. +predetermined length, even though it does not represent a FIX datatype. Variable-length encoding should be reserved for raw data when its length is not known until run-time. ### Fixed-length data +#### General + Data arrays are allocated as a fixed space in a message, supporting direct access to fields. A fixed size array is distinguished from a variable length data by the presence of a length schema attribute rather than sending length on the wire. -| FIX data type | Description | Backing primitives | Length (octets) | Required schema attribute | -|---------------|-------------|-------------------------------------|-------------------------------|---------------------------| -| data | octet array | Array of uint8 of specified length. | Specified by length attribute | length | +| FIX datatype | Description | Backing primitives | Length (octets) | Required schema attribute | +|--------------|----------------|-------------------------------------|-------------------------|---------------------| +| data | octet array | Array of uint8 of specified length. | Specified by length attribute | length | #### Encoding specifications for fixed-length data @@ -707,10 +709,10 @@ case, no space is reserved for the data. Semantics of an empty variable-length data element should be specified at an application layer. -| FIX data type | Description | Backing primitives | Length (octets) | -|---------------|---------------------------------------|----------------------------------------------------------------------------------------------------------------------------|-----------------| -| Length | The length of variable data in octets | primitiveType="uint8" or "uint16" May not hold null value. | 1 or 2 | -| data | Raw data | Array of octet of size specified in associated Length field. The data field itself should be specified as variable length. primitiveType="uint8" | variable +| FIX datatype | Description | Backing primitives | Length (octets) | +|---------------|-------------------|--------------------------|------------| +| Length | The length of variable data in octets | primitiveType="uint8" or "uint16" May not hold null value. | 1 or 2 | +| data | Raw data | Array of octet of size specified in associated Length field. The data field itself should be specified as variable length. primitiveType="uint8" | variable | Optionally, implementations may support any other unsigned integer types for length. @@ -761,8 +763,9 @@ M S F T `04004d534654` -MonthYear encoding ---------------------------------------------------------------------------------------------------------------------------------------------------------------- +## MonthYear encoding + +### General MonthYear encoding contains four subfields representing respectively year, month, and optionally day or week. A field of this type is not @@ -776,10 +779,10 @@ special value indicating null if not present. If Year is set to the null value, then the entire field is considered null. | Subfield | Primitive type | Length (octets) | Null value | -|----------------------------------|----------------|----------------:|-----------:| +|----------------------------------|----------------|:---------------:|-----------:| | Year | uint16 | 2 | 65535 | | Month (1-12) | uint8 | 1 | — | -| Day of the month(1-31) optional | uint8 | 1 | 255 | +| Day of the month (1-31) optional | uint8 | 1 | 255 | | Week of the month (1-5) optional | uint8 | 1 | 255 | @@ -787,24 +790,21 @@ value, then the entire field is considered null. The four subfields of MonthYear are packed at an octet level by default. However, byte alignment may be controlled by specifying offset of the -elements within the composite encoding. See section 4.4.4.3 below. +elements within the composite encoding. See section [*Element offset within a composite type*](#element-offset-within-a-composite-type) for details. ### Encoding specifications for MonthYear -MonthYear data type is based on a composite encoding that carries its +MonthYear datatype is based on a composite encoding that carries its required and optional elements. The standard encoding specification for MonthYear ```xml - + - - + + ``` @@ -816,8 +816,9 @@ Wire format of MonthYear 2014 June week 3 as hexadecimal `de0706ff03` -Date and time encoding ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +## Date and time encoding + +### General Dates and times represent Coordinated Universal Time (UTC). This is the preferred date/time format, except where regulations require local time @@ -825,7 +826,7 @@ with time zone to be reported (see time zone encoding below). ### Epoch -Each time type has an epoch, or start of a time period to count values. +Each time type has an epoch or start of a time period to count values. For timestamp and date, the standard epoch is the UNIX epoch, midnight January 1, 1970 UTC. @@ -841,19 +842,19 @@ the other hand, if all timestamps have the same precision, then time unit may be set to a constant in the message schema. Then it need not be sent on the wire. -| FIX data type | Description | Backing primitives | Length (octets) | Schema attributes | -|---------------|--------------------------------------------------------------------------|--------------------|----------------:|------------------------| -| UTCTimestamp | UTC date/time Default: nanoseconds since Unix epoch Range Jan. 1, 1970 - July 21, 2554 | uint64 time | 8 | epoch=”unix” (default) | | | | -| | timeUnit = second or millisecond or microsecond or nanosecond May be constant | uint8 unit | 1 | | -| UTCTimeOnly | UTC time of day only Default: nanoseconds since midnight today | uint64 time | 8 | | -| | timeUnit = second or millisecond or microsecond or nanosecond May be constant | uint8 unit | 1 | | -| UTCDateOnly | UTC calendar date Default: days since Unix epoch. Range: Jan. 1, 1970 - June 7, 2149 | uint16 | 2 | epoch=”unix” (default) | +| FIX datatype | Description | Backing primitives | Length (octets) | Schema attributes | +|------------------|---------------------------------------|--------------------|:-----------:|---------------| +| UTCTimestamp | UTC date/time Default: nanoseconds since Unix epoch. Range January 1, 1970 - July 21, 2554 | uint64 time | 8 | epoch="unix" (default) | +| | timeUnit = second or millisecond or microsecond or nanosecond. May be constant | uint8 unit | 1 | | +| UTCTimeOnly | UTC time of day only Default: nanoseconds since midnight today | uint64 time | 8 | | +| | timeUnit = second or millisecond or microsecond or nanosecond. May be constant | uint8 unit | 1 | | +| UTCDateOnly | UTC calendar date Default: days since Unix epoch. Range: January 1, 1970 - June 7, 2149 | uint16 | 2 | epoch="unix" (default) | ### Encoding specifications for date and time -Time specifications use an enumeration of time units. See section 2.13 -below for a fuller explanation of enumerations. +Time specifications use an enumeration of time units. See section [*Enumeration encoding*](#enumeration-encoding) +for details. Enumeration of time units: @@ -916,15 +917,15 @@ schema attributes ```xml - - + + ``` Wire format of UTCTimestamp with constant time unit in little-Endian byte order -`4047baa145fb17` +`004047baa145fb17` **time** 10:24:39.123456000 (37,479 seconds and 123456000 nanoseconds since midnight UTC) with default schema attributes @@ -938,7 +939,7 @@ since midnight UTC) with default schema attributes Wire format of UTCTimeOnly -`10d74916220000` +`0010d74916220000` **date** Friday, October 4, 2024 (20,000 days since UNIX epoch) with default schema attributes @@ -951,15 +952,14 @@ Wire format of UTCDateOnly `204e` -Local date encoding ----------------------------------------------------------------------------------------------------------------------------------------------------------------- +## Local date encoding Local date is encoded the same as UTCDateOnly, but it represents local time at the market instead of UTC time. -| FIX data type | Description | Backing primitives | Length (octets) | Schema attributes | -|---------------|-------------------------------------------------------------------------------|--------------------|----------------:|------------------------------------| -| LocalMktDate | Local calendar date Default: days since Unix epoch. Range: Jan. 1, 1970 - June 7, 2149 local time | uint16 | 2 | epoch=”unix” (default) +| FIX datatype | Description | Backing primitives | Length (octets) | Schema attributes | +|------------------|-----------------------------|----------------|:----------:|------------------| +| LocalMktDate | Local calendar date Default: days since Unix epoch. Range: January 1, 1970 - June 7, 2149 local time | uint16 | 2 | epoch="unix" (default) | The standard encoding specification for LocalMktDate @@ -967,8 +967,9 @@ The standard encoding specification for LocalMktDate ``` -Local time encoding ------------------------------------------------------------------------------------------------------------------ +## Local time encoding + +### General Time with time zone encoding should only be used when required by market regulations. Otherwise, use UTC time encoding (see above). @@ -981,18 +982,18 @@ format ±hhmm. A binary UTCTimestamp followed by a number representing the time zone indicator as defined in ISO 8601:2004. -| FIX data type | Description | Backing primitives | Length (octets) | Schema attributes | -|---------------|--------------------------------------------------------------------------|--------------------|----------------:|------------------------------------| -| TZTimestamp | date/time with timezone Default: nanoseconds since Unix epoch Range Jan. 1, 1970 - July 21, 2554 | uint64 | 8 | epoch=”unix” (default) Represents Jan. 1, 1970 local time | -| | timeUnit = second or millisecond or microsecond or nanosecond May be constant | uint8 | 1 | | -| | Time zone hour offset | int8 | 1 | None | -| | Time zone minute offset | uint8 | 1 | None | +| FIX datatype | Description | Backing primitives | Length (octets) | Schema attributes | +|------------------|-----------------------------|----------------|:----------:|------------------| +| TZTimestamp | date/time with timezone Default: nanoseconds since Unix epoch. Range January 1, 1970 - July 21, 2554 | uint64 | 8 | epoch="unix" (default) Represents January 1, 1970 local time | +| | timeUnit = second or millisecond or microsecond or nanosecond. May be constant | uint8 | 1 | | +| | Time zone hour offset | int8 | 1 | None | +| | Time zone minute offset | uint8 | 1 | None | ### Composite encoding padding The subfields of TZTimestamp are packed at an octet level by default. However, byte alignment may be controlled by specifying offset of the -elements within the composite encoding. See section 4.4.4.3 below. +elements within the composite encoding. See section [*Element offset within a composite type*](#element-offset-within-a-composite-type) for details. Standard TZTimestamp encoding specification @@ -1007,9 +1008,9 @@ Standard TZTimestamp encoding specification ``` Wire format of TZTimestamp 8:30 17 September 2013 with Chicago time zone -offset (-6:00) +offset (-6:00) and nanosecond timeunit -`0050d489fea22413fa00` +`0050d489fea2241309fa00` ### TZTimeOnly encoding @@ -1020,10 +1021,10 @@ The time zone hour offset tells the number of hours different to UTC time. The time zone minute tells the number of minutes different to UTC. The sign telling ahead or behind UTC is on the hour subfield. -| FIX data type | Description | Backing primitives | Length (octets) | Schema attributes | -|---------------|------------------------------------------------------------|--------------------|----------------:|-------------------| +| FIX datatype | Description | Backing primitives | Length (octets) | Schema attributes | +|------------------|-----------------------------|----------------|:----------:|------------------| | TZTimeOnly | Time of day only with time zone Default: nanoseconds since midnight today, local time | uint64 | 8 | None | -| | timeUnit = second or millisecond or microsecond or nanosecond May be constant | uint8 | 1 | None | +| | timeUnit = second or millisecond or microsecond or nanosecond. May be constant | uint8 | 1 | None | | | Time zone hour offset | int8 | 1 | None | | | Time zone minute offset | uint8 | 1 | None | @@ -1031,7 +1032,7 @@ The sign telling ahead or behind UTC is on the hour subfield. The subfields of TZTimeOnly are packed at an octet level by default. However, byte alignment may be controlled by specifying offset of the -elements within the composite encoding. See section 4.4.4.3 below. +elements within the composite encoding. See section [*Element offset within a composite type*](#element-offset-within-a-composite-type) for details. Standard TZTimeOnly encoding specification @@ -1040,10 +1041,8 @@ Standard TZTimeOnly encoding specification - - + + ``` @@ -1051,11 +1050,11 @@ Wire format of TZTimeOnly 8:30 with Chicago time zone offset (-6:00) `006c5ebe76000000fa00` -Enumeration encoding ------------------------------------------------------------------------------------------------------------------------------------------------------------------ +## Enumeration encoding -An enumeration conveys a single choice of mutually exclusive valid -values. +### General + +An enumeration conveys a single choice of mutually exclusive valid values. ### Primitive type encodings @@ -1065,21 +1064,21 @@ types. They may additionally support other unsigned integer types to allow more choices. | Primitive type | Description | Length (octets) | Maximum number of choices | -|----------------|------------------------|----------------:|--------------------------:| -| char | character | 1 | 95 | -| uint8 | 8-bit unsigned integer | 1 | 255 | +|----------------|------------------------|:-----------:|:-------------:| +| char | character | 1 | 95 | +| uint8 | 8-bit unsigned integer | 1 | 255 | ### Value encoding -If a field is of FIX data type char, then its valid values are -restricted to US-ASCII printable characters. See section 2.7.1 above. +If a field is of FIX datatype char, then its valid values are +restricted to US-ASCII printable characters. See section [*Character*](#character) for details. -If the field is of FIX data type int, then a primitive integer data type +If the field is of FIX datatype int, then a primitive integer datatype should be selected that can contain the number of choices. For most -cases, an 8 bit integer will be sufficient, allowing 255 possible +cases, an 8-bit integer will be sufficient, allowing 255 possible values. -Enumerations of other data types, such as String valid values specified +Enumerations of other datatypes, such as String valid values specified in FIX, should be mapped to an integer wire format in SBE. ### Encoding specification of enumeration @@ -1088,13 +1087,13 @@ In a message schema, the choices are specified a `` members of an ``. An `` specification must contain at least one ``. -The name and value of a validValue element must be unique within an +The name and value of a `` element must be unique within an enumeration. An `` element must have an encodingType attribute to specify the type of its values. Two formats of encodingType are acceptable: -- In-line style: the value of encodingType is its primitive data type. +- In-line style: the value of encodingType is its primitive datatype. - Reference style: the value of encodingType is the name of a `` element that specifies the wire format. @@ -1153,9 +1152,7 @@ Example of a char field using a constant enum value D - + ``` ### Boolean encoding @@ -1199,8 +1196,9 @@ Wire format of null Boolean (or N/A) value as hexadecimal `ff` -Multi-value choice encoding --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +## Multi-value choice encoding + +### General A multi-value field conveys a choice of zero or more non-exclusive valid values. @@ -1212,17 +1210,14 @@ choices. The encoding is backed by an unsigned integer. The smallest unsigned primitive type should be selected that can contain the number of valid choices. -| Primitive type | Description | Length (octets) | Maximum number of choices | -|----------------|-------------------------|----------------:|--------------------------:| -| uint8 | 8-bit unsigned integer | 1 | 8 | -| uint16 | 16-bit unsigned integer | 2 | 16 | -| uint32 | 32-bit unsigned integer | 4 | 32 | -| uint64 | 64-bit unsigned integer | 8 | 64 | +| Primitive type | Description | Length (octets) | Maximum number of choices | +|----------------|-------------------------|:---------:|:---------------:| +| uint8 | 8-bit unsigned integer | 1 | 8 | +| uint16 | 16-bit unsigned integer | 2 | 16 | +| uint32 | 32-bit unsigned integer | 4 | 32 | +| uint64 | 64-bit unsigned integer | 8 | 64 | -Like other integer-backed encodings, multi-value encodings follow the -byte order specified by message schema when serializing to the wire. See -section 4.3.1 for specification of message schema attributes, including -byteOrder. +Like other integer-backed encodings, multi-value encodings follow the byte order specified by message schema when serializing to the wire. See section [*Message schema attributes*](#messageschema-attributes) for the specification, including byteOrder. ### Value encoding @@ -1239,21 +1234,21 @@ than to set all bits off when no choices are selected. ### Encoding specification of multi-value choice In a message schema, the choices are specified as `` members of -an `` element. Choices are assigned values as an ordinal of bits in +a `` element. Choices are assigned values as an ordinal of bits in the bit set. The first Choice "0" is assigned the least significant bit; choice "1" is the second bit, and so forth. The name and value (bit position) must be unique for element of a set. A `` element must have an encodingType attribute to specify the -wire format of its values. Two formats of encodingType are recognized : +wire format of its values. Two formats of encodingType are recognized: -- In-line style: the value of encodingType is its primitive data type. +- In-line style: the value of encodingType is its primitive datatype. - Reference style: the value of encodingType is the name of a `` element that specifies the wire format. -The length of a `` associated to an bitset must be 1. That is, +The length of a `` associated to a bitset must be 1. That is, bitsets should not be specified as arrays. ### Multi-value example @@ -1282,8 +1277,7 @@ Reference to type. This is equivalent to the example above. A field using the multi-choice encoding ```xml - + ``` Wire format of choices "Bankrupt" + "Pending delisting" (first and @@ -1291,8 +1285,7 @@ second bits set) `03` -Field value validation --------------------------------------------------------------------------------------------------------------------- +## Field value validation These validations apply to message field values. @@ -1300,13 +1293,13 @@ If a value violation is detected on a received message, the message should be rejected back to the counterparty in a way appropriate to the session protocol. -| Error condition | Error description | -|-------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------| -| Field value less than minValue | The encoded value falls below the specified valid range. | -| Field value greater than maxValue | The encoded value exceeds the specified valid range. | -| Null value set for required field | The null value of a data type is invalid for a required field. | +| Error condition | Error description | +|----------------------|-----------------------------------------------| +| Field value less than minValue | The encoded value falls below the specified valid range. | +| Field value greater than maxValue | The encoded value exceeds the specified valid range. | +| Null value set for required field | The null value of a datatype is invalid for a required field. | | String contains invalid characters | A String contains non-US-ASCII printable characters or other invalid sequence if a different characterEncoding is specified. | -| Required subfields not populated in MonthYear | Year and month must be populated with non-null values, and the month must be in the range 1-12. | -| UTCTimeOnly exceeds day range | The value must not exceed the number of time units in a day, e.g. greater than 86400 seconds. | +| Required subfields not populated in MonthYear | Year and month must be populated with non-null values, and the month must be in the range 1-12. | +| UTCTimeOnly exceeds day range | The value must not exceed the number of time units in a day, e.g. greater than 86400 seconds. | | TZTimestamp and TZTimeOnly has missing or invalid time zone | The time zone hour and minute offset subfields must correspond to an actual time zone recognized by international standards. | -| Value must match valid value of an enumeration field | A value is invalid if it does not match one of the explicitly listed valid values. | +| Value must match valid value of an enumeration field | A value is invalid if it does not match one of the explicitly listed valid values. | diff --git a/v1-0-STANDARD/doc/03MessageStructure.md b/v1-0-STANDARD/doc/03MessageStructure.md index 25cce12..36d1930 100644 --- a/v1-0-STANDARD/doc/03MessageStructure.md +++ b/v1-0-STANDARD/doc/03MessageStructure.md @@ -1,11 +1,11 @@ -Message Structure -=============================================================================================================== +# Message Structure -Message Framing ------------------------------------------------------------------------------------------------------------------------------------------------------------- +## Message Framing -SBE messages have no defined message delimiter. Version 2.0 of SBE makes it possible to walk the elements of a message to determine its limit, even when the message has been extended. Nevertheless, since internal framing depends on a correct starting point and not encountering malformed messages, it may be desirable to use an external framing protocol when used with transports that do not preserve message boundaries, such as when they are transmitted on a streaming -session protocol or when persisting messages in storage. +### General + +SBE messages have no defined message delimiter. SBE makes it possible to walk the elements of a message to determine its limit, even when the message has been extended. Nevertheless, since internal framing depends on a correct starting point and not encountering malformed messages, it may be desirable to use an external framing protocol when used with transports that do not preserve message boundaries, such as when they are transmitted on a streaming +session protocol or when persisting messages in storage. ### Simple Open Framing Header @@ -31,7 +31,7 @@ be encoded in big-endian byte order, also known as network byte order. Simple Open Framing Header as an SBE composite encoding (big-endian) ```xml - + @@ -48,14 +48,14 @@ defined as: The Simple Open Framing Header specification also lists values for other wire formats. -SBE Message Encoding Header ---------------------------- +## SBE Message Encoding Header + +### General The purpose of the message encoding header is to tell which message template was used to encode the message and to give information about the size of the message body to aid in decoding, even when a message -template has been extended in a later version. See section 5 below for -an explanation of the schema extension mechanism. +template has been extended in a later version. See section [*Schema Extension Mechanism*](#schema-extension-mechanism) for details. The fields of the SBE message header are: @@ -78,7 +78,7 @@ The fields of the SBE message header are: Block length is specified in a message schema, but it is also serialized on the wire. By default, block length is set to the sum of the sizes of body fields in the message. However, it may be increased to force -padding at the end of block. See section 3.3.3.3 below. +padding at the end of block. See section [*Padding at end of a message or group*](#padding-at-end-of-a-message-or-group) for details. ### Message header schema @@ -87,7 +87,7 @@ position as shown below. Each of these fields must be encoded as an unsigned integer type. The encoding must carry the name "messageHeader". The message header is encoded in the same byte order as the message -body, as specified in a message schema. See section 4.3.1. +body, as specified in a message schema. See section [*Message schema attributes*](#messageschema-attributes) for the specification. Recommended message header encoding @@ -97,7 +97,7 @@ Recommended message header encoding - + ``` @@ -105,12 +105,12 @@ Recommended message header encoding The recommended header encoding is 12 octets. | Element | Description | Primitive type | Length (octets) | Offset | -|-------------|-------------------|----------------|----------------:|-------:| +|------------------|-------------------|----------------|:---------------:|:------:| | blockLength | Root block length | uint16 | 2 | 0 | | templateId | Template ID | uint16 | 2 | 2 | | schemaId | Schema ID | uint16 | 2 | 4 | | version | Schema Version | uint16 | 2 | 6 | -| numGroups |Number of repeating groups | uint16 | 2 | 8 | +| numGroups | Number of repeating groups | uint16 | 2 | 8 | | numVarDataFields | Number of variable-length fields | uint16 | 2 | 10 | Optionally, implementations may support any other unsigned integer types @@ -120,9 +120,9 @@ for blockLength. The total space reserved for the root level of the message not counting any repeating groups or variable-length fields. (Repeating groups have -their own block length; see section 3.4 below. Length of a +their own block length; see section [*Repeating groups*](#repeating-groups) for details. Length of a variable-length Data field is given by its corresponding Length field; -see section 2.7.3 above.) Block length only represents message body +see section [*Variable-length string encoding*](#variable-length-string-encoding) for details.) Block length only represents message body fields; it does not include the length of the message header itself, which is a fixed size. @@ -130,22 +130,20 @@ The block size must be at least the sum of lengths of all fields at the root level of the message, and that is its default value. However, it may be set larger to reserve more space to effect alignment of blocks. This is specified by setting the blockLength attribute in a message -schema. +schema. ### Template ID -The identifier of a message type in a message schema. See section 4.5.2 -below for schema attributes of a message. +The identifier of a message type in a message schema. See section [*Message schema attributes*](#messageschema-attributes) for the specification. ### Schema ID -The identifier of a message schema. See section 4.3.1 below for schema -attributes. +The identifier of a message schema. See section [*Message schema attributes*](#messageschema-attributes) for the specification. ### Schema version The version number of the message schema that was used to encode a -message. See section 4.3.1 below for schema attributes. +message. See section [*Message schema attributes*](#messageschema-attributes) for the specification. ### Number of repeating groups @@ -156,8 +154,9 @@ A count of repeating groups at the root level of the message. The count does not A count of the variable-length fields at the root level of the message. The count does not include variable-length fields within repeating groups. -Message Body ----------------------------------------------------------------------------------------------------------- +## Message Body + +### General The message body conveys the business information of the message. @@ -197,16 +196,14 @@ sum of the sizes of prior fields, as they are defined by the message schema. ```xml - + - + ``` | Field | Size | Offset | -|----------|-----:|-------:| +|----------|:----:|:------:| | ClOrdID | 14 | 0 | | Side | 1 | 14 | | OrderQty | 4 | 15 | @@ -230,18 +227,14 @@ business data. They should be filled with binary zeros. Example of fields with specified offsets ```xml - - - - + + + + ``` | Field | Size | Padding preceding field | Offset | -|----------|------|------------------------:|-------:| +|----------|:----:|:-----------------------:|:------:| | ClOrdID | 14 | 0 | 0 | | Side | 1 | 0 | 14 | | OrderQty | 4 | 1 | 16 | @@ -265,11 +258,12 @@ Extra octets specified for padding should be filled with binary zeros. Example of blockLength specification for 24 octets ```xml - + ``` -Repeating Groups ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +## Repeating Groups + +### General A repeating group is a message structure that contains a variable number of entries. Each entry contains fields specified by a message schema. @@ -279,7 +273,7 @@ group. That is, the entries are homogeneous. Position of a given field within any entry is fixed, with the exception of variable-length fields. -A message may have no groups or an unlimited number of repeating groups +A message may have no groups, or an unlimited number of repeating groups specified in its schema. ### Schema specification of a group @@ -292,17 +286,15 @@ Example repeating group encoding specification ```xml - - + + ``` ### Group block length -The blockLength part of a group dimension represents total space reserved +The blockLength part of a group dimension represents total space reserved for each group entry, not counting any nested repeating groups or variable-length fields. (Length of a variable-length Data field is given by its corresponding Length field.) Block length only represents message body fields; it does not @@ -324,12 +316,11 @@ value does not include the group dimensions itself. Note that padding will only result in deterministic alignment if the repeating group contains no variable-length fields. -### Entry counter +### Entry counter Each group is associated with a required counter field of semantic data type NumInGroup to tell how many entries are contained by a message. The -value of the counter is a non-negative integer. See "Encoding of repeating group dimensions" section below -for encoding of that counter. +value of the counter is a non-negative integer. See section [*Encoding of repeating group dimensions*](#encoding-of-repeating-group-dimensions) for details. ### Empty group @@ -402,6 +393,8 @@ that case, no NumInGroup is encoded on the wire for the child groups. ### Group dimension encoding +#### General + Every repeating group must be immediately preceded on the wire by its dimensions. The two dimensions are the count of entries in a repeating group and the space reserved for each entry of the group. @@ -415,11 +408,11 @@ unsigned integer types. By default, the minimum number of entries is zero, and the maximum number is the largest value of the primitiveType of the counter. | Primitive type | Description | Length (octets) | Maximum number of entries | -|----------------|-------------------------|----------------:|--------------------------:| -| uint8 | 8-bit unsigned integer | 1 | 255 | -| uint16 | 16-bit unsigned integer | 2 | 65535 | +|----------------|-------------------------|:---------------:|:--------------------:| +| uint8 | 8-bit unsigned integer | 1 | 255 | +| uint16 | 16-bit unsigned integer | 2 | 65535 | -The number of entries may be restricted to a specific range; see "Restricting repeating group entries" below. +The number of entries may be restricted to a specific range; see section [*Restricting repeating group entries*](#restricting-repeating-group-entries) for details. #### Encoding of repeating group dimensions @@ -440,7 +433,7 @@ Recommended encoding of repeating group dimensions - + ``` @@ -454,9 +447,9 @@ any repeating groups or variable-length fields. The number of entries in this repeating group, called NumInGroup in FIX. -##### Number of repeating groups +#### Number of repeating groups -A count nested repeating groups in this repeating group. +A count of the nested repeating groups in this repeating group. #### Number of variable-length fields @@ -476,8 +469,7 @@ Example of a restricted group encoding ``` -Sequence of message body elements ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +## Sequence of message body elements ### Root level elements @@ -486,12 +478,10 @@ specified with this sequence of message body elements: 1. Fixed-length fields that reside at the root level of the message (that is, not members of repeating groups), including any of the - following, in the order specified by the message schema:: + following, in the order specified by the message schema: a. Fixed-length scalar fields, such as integers - b. Fixed-length character arrays - c. Fixed-length composite types, such as MonthYear 2. Repeating groups, if any. @@ -504,10 +494,9 @@ Repeating group entries are recursively organized in the same fashion as the root level: fixed-length fields, then nested repeating groups, and finally, variable-length data fields. -Message structure validation --------------------------------------------------------------------------------------------------------------------------- +## Message structure validation -Aside from message schema validations (see section 4.8 below), these +Aside from message schema validations (see section [*Schema validation*](#schema-validation)), these validations apply to message structure. If a message structure violation is detected on a received message, the diff --git a/v1-0-STANDARD/doc/04MessageSchema.md b/v1-0-STANDARD/doc/04MessageSchema.md index 45d2947..0ccfcc2 100644 --- a/v1-0-STANDARD/doc/04MessageSchema.md +++ b/v1-0-STANDARD/doc/04MessageSchema.md @@ -1,18 +1,17 @@ - Message Schema -========================================================================================================================================================================================================== +# Message Schema -XML schema for SBE message schemas ---------- -See [sbe.xsd](../resources/sbe.xsd) for the normative XML Schema Definition (XSD) for SBE. +## XML schema for SBE message schemas +See [sbe.xsd](https://github.com/FIXTradingCommunity/fix-simple-binary-encoding/blob/master/v1-0-STANDARD/resources/sbe.xsd) for the normative XML Schema Definition (XSD) for SBE. -XML namespace ------------------------------------------------------------------------------------------------------------ +**TODO: XSD file should be added as appendix into the specification for ISO submission.** -The Simple Binary Encoding XML schema is identified by this URL [*tentative*]: +## XML namespace + +The Simple Binary Encoding XML schema is identified by this URL: ```xml -xmlns:sbe=http://fixprotocol.io/2017/sbe +xmlns:sbe=http://fixprotocol.io/2016/sbe ``` Conventionally, the URI of the XML schema is aliased by the prefix @@ -21,16 +20,17 @@ Conventionally, the URI of the XML schema is aliased by the prefix *Caution:* Users should treat the SBE XML namespace as a URI (unique identifier), not as a URL (physical resource locator). Firms should not depend on access to the FIX Trading Community web site to validate XML schemas at -run-time +run-time. + +## Naming convention -Name convention -------------------------------------------------------------------------------------------------------------- +### General All symbolic names in a message schema are restricted to alphanumeric characters plus underscore without spaces. This is the same restriction applied to all names in FIX specifications. -### Capitalization +### Capitalization The value of a field's `semanticType` attribute is a FIX data type. In this document, FIX types are capitalized exactly as in the FIX @@ -39,8 +39,9 @@ derived. Since the capitalization is somewhat inconsistent, however, it is recommended that matching of type names should be case insensitive in schema parsers. -Root element ------------- +## Root element + +### General The root element of the XML document is ``. @@ -48,19 +49,19 @@ The root element of the XML document is ``. The root element provides basic identification of a schema. -The `byteOrder` attribute controls the byte order of integer encodings +The `byteOrder` attribute controls the byte order of integer and float encodings within the schema. It is a global setting for all specified messages and their encodings. -| Schema attribute | Description | XML type | Usage | Valid values | -|------------------|--------------------------------------------------------------------------------------------------|--------------------|------------------------|------------------------------------------------------------------------------| -| package | Name or category of a schema | string | optional | Should be unique between counterparties but no naming convention is imposed. | -| id | Unique identifier of a schema | unsignedInt | | Should be unique between counterparties | -| version | Version of this schema | nonnegativeInteger | | Initial version is zero and is incremented for each version | -| semanticVersion | Version of FIX semantics | string | optional | FIX versions, such as “FIX.5.0\_SP2” | -| byteOrder | Byte order of encoding | token | default = littleEndian | littleEndian bigEndian | -| description | Documentation of the schema | string | optional | | -| headerType | Name of the encoding type of the message header, which is the same for all messages in a schema. | string | default= messageHeader | An encoding with this name must be contained by '`. | +| Schema attribute | Description | XML type | Usage | Valid values | +|------------------|---------------------------------|--------------|--------------|--------------------------| +| package | Name or category of a schema | string | optional | Should be unique between counterparties but no naming convention is imposed. | +| id | Unique identifier of a schema | unsignedInt | | Should be unique between counterparties | +| version | Version of this schema | nonnegativeInteger | | Initial version is zero and is incremented for each version | +| semanticVersion | Version of FIX semantics | string | optional | FIX versions, such as “FIX.5.0\_SP2”| +| byteOrder | Byte order of encoding | token | default = littleEndian | littleEndian bigEndian | +| description | Documentation of the schema | string | optional | | +| headerType | Name of the encoding type of the message header, which is the same for all messages in a schema. | string | default= messageHeader | An encoding with this name must be contained by ``. | ### Schema versioning @@ -75,10 +76,9 @@ the version number. The `package` attribute should remain constant between versions, if it is supplied. -Data encodings ------------------------------------------------------------------------------------------------------------- +## Data encodings -### Encoding sets +### Encoding sets The `` element contains one or more sets of data encodings used for messages within the schema. @@ -96,6 +96,8 @@ sequence: ### Encoding name +#### General + The namespace for encoding names is global across all encodings included in a schema, including simple, composite and enumeration types. That is, the name must be unique among all encoding instances. @@ -118,6 +120,8 @@ Example of XML include usage to import common encoding types ### Simple encodings +### General + A simple encoding is backed by either a scalar type or an array of scalars, such as a character array. One or more simple encodings may be defined, each specified by a `` element. @@ -127,7 +131,7 @@ defined, each specified by a `` element. If the element has a value, it is used to indicate a special value of the encoding. -##### Constant value +#### Constant value The element value represents a constant if attribute `presence="constant"`. In this case, the value is conditionally required. @@ -135,20 +139,20 @@ The element value represents a constant if attribute #### `` attributes -| `` attribute | Description | XML type | Usage | Valid values | -|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|-----------------------------------|----------------------------------------------------------------------------------------| -| name | Name of encoding | symbolicName\_t | required | Must be unique among all encoding types in a schema. | -| description | Documentation of the type | string | optional | | -| presence | Presence of any field encoded with this type | token | | required optional constant | -| nullValue | Override of special value used to indicate null for an optional field | string | Only valid if presence = optional | The XML string must be convertible to the scalar data type specified by primitiveType. | -| minValue | Lowest acceptable value | string | | | -| maxValue | Highest acceptable value | string | | | -| length | Number of elements of the primitive data type | nonnegativeInteger | default = 1 | Value “0” represents variable length. | -| offset | If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | See section 4.4.4.3 below | -| primitiveType | The primitive data type that backs the encoding | token | required | char int8 int16 int32 int64 uint8 uint16 uint32 uint64 float double | -| semanticType | Represents a FIX data type | token | optional | Same as field semanticType – see below. | -| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. | -| deprecated | Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | +| `` attribute | Description | XML type | Usage | Valid values | +|----------------------|-----------------------------------------------|-------------------|-----------------|---------------------------| +| name | Name of encoding | symbolicName\_t | required | Must be unique among all encoding types in a schema. | +| description | Documentation of the type | string | optional | | +| presence | Presence of any field encoded with this type | token | | required optional constant | +| nullValue | Override of special value used to indicate null for an optional field | string | Only valid if presence = optional | The XML string must be convertible to the scalar data type specified by primitiveType. | +| minValue | Lowest acceptable value | string | | | +| maxValue | Highest acceptable value | string | | | +| length | Number of elements of the primitive data type | nonnegativeInteger | default = 1 | Value “0” represents variable length. | +| offset | If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | See section [*Element offset within a composite type*](#element-offset-within-a-composite-type) | +| primitiveType | The primitive data type that backs the encoding | token | required | char int8 int16 int32 int64 uint8 uint16 uint32 uint64 float double | +| semanticType | Represents a FIX data type | token | optional | Same as field semanticType – see below. | +| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. | +| deprecated | Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | #### FIX data type specification @@ -159,28 +163,26 @@ but if it is, the two values must match. Simple type examples ```xml - - -C + + +C ``` ### Composite encodings +#### General + Composite encoding types are composed of two or more simple types. #### `` attributes -| `` attribute | Description | XML type | Usage | Valid values | -|--------------------|----------------------------------------------------------------------------------------------------------------|--------------------|-------------|------------------------------------------------------------------| -| name | Name of encoding | symbolicName\_t | required | Must be unique among all encoding types. | -| offset | The offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | | -| description | Documentation of the type | string | optional | | -| semanticType | Represents a FIX data type | token | optional | Same as field semanticType – see below. | -| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. | +| `` attribute | Description | XML type | Usage | Valid values | +|----------------------|-----------------------------------------------|-------------------|-----------------|---------------------------| +| name | Name of encoding | symbolicName\_t | required | Must be unique among all encoding types. | +| offset | The offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | | +| description | Documentation of the type | string | optional | | +| semanticType | Represents a FIX data type | token | optional | Same as field semanticType – see below. | +| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. | | deprecated | Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | #### Composite type elements @@ -193,14 +195,13 @@ stand-alone types. Composite type example -In this example, a Price is encoded as 32 bit integer mantissa and a +In this example, a Price is encoded as 32-bit integer mantissa and a constant exponent, which is not sent on the wire. ```xml - -4 + -4 ``` @@ -223,23 +224,25 @@ mantissa element indicates that the price is null. ### Reference to reusable types +#### General + A composite type often has its elements defined in-line within the `` XML element as shown in the example above. Alternatively, a common type may be defined once on its own, and then referred to by name with the composite type using a `` element. #### `` attributes -| `` attribute | Description | XML type | Usage | Valid values | -|--------------------|----------------------------------------------------------------------------------------------------------------|--------------------|-------------|------------------------------------------------------------------| -| name | Usage of the type in this composite | symbolicName\_t | required | | -| type | Name of referenced encoding | symbolicName\_t | required | Must match a defined type, enum or set or composite name attribute. | -| offset | The offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | | -| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. | -| deprecated | Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | +| `` attribute | Description | XML type | Usage | Valid values | +|----------------------|-----------------------------------------------|-------------------|-----------------|---------------------------| +| name | Usage of the type in this composite | symbolicName\_t | required | | +| type | Name of referenced encoding | symbolicName\_t | required | Must match a defined type, enum or set or composite name attribute. | +| offset | The offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | | +| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. | +| deprecated | Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | #### Type reference examples **Reference to an enum** -In this example, a futuresPrice is encoded as 64 bit integer mantissa, 8 bit exponent, and a reused enum type. +In this example, a futuresPrice is encoded as 64-bit integer mantissa, 8-bit exponent, and a reused enum type. ```xml @@ -251,27 +254,29 @@ In this example, a futuresPrice is encoded as 64 bit integer mantissa, 8 bit ex - + ``` **Reference to a composite type** -In this example, a nested composite is formed by using a reference to another composite type. It supports the expresson of a monetary amount with its currency, such as USD150.45. Note that a reference may carry an offset within the composite encoding that contains it. +In this example, a nested composite is formed by using a reference to another composite type. It supports the expression of a monetary amount with its currency, such as USD 150.45. Note that a reference may carry an offset within the composite encoding that contains it. ```xml - + - + ``` ### Enumeration encodings +#### General + An enumeration explicitly lists the valid values of a data domain. Any number of fields may share the same enumeration. @@ -283,25 +288,25 @@ number of `` elements. The `encodingType` attribute refers to a simple encoding of scalar type. The encoding of an enumeration may be char or any unsigned integer type. -| `` attribute | Description | XML type | Usage | Valid values | -|--------------------|----------------------------------------------------------------------------------------------------------------|--------------------|-------------|-----------------------------------------------------------------------------------| -| name | Name of encoding | symbolicName\_t | required | Must be unique among all encoding types. | -| description | Documentation of the type | string | optional | | -| encodingType | Name of a simple encoding type | symbolicName\_t | required | Must match the name attribute of a scalar `` element *or* a primitive type: char uint8 uint16 uint32 uint64 | -| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. | -| deprecated | Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | -| offset | If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | +| `` attribute | Description | XML type | Usage | Valid values | +|----------------------|-----------------------------------------------|-------------------|-----------------|---------------------------| +| name | Name of encoding | symbolicName\_t | required | Must be unique among all encoding types. | +| description | Documentation of the type | string | optional | | +| encodingType | Name of a simple encoding type | symbolicName\_t | required | Must match the name attribute of a scalar `` element *or* a primitive type: char uint8 uint16 uint32 uint64 | +| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. | +| deprecated | Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | +| offset | If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | #### `` element attributes The name attribute of the `` uniquely identifies it. -| `` attribute | Description | XML type | Usage | Valid values | -|--------------------|-----------------------------------------------------------------------------------------------------------------|--------------------|-------------|------------------------------------------------------------------| -| name | Symbolic name of value | symbolicName\_t | required | Must be unique among valid values in the enumeration. | -| description | Documentation of the value | string | optional | | -| sinceVersion | Documents the version of a schema in which a value was added | nonNegativeInteger | default = 0 | | -| deprecated | Documents the version of a schema in which a value was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | +| `` attribute | Description | XML type | Usage | Valid values | +|------------------------|-----------------------------------------------|-------------------|-----------------|---------------------------| +| name | Symbolic name of value | symbolicName\_t | required | Must be unique among valid values in the enumeration. | +| description | Documentation of the value | string | optional | | +| sinceVersion | Documents the version of a schema in which a value was added | nonNegativeInteger | default = 0 | | +| deprecated | Documents the version of a schema in which a value was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | #### `` element content @@ -313,7 +318,7 @@ the encoding, such as an integer. Enumeration example (not all valid values listed) -This enumeration is encoded as an 8 bit unsigned integer value. Others +This enumeration is encoded as an 8-bit unsigned integer value. Others are encoded as char codes. ```xml @@ -329,6 +334,8 @@ are encoded as char codes. ### Multi-value choice encodings (bitset) +#### General + An enumeration explicitly lists the valid values of a data domain. Any number of fields may share the same set of choices. @@ -342,27 +349,27 @@ uint64 encoding. The `encodingType` attribute refers to a simple encoding of scalar type. The encoding of a bitset should be an unsigned integer type. -| `` attribute | Description | XML type | Usage | Valid values | -|-------------------|----------------------------------------------------------------------------------------------------------------|--------------------|-------------|-----------------------------------------------------------------------------------| -| name | Name of encoding | symbolicName\_t | required | Must be unique among all encoding types. | -| description | Documentation of the type | string | optional | | -| encodingType | Name of a simple encoding type | string | required | Must match the name attribute of a scalar `` element *or* a primitive type: uint8 uint16 uint32 uint64 | -| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. | -| deprecated | Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. -| offset | If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | +| `` attribute | Description | XML type | Usage | Valid values | +|----------------------|-----------------------------------------------|-------------------|-----------------|---------------------------| +| name | Name of encoding | symbolicName\_t | required | Must be unique among all encoding types. | +| description | Documentation of the type | string | optional | | +| encodingType | Name of a simple encoding type | string | required | Must match the name attribute of a scalar `` element *or* a primitive type: uint8 uint16 uint32 uint64 | +| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. | +| deprecated | Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | +| offset | If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | #### `` element attributes The `name` attribute of the `` uniquely identifies it. -| `` attribute | Description | XML type | Usage | Valid values | -|----------------------|------------------------------------------------------------------------------------------------------------------|--------------------|-------------|------------------------------------------------------------------| -| name | Symbolic name of value | symbolicName\_t | required | Must be unique among choices in the set. | -| description | Documentation of the value | string | optional | | -| sinceVersion | Documents the version of a schema in which a choice was added | nonNegativeInteger | default = 0 | | -| deprecated | Documents the version of a schema in which a choice was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | +| `` attribute | Description | XML type | Usage | Valid values | +|----------------------|-----------------------------------------------|-------------------|-----------------|---------------------------| +| name | Symbolic name of value | symbolicName\_t | required | Must be unique among choices in the set. | +| description | Documentation of the value | string | optional | | +| sinceVersion | Documents the version of a schema in which a choice was added | nonNegativeInteger | default = 0 | | +| deprecated | Documents the version of a schema in which a choice was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | -#### `< choice >` element content +#### `` element content The element is required to carry a value, which is an unsigned integer representing a zero-based index to a bit within a bitset. Zero is the @@ -370,7 +377,7 @@ least significant bit. `` and `` XML elements -Multi-value choice example, The choice is encoded as a bitset. +Multi-value choice example, the choice is encoded as a bitset. ```xml @@ -382,8 +389,9 @@ Multi-value choice example, The choice is encoded as a bitset. ``` -Message template --------------------------------------------------------------------------------------------------------------- +## Message template + +### General To define a message type, add a `` element to the root element of the XML document, ``. @@ -405,9 +413,7 @@ A `` element contains its field definitions in three categories, which must appear in this sequence: 1. Element `` defines a fixed-length field - 2. Element `` defines a repeating group - 3. Element `` defines a variable-length field, such as raw data The number of members of each type is unbound. @@ -417,21 +423,21 @@ The number of members of each type is unbound. The order that fields are listed in the message schema governs the order that they are encoded on the wire. -**`` element attributes** - -| `` attribute | Description | XML type | Usage | Valid values | -|-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------|--------------------|-------------|--------------------------------------------------------------------------| -| name | Name of a message | symbolicName\_t | required | Must be unique among all messages in a schema | -| id | Unique message template identifier | unsignedInt | required | Must be unique within a schema | -| description | Documentation | string | optional | | -| blockLength | Reserved size in number of octets for root level of message body | unsignedInt | optional | If specified, must be greater than or equal to the sum of field lengths. | -| semanticType | Documents value of FIX MsgType for a message | token | optional | Listed in FIX specifications | -| sinceVersion | Documents the version of a schema in which a message was added | nonNegativeInteger | default = 0 | | -| deprecated | Documents the version of a schema in which a message was deprecated. It should no longer be sent but is documented for back-compatibility. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | +### `` element attributes + +| `` attribute | Description | XML type | Usage | Valid values | +|----------------------|-----------------------------------------------|-------------------|-----------------|---------------------------| +| name | Name of a message | symbolicName\_t | required | Must be unique among all messages in a schema | +| id | Unique message template identifier | unsignedInt | required | Must be unique within a schema | +| description | Documentation | string | optional | | +| blockLength | Reserved size in number of octets for root level of message body | unsignedInt | optional | If specified, must be greater than or equal to the sum of field lengths. | +| semanticType | Documents value of FIX MsgType(35) field for a message | token | optional | Listed in FIX specifications | +| sinceVersion | Documents the version of a schema in which a message was added | nonNegativeInteger | default = 0 | | +| deprecated | Documents the version of a schema in which a message was deprecated. It should no longer be sent but is documented for back-compatibility. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | Note that there need not be a one-to-one relationship between message template (identified by `id` attribute) and `semanticType` attribute. You -might design multiple templates for the same FIX MsgType to optimize +might design multiple templates for the same FIX MsgType(35) value to optimize different scenarios. Example `` element @@ -440,26 +446,24 @@ Example `` element ``` -Field attributes --------------------------------------------------------------------------------------------------------------- +## Field attributes -Fields are added to a `` element as child elements. See Field -Encoding section above for a listing of all field types. +Fields are added to a `` element as child elements. See section [*Field Encoding*](#field-encoding) for a listing of all field types. These are the common attributes of all field types. -| Schema attribute | Description | XML type | Usage | Valid values | -|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------|------------------------------------|-------------------------------------------------------------------------------------------------------| -| name | Name of a field | symbolicName\_t | required | Name and id must uniquely identify a field type within a message schema. | -| id | Unique field identifier (FIX tag) | unsignedShort | required | | -| description | Documentation | string | optional | | -| type | Encoding type name, one of simple type, composite type or enumeration. | string | required | Must match the name attribute of a simple ``, `` encoding type, `` or ``. | -| offset | Offset to the start of the field within a message or repeating group entry. By default, the offset is the sum of preceding field sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | Must be greater than or equal to the sum of preceding field sizes. | -| presence | Field presence | enumeration | Default = required | required = field value is required; not tested for null. optional = field value may be null. constant = constant value not sent on wire. | -| valueRef | Constant value of a field as a valid value of an enumeration | qualifiedName\_t | optional Valid only if presence= ”constant” | If provided, the qualified name must match the name attribute of a `` within an `` | -| sinceVersion | The version of a message schema in which this field was added. | InonnegativeInteger | default=0 | Must not be greater than version attribute of `` element. | -| deprecated | Documents the version of a schema in which a field was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | +| Schema attribute | Description | XML type | Usage | Valid values | +|----------------------|-----------------------------------------------|-------------------|-----------------|---------------------------| +| name | Name of a field | symbolicName\_t | required | Name and id must uniquely identify a field type within a message schema. | +| id | Unique field identifier (FIX tag number) | unsignedShort | required | | +| description | Documentation | string | optional | | +| type | Encoding type name, one of simple type, composite type or enumeration. | string | required | Must match the name attribute of a simple ``, `` encoding type, `` or ``. | +| offset | Offset to the start of the field within a message or repeating group entry. By default, the offset is the sum of preceding field sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | Must be greater than or equal to the sum of preceding field sizes. | +| presence | Field presence | enumeration | Default = required | required = field value is required; not tested for null. optional = field value may be null. constant = constant value not sent on wire. | +| valueRef | Constant value of a field as a valid value of an enumeration | qualifiedName\_t | optional Valid only if presence= ”constant” | If provided, the qualified name must match the name attribute of a `` within an `` | +| sinceVersion | The version of a message schema in which this field was added. | InonnegativeInteger | default=0 | Must not be greater than version attribute of `` element. | +| deprecated | Documents the version of a schema in which a field was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | Example field schemas @@ -469,19 +473,17 @@ Field that uses a composite encoding ```xml - 0\ + 0\ - + ``` -Repeating group schema --------------------------------------------------------------------------------------------------------------------- +## Repeating group schema A `` has the same attributes as a `` element since they -both inherit attributes from the blockType XML type. A group has the +both inherit attributes from the blockType XML type. See section +[*Message element attributes*](#message-element-attributes) for details. A group has the same child members as a message, and they must appear in the same order: 1. Element `` defines a fixed-length field @@ -494,23 +496,19 @@ same child members as a message, and they must appear in the same order: The number of members of each type is unbound. -| `` attribute | Description | XML type | Usage | Valid values | -|---------------------|-----------------------------------|-----------------|-----------------------------|--------------------------------------------------------------------------| +| `` attribute | Description | XML type | Usage | Valid values | +|----------------------|-------------------------------|------------------------|--------------|---------------------------| | name | Name of a group | symbolicName\_t | required | Name and id must uniquely identify a group type within a message schema. | | id | Unique group identifier | unsignedShort | required | | | description | Documentation | string | optional | | | dimensionType | Dimensions of the repeating group | symbolicName\_t | default = groupSizeEncoding | If specified, must be greater than or equal to the sum of field lengths. | -`` element inherits attributes of blockType. See `` -above. - *Example group schema with default dimension encoding* ```xml - + @@ -519,36 +517,35 @@ above. ``` -Schema validation --------------------------------------------------------------------------------------------------------------------------------------------------------------- +## Schema validation + +### General The first level of schema validation is enforced by XML schema validation tools to make sure that a schema is well-formed according to XSD schema rules. Well-formed XML is necessary but insufficient to prove that a schema is correct according to FIX Simple Binary Encoding rules. -Additional conditions that render a schema invalid include the -following. - -| Error condition | Error description | -|----------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Missing field encoding | A field or `` references a type name that is undefined. | -| Missing message header encoding | Missing encoding type for headerType specified in ``. Default name is “messageHeader”. | -| Duplicate encoding name | An encoding name is non-unique, rendering a reference ambiguous. | -| nullValue specified for non-null encoding | Attribute nullValue is inconsistent with presence=required or constant | -| Attributes nullValue, minValue or maxValue of wrong data range | The specified values must be convertible to a scalar value consistent with the encoding. For example, if the primitive type is uint8, then the value must be in the range 0 through 255. | -| semanticType mismatch | If the attribute is specified on both a field and the encoding that it references, the values must be identical. | -| presence mismatch | If the attribute is specified on both a field and the encoding that it references, the values must be identical. | -| Missing constant value | If presence=constant is specified for a field or encoding, the element value must contain the constant value. | -| Missing validValue content | A `` element is required to carry its value. | -| Incompatible offset and blockLength | A field offset greater than message or group blockLength is invalid | +Additional conditions that render a schema invalid include the following. + +| Error condition | Error description | +|--------------------------|--------------------------------------------------------------------------------------| +| Missing field encoding | A field or `` references a type name that is undefined. | +| Missing message header encoding | Missing encoding type for headerType specified in ``. Default name is “messageHeader”. | +| Duplicate encoding name | An encoding name is non-unique, rendering a reference ambiguous. | +| nullValue specified for non-null encoding | Attribute nullValue is inconsistent with presence=required or constant | +| Attributes nullValue, minValue or maxValue of wrong data range | The specified values must be convertible to a scalar value consistent with the encoding. For example, if the primitive type is uint8, then the value must be in the range 0 through 255. | +| semanticType mismatch | If the attribute is specified on both a field and the encoding that it references, the values must be identical. | +| presence mismatch | If the attribute is specified on both a field and the encoding that it references, the values must be identical. | +| Missing constant value | If presence=constant is specified for a field or encoding, the element value must contain the constant value. | +| Missing validValue content | A `` element is required to carry its value. | +| Incompatible offset and blockLength | A field offset greater than message or group blockLength is invalid | | Duplicate ID or name of field or group | Attributes id and name must uniquely identify a type within a message schema. This applies to fields and groups. To be clear, the same field or group ID may be used in multiple messages, but each instance must represent the same type. Each of those instances must match on both id and name attributes. | ### Message with a repeating group ```xml - + @@ -570,8 +567,7 @@ following. - + @@ -581,8 +577,7 @@ following. ``` -Reserved element names ----------------------- +## Reserved element names ### Composite types diff --git a/v1-0-STANDARD/doc/05SchemaExtensionMechanism.md b/v1-0-STANDARD/doc/05SchemaExtensionMechanism.md index eb067a5..9977c0d 100644 --- a/v1-0-STANDARD/doc/05SchemaExtensionMechanism.md +++ b/v1-0-STANDARD/doc/05SchemaExtensionMechanism.md @@ -1,8 +1,8 @@ -Schema Extension Mechanism -===================================================================================================================================================================================================================================================================== +# Schema Extension Mechanism -Objective ---------- +## Objective + +### General It is not always practical to update all message publishers and consumers simultaneously. Within certain constraints, message schemas @@ -34,8 +34,7 @@ wire format does not change. Changes that break those constraints require consumers to update to the current schema used by publishers. An message template that has changed in an incompatible way must be assinged a new template "id" attribute. -Message schema features for extension -------------------------------------- +## Message schema features for extension ### Schema version @@ -48,7 +47,7 @@ Version applies to the schema as a whole, not to individual elements. Version is sent in the message header so the consumer can determine which version of the message schema was used to encode the message. -See section 4.3.1 above for schema attributes. +See section [*Message schema attributes*](#messageschema-attributes) for the specification. ### Since version @@ -68,7 +67,7 @@ appended in proper order. The length of the root level of the message may optionally be documented on a `` element in the schema using the blockLength attribute. -See section 4.5.3 above for message attributes. If not set in the +See section [*Message element attributes*](#message-element-attributes) for details. If not set in the schema, block length of the message root is the sum of its field lengths. Whether it is set in the schema or not, the block length is sent on the wire to consumers. @@ -76,7 +75,7 @@ sent on the wire to consumers. Likewise, a repeating group has a blockLength attribute to tell how much space is reserved for group entries, and the value is sent on the wire. It is encoded in the schema as part of the NumInGroup field encoding. -See section 3.4.8.2 above. +See section [*Encoding of repeating group dimensions*](#encoding-of-repeating-group-dimensions) for details. ### Deprecated elements @@ -86,13 +85,12 @@ Updated applications should not publish deprecated messages or values, but declarations may remain in the message schema during a staged migration to replacement message layouts. -Wire format features for extension ----------------------------------- +## Wire format features for extension ### Block size The length of the root level of the message is sent on the wire in the -SBE message header. See section 3.2.2 above. Therefore, if new fields +SBE message header. See section [*Root block length*](#root-block-length) for details. Therefore, if new fields were appended in a later version of the schema, the consumer would still know how many octets to consume to find the next message element, such as repeating group or variable-length Data field. Without the current @@ -106,30 +104,29 @@ encoding. Message headers and repeating group dimensions carry a count of the number of repeating groups and a count of variable-length data fields on the wire. This supports a walk by a decoder of all the elements of a message, even when the decoder was built with an older version of a schema. As for added fixed-length fields, new repeating groups cannot be interpreted by the decoder, but it still can process the ones it knows, and it can correctly reach the end of a message. -Comaptibility strategy ------------------------ +## Compatibility strategy + *This suggested strategy is non-normative.* A message decoder compares the schema version in a received message header to the version that the decoder was built with. If the *received version is equal to the decoder's version*, then all fields known to the decoder may be parsed, and no further analysis is required. -If the *received version is greater than the decoder's version* (that is, the producer's encoder is newer than the consumer's decoder), then all fields known to the decoder may be parsed but it will be unable to parse added fields. +If the *received version is greater than the decoder's version* (that is, the producer's encoder is newer than the consumer's decoder), then all fields known to the decoder may be parsed but it will be unable to parse added fields. -Also, an old decoder may encounter unexpected enumeration values. The application layer determines whether an unexpected value is a fatal error. Probably so for a required field since the business meaning is unknown, but it may choose to allow an unknown value of an optional field to pass through. For example, if OrdType value J="Market If Touched" is added to a schema, and the consumer does not recognize it, then the application returns an order rejection with reason "order type not supported", even if it does not know what "J" represents. Note that this is not strictly a versioning problem, however. This exception handling is indistinguishable from the case where "J" was never added to the enum but was simply sent in error. +Also, an old decoder may encounter unexpected enumeration values. The application layer determines whether an unexpected value is a fatal error. Probably so for a required field since the business meaning is unknown, but it may choose to allow an unknown value of an optional field to pass through. For example, if OrdType(40)=J (Market If Touched (MIT)) is added to a schema, and the consumer does not recognize it, then the application returns an order rejection with reason "order type not supported", even if it does not know what "J" represents. Note that this is not strictly a versioning problem, however. This exception handling is indistinguishable from the case where "J" was never added to the enum but was simply sent in error. -If the *received version is less than the decoder's version* (that is, the producer's encoder is older than the consumer's decoder), then only the fields of the older version may be parsed. This information is available through metadata as "sinceVersion" attribute of a field. If sinceVersion is greater than received schema version, then the field is not available. How a decoder signals an application that a field is unavailable is an implementation detail. One strategy is for an application to provide a default value for unavailable fields. +If the *received version is less than the decoder's version* (that is, the producer's encoder is older than the consumer's decoder), then only the fields of the older version may be parsed. This information is available through metadata as sinceVersion attribute of a field. If sinceVersion is greater than received schema version, then the field is not available. How a decoder signals an application that a field is unavailable is an implementation detail. One strategy is for an application to provide a default value for unavailable fields. -Message schema extension example --------------------------------- +## Message schema extension example -Initial version of a message schema +### Initial version of a message schema ```xml - - - + + + @@ -138,52 +135,44 @@ Initial version of a message schema ``` -Second version - a new message is added +### Second version - a new message is added ```xml - + - + - - + + ``` -Third version - a field is added +### Third version - a field is added ```xml - + - - + + - + - + diff --git a/v1-0-STANDARD/doc/06UsageGuidelines.md b/v1-0-STANDARD/doc/06UsageGuidelines.md index 31979eb..deeaadb 100644 --- a/v1-0-STANDARD/doc/06UsageGuidelines.md +++ b/v1-0-STANDARD/doc/06UsageGuidelines.md @@ -1,8 +1,6 @@ -Usage Guidelines -================ +# Usage Guidelines -Identifier encodings -------------------------------------------------------------------------------------------------------------------- +## Identifier encodings FIX specifies request and entity identifiers as String type. Common practice is to specify an identifier field as fixed-length character of @@ -10,21 +8,19 @@ a certain size. Optionally, a message schema may restrict such identifiers to numeric encodings. - -Example of an identifier field with character encoding +\ +**Example of an identifier field with character encoding** ```xml - + ``` - -Example of an identifier field with numeric encoding +\ +**Example of an identifier field with numeric encoding** ```xml - + ``` diff --git a/v1-0-STANDARD/doc/07Examples.md b/v1-0-STANDARD/doc/07Examples.md index 4dcb290..41f2634 100644 --- a/v1-0-STANDARD/doc/07Examples.md +++ b/v1-0-STANDARD/doc/07Examples.md @@ -1,14 +1,16 @@ -Examples -======== +# Examples -The example messages are preceded by Simple Open Framing Header. Note +## General + +The example messages are preceded by Simple Open Framing Header (SOFH). Note that SOFH encoding is always big-endian, regardless of the byte order of the SBE message body. See that FIX standard for details. Not all FIX enumeration values are listed in the samples. -Flat, fixed-length message --------------------------- +## Flat, fixed-length message + +### General This is an example of a simple, flat order message without repeating groups or variable-length data. @@ -18,7 +20,7 @@ groups or variable-length data. ```xml - > - - - 2 - 4 - 6 + 0 + 1 + 2 + 4 + 6 - - + ``` @@ -339,13 +343,13 @@ Hexadecimal and ASCII representations (little-endian byte order): ### Interpretation |Wire format|Field ID|Name|Offset|Length|Interpreted value| -|-----------|-------:|----|-----:|-----:|-----------------| +|------------------|:------:|---------------------|:------:|:------:|-------------| | `00000040` | | SOFH message length | 0 | 4 | 64 | | `eb50` | | SOFH encoding | 4 | 2 | SBE little-endian | | `0900` | | SBE block length | 0 | 2 | 9 | | `6100` | | SBE template ID | 2 | 2 | 97 | | `5b00` | | SBE schema ID | 4 | 2 | 91 | | `0000` | | SBE schema version | 6 | 2 | 0 | -| `4f52443030303031` | 379 | BusinesRejectRefId | 0 | 8 | ORD00001 | +| `4f52443030303031` | 379 | BusinessRejectRefID | 0 | 8 | ORD00001 | | `06` | 380 | BusinessRejectReason | 8 | 1 | NotAuthorized | -| `4e6f74206175...` | 58 | Text | 0 | 39 | Not authorized to trade that instrument | \ No newline at end of file +| `4e6f74206175...` | 58 | Text | 0 | 39 | Not authorized to trade that instrument | diff --git a/v1-0-STANDARD/doc/08ReleaseNotes.md b/v1-0-STANDARD/doc/08ReleaseNotes.md deleted file mode 100644 index 090af06..0000000 --- a/v1-0-STANDARD/doc/08ReleaseNotes.md +++ /dev/null @@ -1,16 +0,0 @@ -Release Notes -============= - -These are the changes made since SBE version 1.0. - -SBE version 2.0 Release Candidate 1 -------------------- -These issues were resolved and accepted for version 2.0 Release Candidate 1. See [issues](https://github.com/FIXTradingCommunity/fix-simple-binary-encoding/issues) and [pull requests](https://github.com/FIXTradingCommunity/fix-simple-binary-encoding/pulls) in GitHub for details and changes. - -| Issue | Description | -|------:|----------------------------------------------------------------| -| 26 | Adding new variable length field in a repeating group | - -### Compatibility - -Version 2.0 is not back-compatible SBE version 1.0, either in wire format or XML schema. diff --git a/v1-0-STANDARD/doc/FIXDisclaimerTechStd.md b/v1-0-STANDARD/doc/FIXDisclaimerTechStd.md new file mode 100644 index 0000000..48f3c6e --- /dev/null +++ b/v1-0-STANDARD/doc/FIXDisclaimerTechStd.md @@ -0,0 +1,27 @@ +::: {custom-style=Disclaimer} +DISCLAIMER +::: + +THE INFORMATION CONTAINED HEREIN AND THE FINANCIAL INFORMATION EXCHANGE PROTOCOL (COLLECTIVELY, THE "FIX PROTOCOL") ARE PROVIDED "AS IS" AND NO PERSON OR ENTITY ASSOCIATED WITH THE FIX PROTOCOL MAKES ANY REPRESENTATION OR WARRANTY, EXPRESS OR IMPLIED, AS TO THE FIX PROTOCOL (OR THE RESULTS TO BE OBTAINED BY THE USE THEREOF) OR ANY OTHER MATTER AND EACH SUCH PERSON AND ENTITY SPECIFICALLY DISCLAIMS ANY WARRANTY OF ORIGINALITY, ACCURACY, COMPLETENESS, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SUCH PERSONS AND ENTITIES DO NOT WARRANT THAT THE FIX PROTOCOL WILL CONFORM TO ANY DESCRIPTION THEREOF OR BE FREE OF ERRORS. THE ENTIRE RISK OF ANY USE OF THE FIX PROTOCOL IS ASSUMED BY THE USER. + +NO PERSON OR ENTITY ASSOCIATED WITH THE FIX PROTOCOL SHALL HAVE ANY LIABILITY FOR DAMAGES OF ANY KIND ARISING IN ANY MANNER OUT OF OR IN CONNECTION WITH ANY USER'S USE OF (OR ANY INABILITY TO USE) THE FIX PROTOCOL, WHETHER DIRECT, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL (INCLUDING, WITHOUT LIMITATION, LOSS OF DATA, LOSS OF USE, CLAIMS OF THIRD PARTIES OR LOST PROFITS OR REVENUES OR OTHER ECONOMIC LOSS), WHETHER IN TORT (INCLUDING NEGLIGENCE AND STRICT LIABILITY), CONTRACT OR OTHERWISE, WHETHER OR NOT ANY SUCH PERSON OR ENTITY HAS BEEN ADVISED OF, OR OTHERWISE MIGHT HAVE ANTICIPATED THE POSSIBILITY OF, SUCH DAMAGES. + +**DRAFT OR NOT RATIFIED PROPOSALS** (REFER TO PROPOSAL STATUS AND/OR SUBMISSION STATUS ON COVER PAGE) ARE PROVIDED "AS IS" TO INTERESTED +PARTIES FOR DISCUSSION ONLY. PARTIES THAT CHOOSE TO IMPLEMENT THIS DRAFT PROPOSAL DO SO AT THEIR OWN RISK. IT IS A DRAFT DOCUMENT AND MAY BE +UPDATED, REPLACED, OR MADE OBSOLETE BY OTHER DOCUMENTS AT ANY TIME. THE FIX GLOBAL TECHNICAL COMMITTEE WILL NOT ALLOW EARLY IMPLEMENTATION TO +CONSTRAIN ITS ABILITY TO MAKE CHANGES TO THIS SPECIFICATION PRIOR TO FINAL RELEASE. IT IS INAPPROPRIATE TO USE FIX WORKING DRAFTS AS +REFERENCE MATERIAL OR TO CITE THEM AS OTHER THAN “WORKS IN PROGRESS”. THE FIX GLOBAL TECHNICAL COMMITTEE WILL ISSUE, UPON COMPLETION OF REVIEW +AND RATIFICATION, AN OFFICIAL STATUS ("APPROVED") OF/FOR THE PROPOSAL AND A RELEASE NUMBER. + +No proprietary or ownership interest of any kind is granted with respect to the FIX Protocol (or any rights therein), except as expressly set out in FIX Protocol Limited's Copyright and Acceptable Use Policy. + +© Copyright 2013-2020 FIX Protocol Limited, all rights reserved + +\ + + + +FIX Technical Standard Specifications by [FIX Protocol Ltd.](https://www.fixtradingcommunity.org/) are licensed under a [Creative Commons Attribution-NoDerivatives 4.0 International License](http://creativecommons.org/licenses/by-nd/4.0/). Based on a work at [https://github.com/FIXTradingCommunity/](https://github.com/FIXTradingCommunity/). + + +1. diff --git a/v1-0-STANDARD/doc/FIX_TechStd_Style_MASTER.docx b/v1-0-STANDARD/doc/FIX_TechStd_Style_MASTER.docx new file mode 100644 index 0000000..6b28d28 Binary files /dev/null and b/v1-0-STANDARD/doc/FIX_TechStd_Style_MASTER.docx differ diff --git a/v1-0-STANDARD/doc/ISOBiblio.md b/v1-0-STANDARD/doc/ISOBiblio.md new file mode 100644 index 0000000..712215f --- /dev/null +++ b/v1-0-STANDARD/doc/ISOBiblio.md @@ -0,0 +1,25 @@ +::: {custom-style="Annex"} +**Bibliography** +::: + +[1] Simple Open Framing Header (SOFH) Draft Standard v1.0, *Message framing standard for FIX messages* [https://www.fixtrading.org/standards/fix-sofh/](https://www.fixtrading.org/standards/fix-sofh/) + +[2] FIX Latest, *Normative specification of the FIX Protocol* [https://www.fixtrading.org/online-specification/](https://www.fixtrading.org/online-specification/) + +[3] IEEE 754, *IEEE Standard for Binary Floating-Point Arithmetic* [https://ieeexplore.ieee.org/document/8766229](https://ieeexplore.ieee.org/document/8766229) + +[4] ISO 639-1, *Codes for the representation of names of languages — Part 1: Alpha-2 code* [https://www.iso.org/standard/22109.html](https://www.iso.org/standard/22109.html) + +[5] ISO 3166-1, *Codes for the representation of names of countries and their subdivisions — Part 1: Country codes* [https://www.iso.org/standard/63545.html](https://www.iso.org/standard/63545.html) + +[6] ISO 4217, *Codes for the representation of currencies and funds* [https://www.iso.org/standard/64758.html](https://www.iso.org/standard/64758.html) + +[7] ISO 8601, *Data elements and interchange formats - Information interchange — Representation of dates and times* [https://www.iso.org/standard/40874.html](https://www.iso.org/standard/40874.html) + +[8] ISO 10383, *Securities and related financial instruments — Codes for exchanges and market identification (MIC)* [https://www.iso.org/standard/61067.html](https://www.iso.org/standard/61067.html) + +[9] ISO/IEC 11404, *Information technology — General-Purpose Datatypes (GPD)* [https://www.iso.org/standard/39479.html](https://www.iso.org/standard/39479.html) + +[10] W3C XML Schema, *XML 1.1 schema standards* [http://www.w3.org/XML/Schema.html#dev](http://www.w3.org/XML/Schema.html#dev) + +[11] IETF RFC 2119, *Keywords for use in RFCs to Indicate Requirement Levels March 1997* [https://datatracker.ietf.org/doc/html/rfc2119](https://datatracker.ietf.org/doc/html/rfc2119) diff --git a/v1-0-STANDARD/doc/ISOCopyright.md b/v1-0-STANDARD/doc/ISOCopyright.md new file mode 100644 index 0000000..5be0485 --- /dev/null +++ b/v1-0-STANDARD/doc/ISOCopyright.md @@ -0,0 +1,15 @@ +::: {custom-style="TextBox"} +© ISO 2022\ +\ +All rights reserved. Unless otherwise specified, or required in the context of its implementation, no part of this publication may be reproduced or utilized otherwise in any form or by any means, electronic or mechanical, including photocopying, or posting on the internet or an intranet, without prior written permission. Permission can be requested from either ISO at the address below or ISO’s member body in the country of the requester.\ +\ + ISO copyright office\ + CP 401 • Ch. de Blandonnet 8\ + CH-1214 Vernier, Geneva\ + Phone: +41 22 749 01 11\ + Fax: +41 22 749 09 47\ + Email: copyright@iso.org\ + Website: www.iso.org\ +\ +Published in Switzerland +::: diff --git a/v1-0-STANDARD/doc/ISOForeword.md b/v1-0-STANDARD/doc/ISOForeword.md new file mode 100644 index 0000000..6d100b4 --- /dev/null +++ b/v1-0-STANDARD/doc/ISOForeword.md @@ -0,0 +1,19 @@ +::: {custom-style="NewPageWithTOC"} +**Foreword** +::: + +ISO (the International Organization for Standardization) is a worldwide federation of national standards bodies (ISO member bodies). The work of preparing International Standards is normally carried out through ISO technical committees. Each member body interested in a subject for which a technical committee has been established has the right to be represented on that committee. International organizations, governmental and non-governmental, in liaison with ISO, also take part in the work. ISO collaborates closely with the International Electrotechnical Commission (IEC) on all matters of electrotechnical standardization. + +The procedures used to develop this document and those intended for its further maintenance are described in the ISO/IEC Directives, Part 1. In particular the different approval criteria needed for the different types of ISO documents should be noted. This document was drafted in accordance with the editorial rules of the ISO/IEC Directives, Part 2 (see [www.iso.org/directives](www.iso.org/directives)). + +Attention is drawn to the possibility that some of the elements of this document may be the subject of patent rights. ISO shall not be held responsible for identifying any or all such patent rights. Details of any patent rights identified during the development of the document will be in the Introduction and/or on the ISO list of patent declarations received (see [www.iso.org/patents](www.iso.org/patents)). + +Any trade name used in this document is information given for the convenience of users and does not constitute an endorsement. + +For an explanation on the voluntary nature of standards, the meaning of ISO specific terms and expressions related to conformity assessment, as well as information about ISO's adherence to the World Trade Organization (WTO) principles in the Technical Barriers to Trade (TBT) see the following URL: [www.iso.org/iso/foreword.html](www.iso.org/iso/foreword.html). + +This document was prepared by Technical Committee ISO/TC 68, *Financial Services*, Subcommittee SC 9, *Information Exchange* + +A list of all parts in the ISO ##### series can be found on the ISO website. + +Any feedback or questions on this document should be directed to the user’s national standards body. A complete listing of these bodies can be found at [www.iso.org/members.html](www.iso.org/members.html). diff --git a/v1-0-STANDARD/doc/ISOIntro.md b/v1-0-STANDARD/doc/ISOIntro.md new file mode 100644 index 0000000..b46e934 --- /dev/null +++ b/v1-0-STANDARD/doc/ISOIntro.md @@ -0,0 +1,9 @@ +::: {custom-style="NewPageWithTOC"} +Introduction +::: + +The Financial Information eXchange Simple Binary Encoding (SBE) targets high performance trading systems. It is optimized for low latency of encoding and decoding while keeping bandwidth utilization reasonably small. For compatibility, it is intended to represent all FIX semantics. SBE is primarily a fixed length wire format but also supports variable length fields and repeating groups with fixed length entries. The wire format does not contain any meta-data other than length information for variable elements. The meta-data is a message schema provided out-of-band as an XML Schema Definition (XSD) file. + +::: {custom-style="NewPage"} +**Financial Services -- Financial Information eXchange -- Simple Binary Encoding** +::: diff --git a/v1-0-STANDARD/doc/ISO_TechStd_Style_MASTER.docx b/v1-0-STANDARD/doc/ISO_TechStd_Style_MASTER.docx new file mode 100644 index 0000000..ec57d58 Binary files /dev/null and b/v1-0-STANDARD/doc/ISO_TechStd_Style_MASTER.docx differ diff --git a/v1-0-STANDARD/doc/JTC1Biblio.md b/v1-0-STANDARD/doc/JTC1Biblio.md new file mode 100644 index 0000000..712215f --- /dev/null +++ b/v1-0-STANDARD/doc/JTC1Biblio.md @@ -0,0 +1,25 @@ +::: {custom-style="Annex"} +**Bibliography** +::: + +[1] Simple Open Framing Header (SOFH) Draft Standard v1.0, *Message framing standard for FIX messages* [https://www.fixtrading.org/standards/fix-sofh/](https://www.fixtrading.org/standards/fix-sofh/) + +[2] FIX Latest, *Normative specification of the FIX Protocol* [https://www.fixtrading.org/online-specification/](https://www.fixtrading.org/online-specification/) + +[3] IEEE 754, *IEEE Standard for Binary Floating-Point Arithmetic* [https://ieeexplore.ieee.org/document/8766229](https://ieeexplore.ieee.org/document/8766229) + +[4] ISO 639-1, *Codes for the representation of names of languages — Part 1: Alpha-2 code* [https://www.iso.org/standard/22109.html](https://www.iso.org/standard/22109.html) + +[5] ISO 3166-1, *Codes for the representation of names of countries and their subdivisions — Part 1: Country codes* [https://www.iso.org/standard/63545.html](https://www.iso.org/standard/63545.html) + +[6] ISO 4217, *Codes for the representation of currencies and funds* [https://www.iso.org/standard/64758.html](https://www.iso.org/standard/64758.html) + +[7] ISO 8601, *Data elements and interchange formats - Information interchange — Representation of dates and times* [https://www.iso.org/standard/40874.html](https://www.iso.org/standard/40874.html) + +[8] ISO 10383, *Securities and related financial instruments — Codes for exchanges and market identification (MIC)* [https://www.iso.org/standard/61067.html](https://www.iso.org/standard/61067.html) + +[9] ISO/IEC 11404, *Information technology — General-Purpose Datatypes (GPD)* [https://www.iso.org/standard/39479.html](https://www.iso.org/standard/39479.html) + +[10] W3C XML Schema, *XML 1.1 schema standards* [http://www.w3.org/XML/Schema.html#dev](http://www.w3.org/XML/Schema.html#dev) + +[11] IETF RFC 2119, *Keywords for use in RFCs to Indicate Requirement Levels March 1997* [https://datatracker.ietf.org/doc/html/rfc2119](https://datatracker.ietf.org/doc/html/rfc2119) diff --git a/v1-0-STANDARD/doc/JTC1Copyright.md b/v1-0-STANDARD/doc/JTC1Copyright.md new file mode 100644 index 0000000..31291d3 --- /dev/null +++ b/v1-0-STANDARD/doc/JTC1Copyright.md @@ -0,0 +1,17 @@ +::: {custom-style="TextBox"} +**COPYRIGHT PROTECTED DOCUMENT**\ +\ +© ISO/IEC 2024\ +\ +All rights reserved. Unless otherwise specified, or required in the context of its implementation, no part of this publication may be reproduced or utilized otherwise in any form or by any means, electronic or mechanical, including photocopying, or posting on the internet or an intranet, without prior written permission. Permission can be requested from either ISO at the address below or ISO’s member body in the country of the requester.\ +\ + **ISO copyright office** **IEC Secretariat**\ + CP 401 • Ch. de Blandonnet 8 3, rue de Varembé\ + CH-1214 Vernier, Geneva CH-1211 Geneva 20\ + Phone: +41 22 749 01 11 Phone: +41 22 919 02 11\ + Fax: +41 22 749 09 47 Fax: +41 22 919 03 00\ + Email: copyright@iso.org Email: info@iec.ch\ + Website: [www.iso.org](http://www.iso.org) Website: [www.iec.ch](http://www.iec.ch)\ +\ +Published in Switzerland +::: diff --git a/v1-0-STANDARD/doc/JTC1Foreword.md b/v1-0-STANDARD/doc/JTC1Foreword.md new file mode 100644 index 0000000..2493181 --- /dev/null +++ b/v1-0-STANDARD/doc/JTC1Foreword.md @@ -0,0 +1,17 @@ +::: {custom-style="NewPageWithTOC"} +**Foreword** +::: + +ISO (the International Organization for Standardization) and IEC (the International Electrotechnical Commission) form the specialized system for worldwide standardization. National bodies that are members of ISO or IEC participate in the development of International Standards through technical committees established by the respective organization to deal with particular fields of technical activity. ISO and IEC technical committees collaborate in fields of mutual interest. Other international organizations, governmental and non-governmental, in liaison with ISO and IEC, also take part in the work. + +The procedures used to develop this document and those intended for its further maintenance are described in the ISO/IEC Directives, Part 1. In particular the different approval criteria needed for the different types of ISO documents should be noted. This document was drafted in accordance with the editorial rules of the ISO/IEC Directives, Part 2 (see [www.iso.org/directives](www.iso.org/directives)). + +Attention is drawn to the possibility that some of the elements of this document may be the subject of patent rights. ISO and IEC shall not be held responsible for identifying any or all such patent rights. Details of any patent rights identified during the development of the document will be in the Introduction and/or on the ISO list of patent declarations received (see [www.iso.org/patents](www.iso.org/patents)) or the IEC list of patent declarations received (see [http://patents.iec.ch](http://patents.iec.ch)). + +Any trade name used in this document is information given for the convenience of users and does not constitute an endorsement. + +For an explanation on the voluntary nature of standards, the meaning of ISO specific terms and expressions related to conformity assessment, as well as information about ISO's adherence to the World Trade Organization (WTO) principles in the Technical Barriers to Trade (TBT), see [www.iso.org/iso/foreword.html](www.iso.org/iso/foreword.html). + +This document was prepared by the Joint Development Foundation (as OpenChain Specification) and drafted in accordance with its editorial rules. It was adopted, under the JTC 1 PAS procedure, by Joint Technical Committee ISO/IEC JTC 1, *Information technology*. + +Any feedback or questions on this document should be directed to the user’s national standards body. A complete listing of these bodies can be found at [www.iso.org/members.html](www.iso.org/members.html). diff --git a/v1-0-STANDARD/doc/JTC1Intro.md b/v1-0-STANDARD/doc/JTC1Intro.md new file mode 100644 index 0000000..b46e934 --- /dev/null +++ b/v1-0-STANDARD/doc/JTC1Intro.md @@ -0,0 +1,9 @@ +::: {custom-style="NewPageWithTOC"} +Introduction +::: + +The Financial Information eXchange Simple Binary Encoding (SBE) targets high performance trading systems. It is optimized for low latency of encoding and decoding while keeping bandwidth utilization reasonably small. For compatibility, it is intended to represent all FIX semantics. SBE is primarily a fixed length wire format but also supports variable length fields and repeating groups with fixed length entries. The wire format does not contain any meta-data other than length information for variable elements. The meta-data is a message schema provided out-of-band as an XML Schema Definition (XSD) file. + +::: {custom-style="NewPage"} +**Financial Services -- Financial Information eXchange -- Simple Binary Encoding** +::: diff --git a/v1-0-STANDARD/doc/JTC1_TechStd_Style_MASTER.docx b/v1-0-STANDARD/doc/JTC1_TechStd_Style_MASTER.docx new file mode 100644 index 0000000..60cebf3 Binary files /dev/null and b/v1-0-STANDARD/doc/JTC1_TechStd_Style_MASTER.docx differ diff --git a/v1-0-STANDARD/doc/SBE.cmd b/v1-0-STANDARD/doc/SBE.cmd new file mode 100644 index 0000000..517107a --- /dev/null +++ b/v1-0-STANDARD/doc/SBE.cmd @@ -0,0 +1,44 @@ +echo Compilation started... +:: Script is expected to start running in the folder where it is located (together with the source files) +set SOURCE=%CD% +:: There is only one disclaimer and style docx file for all FIX Technical Standards and it is stored with the FIX Session Layer +:: Repository has local copies with the specific names and dates of the standard +set DISCLAIMER=FIXDisclaimerTechStd.md +set STYLE=FIX_TechStd_Style_MASTER.docx +set TARGET=%SOURCE%\target +set YAML=%SOURCE%\SBE.yaml +set FILES=01Introduction.md 02FieldEncoding.md 03MessageStructure.md 04MessageSchema.md 05SchemaExtensionMechanism.md 06UsageGuidelines.md 07Examples.md +set WPFOLDER=\wp-content\uploads\2020\03\ + +:: Create FIX document version with disclaimer +pandoc "%DISCLAIMER%" %FILES% -o "%TARGET%\docx\Simple_Binary_Encoding_V1.0_with_Errata.docx" --reference-doc="%STYLE%" --metadata-file="%YAML%" --toc --toc-depth=4 +echo SBE document version created for FIX + +:: Create ISO document version with copyright etc. +set ISOYAML=%SOURCE%\SBE_ISO.yaml +set ISOSTYLE=ISO_TechStd_Style_MASTER.docx +set ISOCOPYRIGHT=ISOCopyright.md +set ISOFOREWORD=ISOForeword.md +set ISOINTRO=ISOIntro.md +:: set ISOBIBLIO=ISOBiblio.md + +pandoc %ISOCOPYRIGHT% %ISOFOREWORD% %ISOINTRO% %FILES% -o "%TARGET%\docx\ISOSimple_Binary_Encoding.docx" --reference-doc=%ISOSTYLE% --metadata-file=%ISOYAML% --filter pandoc-plantuml --toc --toc-depth=3 +echo SBE document version created for ISO + +:: Create base online version without disclaimer +:: pandoc $FILES -o "$TARGET/debug/SBEONLINE.html" -s --metadata-file="$YAML" --toc --toc-depth=2 + +:: Remove title as it is redundant to page header +:: sed -i '.bak1' '//d' "$TARGET/debug/SBEONLINE.html" + +:: Add header for table of contents +:: sed -i '.bak2' '//i\ +:: Table of Contents<\/h1>\ +:: ' "$TARGET/debug/SBEONLINE.html" + +:: Create separate online versions for production and test website by including appropriate link prefixes +:: sed 's,img src="media/,img src="https://www.fixtrading.org'$WPFOLDER',g' "$TARGET/debug/SBEONLINE.html" > "$TARGET/html/SBEONLINE_PROD.html" +:: sed s/www.fixtrading.org/www.technical-fixprotocol.org/ "$TARGET/html/SBEONLINE_PROD.html" > "$TARGET/html/SBEONLINE_TEST.html" +:: echo SBE ONLINE version created for PROD and TEST + +echo Compilation ended! diff --git a/v1-0-STANDARD/doc/SBE.sh b/v1-0-STANDARD/doc/SBE.sh new file mode 100755 index 0000000..c9f97b6 --- /dev/null +++ b/v1-0-STANDARD/doc/SBE.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +echo Compilation started... +# Script is expected to start running in the folder where it is located (together with the source files) +SOURCE="$PWD" +# There is only one disclaimer and style docx file for all FIX Technical Standards and it is stored with the FIX Session Layer +# Repository has local copies with the specific names and dates of the standard +DISCLAIMER="FIXDisclaimerTechStd.md" +STYLE="FIX_TechStd_Style_MASTER.docx" +TARGET="$SOURCE/target" +YAML="$SOURCE/SBE.yaml" +FILES="01Introduction.md 02FieldEncoding.md 03MessageStructure.md 04MessageSchema.md 05SchemaExtensionMechanism.md 06UsageGuidelines.md 07Examples.md" +WPFOLDER="/wp-content/uploads/2020/03/" + +mkdir -p $TARGET $TARGET/docx $TARGET/html $TARGET/debug + +# Create FIX document version with disclaimer +pandoc "$DISCLAIMER" $FILES -o "$TARGET/docx/Simple_Binary_Encoding_V1.0_with_Errata.docx" --reference-doc="$STYLE" --metadata-file="$YAML" --toc --toc-depth=4 +echo SBE document version created for FIX + +# Create ISO JTC1 document version with copyright etc. +JTC1YAML="$SOURCE/SBE_JTC1.yaml" +JTC1STYLE="JTC1_TechStd_Style_MASTER.docx" +JTC1COPYRIGHT="JTC1Copyright.md" +JTC1FOREWORD="JTC1Foreword.md" +JTC1INTRO="JTC1Intro.md" +JTC1BIBLIO="JTC1Biblio.md" +pandoc "$JTC1COPYRIGHT" "$JTC1FOREWORD" "$JTC1INTRO" $FILES "$JTC1BIBLIO" -o "$TARGET/docx/JTC1Simple_Binary_Encoding_V1.0_with_Errata.docx" --reference-doc="$JTC1STYLE" --metadata-file="$JTC1YAML" --filter pandoc-plantuml --toc --toc-depth=3 +echo SBE document version created for JTC1 + +# Create ISO document version with copyright etc. (disabled) +# ISOYAML="$SOURCE/SBE_ISO.yaml" +# ISOSTYLE="ISO_TechStd_Style_MASTER.docx" +# ISOCOPYRIGHT="ISOCopyright.md" +# ISOFOREWORD="ISOForeword.md" +# ISOINTRO="ISOIntro.md" +# ISOBIBLIO="ISOBiblio.md" +# pandoc "$ISOCOPYRIGHT" "$ISOFOREWORD" "$ISOINTRO" $FILES "$ISOBIBLIO" -o "$TARGET/docx/ISOSimple_Binary_Encoding_V1.0_with_Errata.docx" --reference-doc="$ISOSTYLE" --metadata-file="$ISOYAML" --filter pandoc-plantuml --toc --toc-depth=3 +# echo SBE document version created for ISO + +# Create base online version without disclaimer +pandoc $FILES -o "$TARGET/debug/SBEONLINE.html" -s --metadata-file="$YAML" --toc --toc-depth=2 + +# Remove title as it is redundant to page header +sed -i '.bak1' '//d' "$TARGET/debug/SBEONLINE.html" + +# Add header for table of contents +sed -i '.bak2' '//i\ +Table of Contents<\/h1>\ +' "$TARGET/debug/SBEONLINE.html" + +# Create separate online versions for production and test website by including appropriate link prefixes +sed 's,img src="media/,img src="https://www.fixtrading.org'$WPFOLDER',g' "$TARGET/debug/SBEONLINE.html" > "$TARGET/html/SBEONLINE_PROD.html" +sed s/www.fixtrading.org/www.technical-fixprotocol.org/ "$TARGET/html/SBEONLINE_PROD.html" > "$TARGET/html/SBEONLINE_TEST.html" +echo SBE ONLINE version created for PROD and TEST + +echo Compilation ended! diff --git a/v1-0-STANDARD/doc/SBE.yaml b/v1-0-STANDARD/doc/SBE.yaml new file mode 100644 index 0000000..ef1fec5 --- /dev/null +++ b/v1-0-STANDARD/doc/SBE.yaml @@ -0,0 +1,12 @@ +--- +title: Simple Binary Encoding (SBE) +subtitle: Technical Specification +author: +- "Version 1.0 with Errata -- Technical Standard -- November 2020" +- "\x0D" +- "THIS DOCUMENT IS THE FINAL VERSION OF A FIX TECHNICAL STANDARD. THIS VERSION HAS BEEN" +- "APPROVED BY THE GLOBAL TECHNICAL COMMITTEE AS THE FINAL STEP IN CREATING A NEW FIX" +- "TECHNICAL STANDARD OR A NEW VERSION OF AN EXISTING FIX TECHNICAL STANDARD. POTENTIAL" +- "ADOPTERS ARE STRONGLY ENCOURAGED TO USE ONLY THE FINAL VERSION. EXISTING ADOPTERS ARE" +- "STRONGLY ENCOURAGED TO UPGRADE TO THE FINAL VERSION." +--- diff --git a/v1-0-STANDARD/doc/SBE_ISO.yaml b/v1-0-STANDARD/doc/SBE_ISO.yaml new file mode 100644 index 0000000..143b7a4 --- /dev/null +++ b/v1-0-STANDARD/doc/SBE_ISO.yaml @@ -0,0 +1,9 @@ +--- +title: "Financial Services -- Financial Information eXchange -- Simple Binary Encoding" +subtitle: "DIS stage" +author: +- "\x0D" +- Warning for WDs and CDs +- This document is not an ISO International Standard. It is distributed for review and comment. It is subject to change without notice and may not be referred to as an International Standard. +- Recipients of this draft are invited to submit, with their comments, notification of any relevant patent rights of which they are aware and to provide supporting documentation. +--- diff --git a/v1-0-STANDARD/doc/SBE_JTC1.yaml b/v1-0-STANDARD/doc/SBE_JTC1.yaml new file mode 100644 index 0000000..fa5d2a4 --- /dev/null +++ b/v1-0-STANDARD/doc/SBE_JTC1.yaml @@ -0,0 +1,9 @@ +--- +title: "Financial Services -- Financial Information eXchange -- Simple Binary Encoding" +subtitle: "DIS stage" +author: +- "\x0D" +- Warning for WDs and CDs +- This document is not an ISO/IEC International Standard. It is distributed for review and comment. It is subject to change without notice and may not be referred to as an International Standard. +- Recipients of this draft are invited to submit, with their comments, notification of any relevant patent rights of which they are aware and to provide supporting documentation. +--- diff --git a/v1-0-STANDARD/doc/publication/SBEONLINE_PROD_with_20180727_errata.html b/v1-0-STANDARD/doc/publication/SBEONLINE_PROD_with_20180727_errata.html new file mode 100644 index 0000000..893fae8 --- /dev/null +++ b/v1-0-STANDARD/doc/publication/SBEONLINE_PROD_with_20180727_errata.html @@ -0,0 +1,3884 @@ + + + + + + + + + + + + + + Simple Binary Encoding (SBE) + + + + + +Simple Binary Encoding (SBE) +Technical Specification +Version 1.0 with Errata – Technical Standard – July 27, 2018 + +THIS DOCUMENT IS THE FINAL VERSION OF A FIX TECHNICAL STANDARD. THIS VERSION HAS BEEN +APPROVED BY THE GLOBAL TECHNICAL COMMITTEE AS THE FINAL STEP IN CREATING A NEW FIX +TECHNICAL STANDARD OR A NEW VERSION OF AN EXISTING FIX TECHNICAL STANDARD. POTENTIAL +ADOPTERS ARE STRONGLY ENCOURAGED TO USE ONLY THE FINAL VERSION. EXISTING ADOPTERS ARE +STRONGLY ENCOURAGED TO UPGRADE TO THE FINAL VERSION. + + + +Introduction + +Binary type system +Design principles +Message schema +Glossary +Documentation +References + +Field Encoding + +Field aspects +FIX data type summary +Common field schema attributes +Integer encoding +Decimal encoding +Float encoding +String encodings +Data encodings +MonthYear encoding +Date and time encoding +Local date encoding +Local time encoding +Enumeration encoding +Multi-value choice encoding +Field value validation + +Message Structure + +Message Framing +SBE Message Encoding Header +Message Body +Repeating Groups +Sequence of message body elements +Message structure validation + +Message Schema + +XML schema for SBE message schemas +XML namespace +Name convention +Root element +Data encodings +Message template +Field attributes +Repeating group schema +Schema validation +Reserved element names + +Schema Extension Mechanism + +Objective +Message schema features for extension +Wire format features for extension +Comaptibility strategy +Message schema extension example + +Usage Guidelines + +Identifier encodings + +Examples + +Flat, fixed-length message +Message with a repeating group +Message with a variable-length field + + + +Introduction +FIX Simple Binary Encoding (SBE) targets high performance trading systems. It is optimized for low latency of encoding and decoding while keeping bandwidth utilization reasonably small. For compatibility, it is intended to represent all FIX semantics. +This encoding specification describes the wire protocol for messages. Thus, it provides a standard for interoperability between communicating parties. Users are free to implement the standard in a way that best suits their needs. +The encoding standard is complimentary to other FIX standards for session protocol and application level behavior. +The Technical Specification is split into the following sections: + +Introduction +Field Encoding +Message Structure +Message Schema +Schema Extension Mechanism +Usage Guidelines +Examples + +Binary type system +In order to support traditional FIX semantics, all the documented field types are supported. However, instead of printable character representations of tag-value encoding, the type system binds to native binary data types, and defines derived types as needed. +The binary type system has been enhanced in these ways: + +Provides a means to specify precision of decimal numbers and timestamps, as well as valid ranges of numbers. +Differentiates fixed-length character arrays from variable-length strings. Allows a way to specify the minimum and maximum length of strings that an application can accept. +Provides a consistent system of enumerations, Boolean switches and multiple-choice fields. + +Design principles +The message design strives for direct data access without complex transformations or conditional logic. This is achieved by: + +Usage of native binary data types and simple types derived from native binaries, such as prices and timestamps. +Preference for fixed positions and fixed length fields, supporting direct access to data and avoiding the need for management of heaps of variable-length elements which must be sequentially processed. + +Message schema +This standard describes how fields are encoded and the general structure of messages. The content of a message type is specified by a message schema. A message schema tells which fields belong to a message and their location within a message. Additionally, the metadata describes valid value ranges and information that need not be sent on the wire, such as constant values. +Message schemas may be based on standard FIX message specifications, or may be customized as needed by agreement between counterparties. +Glossary +Data type - A field type with its associated encoding attributes, including backing primitive types and valid values or range. Some types have additional attributes, e.g. epoch of a date. +Encoding - a message format for interchange. The term is commonly used to mean the conversion of one data format to another, such as text to binary. However, Simple Binary Encoding strives to use native binary data types in order to make conversion unnecessary, or at least trivial. Encoding also refers to the act of formatting a message, as opposed to decoding. +Message schema - metadata that specifies messages and their data types and identifiers. Message schemas may be disseminated out of band. For Simple Binary Encoding, message schemas are expressed as an XML document that conforms to an XML schema that is published as part of this standard. +Message template - metadata that specifies the fields that belong to one particular message type. A message template is contained by a message schema. +Session protocol - a protocol concerned with the reliable delivery of messages over a transport. FIX protocol makes a distinction between session protocol and the encoding of a message payload, as described by this document. See the specifications section of FIX protocol web site for supported protocols. The original FIX session protocol is known as FIXT. +XML schema - defines the elements and attributes that may appear in an XML document. The SBE message schema is defined in W3C (XSD) schema language since it is the most widely adopted format for XML schemas. +Documentation +This document explains: + +The binary type system for field encoding +Message structure, including field arrangement, repeating groups, and relationship to a message header that may be provided by a session protocol. +The Simple Binary Encoding message schema. + +Specification terms +These key words in this document are to be interpreted as described in Internet Engineering Task Force RFC2119. These terms indicate an absolute requirement for implementations of the standard: “must”, or “required”. +This term indicates an absolute prohibition: “must not”. +These terms indicate that a feature is allowed by the standard but not required: “may”, “optional”. An implementation that does not provide an optional feature must be prepared to interoperate with one that does. +These terms give guidance, recommendation or best practices: “should” or “recommended”. A recommended choice among alternatives is described as “preferred”. +These terms give guidance that a practice is not recommended: “should not” or “not recommended”. +Document format +In this document, these formats are used for technical specifications and data examples. +This is a sample encoding specification +<type name="short" primitiveType="int16" semanticType="int" /> +This is sample data as it would be transmitted on the wire +10270000 +References +Related FIX Standards +Simple Open Framing Header, FIX Protocol, Limited. Version 1.0 Draft Standard specification has been published at http://www.fixtradingcommunity.org/ +For FIX semantics, see the current FIX message specification, which is currently FIX 5.0 Service Pack 2 with Extension Packs. +Dependencies on other standards +SBE is dependent on several industry standards. Implementations must conform to these standards to interoperate. Therefore, they are normative for SBE. +IEEE 754-2008 A Standard for Binary Floating-Point Arithmetic +ISO 639-1:2002 Codes for the representation of names of languages - Part 1: Alpha-2 code +ISO 3166-1:2013 Codes for the representation of names of countries and their subdivisions - Part 1: Country codes +ISO 4217:2015 Codes for the representation of currencies and funds +ISO 8601:2004 Data elements and interchange formats - Information interchange - Representation of dates and times +ISO 10383:2012 Securities and related financial instruments - Codes for exchanges and market identification (MIC) +XML 1.1 schema standards are located here W3C XML Schema +Field Encoding +Field aspects +A field is a unit of data contained by a FIX message. Every field has the following aspects: semantic data type, encoding, and metadata. They will be specified in more detail in the sections on data type encoding and message schema but are introduced here as an overview. +Semantic data type +The FIX semantic data type of a field tells a data domain in a broad sense, for example, whether it is numeric or character data, or whether it represents a time or price. Simple Binary Encoding represents all of the semantic data types that FIX protocol has defined across all encodings. In message specifications, FIX data type is declared with attribute semanticType. See the section 2.2 below for a listing of those FIX types. +Encoding +Encoding tells how a field of a specific data type is encoded on the wire. An encoding maps a FIX data type to either a simple, primitive data type, such as a 32 bit signed integer, or to a composite type. A composite type is composed of two or more simple primitive types. For example, the FIX data type Price is encoded as a decimal, a composite type containing a mantissa and an exponent. Note that many fields may share a data type and an encoding. The sections that follow explain the valid encodings for each data type. +Metadata +Field metadata, part of a message schema, describes a field to application developers. Elements of field metadata are: + +Field ID, also known as FIX tag, is a unique identifier of a field for semantic purposes. For example, tag 55 identifies the Symbol field of an instrument. +Field name, as it is known in FIX specifications +The FIX semantic data type and encoding type that it maps to +Valid values or data range accepted +Documentation + +Metadata is normally not sent on the wire with Simple Binary Encoding messages. It is necessary to possess the message schema that was used to encode a message in order to decode it. In other words, Simple Binary Encoding messages are not self-describing. Rather, message schemas are typically exchanged out-of-band between counterparties. +See section 4 below for a detailed message schema specification. +Field presence +By default, fields are assumed to be required in a message. However, fields may be specified as optional. To indicate that a value is not set, a special null indicator value is sent on the wire. The null value varies according to data type and encoding. Global defaults for null value may be overridden in a message schema by explicitly specifying the value that indicates nullness. +Alternatively, fields may be specified as constant. In which case, the data is not sent on the wire, but may be treated as constants by applications. +Default value +Default value handling is not specified by the encoding layer. A null value of an optional field does not necessarily imply that a default value should be applied. Rather, default handling is left to application layer specifications. +FIX data type summary +FIX semantic types are mapped to binary field encodings as follows. See sections below for more detail about each type. +Schema attributes may restrict the range of valid values for a field. See Common field schema attributes below. + + + + + + + + + +FIX semantic type +Binary type +Section +Description + + + + +int +Integer encoding +2.4 +An integer number + + +Length +Integer encoding +2.4 +Field length in octets. Value must be non-negative. + + +TagNum +Integer encoding +2.4 +A field’s tag number. Value must be positive. + + +SeqNum +Integer encoding +2.4 +A field representing a message sequence number. Value must be positive + + +NumInGroup +Group dimension encoding +3.4.8 +A counter representing the number of entries in a repeating group. Value must be positive. + + +DayOfMonth +Integer encoding +2.4 +A field representing a day during a particular month (values 1 to 31). + + +Qty +Decimal encoding +2.5 +A number representing quantity of a security, such as shares. The encoding may constrain values to integers, if desired. + + +float +Float encoding +2.5 +A real number with binary representation of specified precision + + +Price +Decimal encoding +2.5 +A decimal number representing a price + + +PriceOffset +Decimal encoding +2.5 +A decimal number representing a price offset, which can be mathematically added to a Price. + + +Amt +Decimal encoding +2.5 +A field typically representing a Price times a Qty. + + +Percentage +Decimal encoding +2.5 +A field representing a percentage (e.g. 0.05 represents 5% and 0.9525 represents 95.25%). + + +char +Character +2.7.1 +Single US-ASCII character value. Can include any alphanumeric character or punctuation. All char fields are case sensitive (i.e. m != M). + + +String +Fixed-length character array +2.7.2 +A fixed-length character array of ASCII encoding + + +String +Variable-length data encoding +2.7.3 +Alpha-numeric free format strings can include any character or punctuation. All String fields are case sensitive (i.e. morstatt != Morstatt). ASCII encoding. + + +String—EncodedText +String encoding +2.7.3 +Non-ASCII string. The character encoding may be specified by a schema attribute. + + +XMLData +String encoding +2.7.3 +Variable-length XML. Must be paired with a Length field. + + +data +Fixed-length data +2.8.1 +Fixed-length non-character data + + +data +Variable-length data encoding +2.8.2 +Variable-length data. Must be paired with a Length field. + + +Country +Fixed-length character array; size = 2 or a subset of values may use Enumeration encoding +2.7.2 +ISO 3166-1:2013 Country code + + +Currency +Fixed-length character array; size = 3 or a subset of values may use Enumeration encoding +2.7.2 +ISO 4217:2015 Currency code (3 character) + + +Exchange +Fixed-length character array; size = 4 or a subset of values may use Enumeration encoding +2.7.2 +ISO 10383:2012 Market Identifier Code (MIC) + + +Language +Fixed-length character array; size = 2 or a subset of values may use Enumeration encoding +2.7.2 +National language - uses ISO 639-1:2002 standard + + +Implicit enumeration—char or int +Enumeration encoding +2.12 +A single choice of alternative values + + +Boolean +Boolean encoding +2.12.6 +Values true or false + + +MultipleCharValue +Multi-value choice encoding +2.13 +Multiple choice of a set of values + + +MultipleStringValue +Multi-value choice encoding. String choices must be mapped to int values. +2.13 +Multiple choice of a set of values + + +MonthYear +MonthYear encoding +2.8 +A flexible date format that must include month and year at least, but may also include day or week. + + +UTCTimestamp +Date and time encoding +2.9 +Time/date combination represented in UTC (Universal Time Coordinated, also known as “GMT”) + + +UTCTimeOnly +Date and time encoding +2.9 +Time-only represented in UTC (Universal Time Coordinated, also known as “GMT”) + + +UTCDateOnly +Date and time encoding +2.9 +Date represented in UTC (Universal Time Coordinated, also known as “GMT”) + + +LocalMktDate +Local date encoding +2.9 +Local date(as oppose to UTC) + + +TZTimeOnly +TZTimeOnly +2.11.3 +Time of day + + +TZTimestamp +TZTimestamp +2.11.1 +Time/date combination representing local time with an offset to UTC to allow identification of local time and timezone offset of that time. The representation is based on ISO 8601:2004 + + + +The FIX semantic types listed above are spelled and capitalized exactly as they are in the FIX repository from which official FIX documents and references are derived. +Common field schema attributes +Schema attributes alter the range of valid values for a field. Attributes are optional unless specified otherwise. + + + + + + + +Schema attribute +Description + + + + +presence=required +The field must always be set. This is the default presence. Mutually exclusive with nullValue. + + +presence=constant +The field has a constant value that need not be transmitted on the wire. Mutually exclusive with value attributes. + + +presence=optional +The field need not be populated. A special null value indicates that a field is not set. The presence attribute may be specified on either on a field or its encoding. + + +nullValue +A special value that indicates that an optional value is not set. See encodings below for default nullValue for each type. Mutually exclusive with presence=required and constant. + + +minValue +The lowest valid value of a range. Applies to scalar data types, but not to String or data types. + + +maxValue +The highest valid value of a range (inclusive unless specified otherwise). Applies to scalar data types, but not to String or data types. + + +semanticType +Tells the FIX semantic type of a field or encoding. It may be specified on either a field or its encoding. + + + +Inherited attributes +The attributes listed above apply to a field element or its encoding (wire format). Any attributes specified on an encoding are inherited by fields that use that encoding. +Non-FIX types +Encodings may be added to SBE messages that do not correspond to listed FIX data types. In that case, the encoding and fields that use the encoding will not have a semanticType attribute. +Integer encoding +Integer encodings should be used for cardinal or ordinal number fields. Signed integers are encoded in a two’s complement binary format. +Primitive type encodings +Numeric data types may be specified by range and signed or unsigned attribute. Integer types are intended to convey common platform primitive data types as they reside in memory. An integer type should be selected to hold the maximum range of values that a field is expected to hold. + + + +Primitive type +Description +Length (octets) + + + + +int8 +Signed byte +1 + + +uint8 +Unsigned byte / single-byte character +1 + + +int16 +16-bit signed integer +2 + + +uint16 +16-bit unsigned integer +2 + + +int32 +32-bit signed integer +4 + + +uint32 +32-bit unsigned integer +4 + + +int64 +64-bit signed integer +8 + + +uint64 +64-bit unsigned integer +8 + + + +Range attributes for integer fields +The default data ranges and null indicator are listed below for each integer encoding. +A message schema may optionally specify a more restricted range of valid values for a field. +For optional fields, a special null value is used to indicate that a field value is not set. The default null indicator may also be overridden by a message schema. +Required and optional fields of the same primitive type have the same data range. The null value must not be set for a required field. + + + +Schema attribute +int8 +uint8 +int16 +uint16 +int32 +uint32 +int64 +uint64 + + + + +minValue +–127 +0 +–32767 +0 +–231 + 1 +0 +–263 + 1 +0 + + +maxValue +127 +254 +32767 +65534 +231 – 1 +232 – 2 +263 – 1 +264 – 2 + + +nullValue +–128 +255 +–32768 +65535 +–231 +232 – 1 +–263 +264 – 1 + + + +Byte order +The byte order of integer fields, and for derived types that use integer components, is specified globally in a message schema. Little-Endian order is the default encoding, meaning that the least significant byte is serialized first on the wire. +See section 4.3.1 for specification of message schema attributes, including byteOrder. Message schema designers should specify the byte order most appropriate to their system architecture and that of their counterparties. +Integer encoding specifications +By nature, integers map to simple encodings. These are valid encoding specifications for each of the integer primitive types. +<type name="int8" primitiveType="int8" /> +<type name="int16" primitiveType="int16" /> +<type name="int32" primitiveType="int32" /> +<type name="int64" primitiveType="int64" /> +<type name="uint8" primitiveType="uint8" /> +<type name="uint16" primitiveType="uint16" /> +<type name="uint32" primitiveType="uint32" /> +<type name="uint64" primitiveType="uint64" /> +Examples of integer fields +Examples show example schemas and encoded bytes on the wire as hexadecimal digits in Little-Endian byte order. +Example integer field specification +<field type="uint32" name="ListSeqNo" id="67" semanticType="int" + description="Order number within the list" /> +Value on the wire - uint32 value decimal 10,000, hexadecimal 2710. +10270000 +Optional field with a valid range 0-6 +<type name="range06" primitiveType="uint8" maxValue="6" + presence="optional" nullValue="255" /> +<field type="range06" name="MaxPriceLevels" id="1090" + semanticType="int"/> +Wire format of uint8 value decimal 3. +03 +Sequence number field with integer encoding +<field type="uint64" name="MsgSeqNum" id="34" + semanticType="SeqNum" /> +Wire format of uint64 value decimal 100,000,000,000, hexadecimal 174876E800. +00e8764817000000 +Wire format of uint16 value decimal 10000, hexadecimal 2710. +1027 +Wire format of uint32 null value 232 - 1 +ffffffff +Decimal encoding +Decimal encodings should be used for prices and related monetary data types like PriceOffset and Amt. +FIX specifies Qty as a float type to support fractional quantities. However, decimal encoding may be constrained to integer values if that is appropriate to the application or market. +Composite encodings +Prices are encoded as a scaled decimal, consisting of a signed integer mantissa and signed exponent. For example, a mantissa of 123456 and exponent of -4 represents the decimal number 12.3456. +Mantissa +Mantissa represents the significant digits of a decimal number. Mantissa is a commonly used term in computing, but it is properly known in mathematics as significand or coefficient. +Exponent +Exponent represents scale of a decimal number as a power of 10. +Floating point and fixed point encodings +A floating-point decimal transmits the exponent on the wire while a fixed-point decimal specifies a fixed exponent in a message schema. A constant negative exponent specifies a number of assumed decimal places to the right of the decimal point. +Implementations should support both 32 bit and 64 bit mantissa. The usage depends on the data range that must be represented for a particular application. It is expected that an 8 bit exponent should be sufficient for all FIX uses. + + + +Encoding type +Description +Backing primitives +Length (octets) + + + + +decimal +Floating-point decimal +Composite: int64 mantissa, int8 exponent +9 + + +decimal64 +Fixed-point decimal +int64 mantissa, constant exponent +8 + + +decimal32 +Fixed-point decimal +int32 mantissa, constant exponent +4 + + + +Optionally, implementations may support any other signed integer types for mantissa and exponent. +Range attributes for decimal fields +The default data ranges and null indicator are listed below for each decimal encoding. +A message schema may optionally specify a more restricted range of valid values for a field. For optional fields, a special mantissa value is used to indicate that a field value is null. + + + +Schema attribute +decimal +decimal64 +decimal32 + + + + +exponent range +–128 to 127 +–128 to 127 +–128 to 127 + + +mantissa range +–263 + 1 to 263 – 1 +–263 + 1 to 263 – 1 +–231 + 1 to 231 – 1 + + +minValue +(–263 + 1) * 10127 +(–263 + 1) * 10127 +(–231 + 1) * 10127 + + +maxValue +(263 – 1) * 10127 +(263 – 1) * 10127 +(231 – 1) * 10127 + + +nullValue +mantissa=–263, exponent=–128 +mantissa =–263 +mantissa =–231 + + + +Encoding specifications for decimal types +Decimal encodings are composite types, consisting of two subfields, mantissa and exponent. The exponent may either be serialized on the wire or may be set to constant. A constant exponent is a way to specify an assumed number of decimal places. +Decimal encoding specifications that an implementation must support +<composite name="decimal" > + <type name="mantissa" primitiveType="int64" /> + <type name="exponent" primitiveType="int8" /> +</composite> + +<composite name="decimal32" > + <type name="mantissa" primitiveType="int32" /> + <type name="exponent" primitiveType="int8" + presence="constant">-2</type> +</composite> + +<composite name="decimal64"> + <type name="mantissa" primitiveType="int64" /> + <type name="exponent" primitiveType="int8" + presence="constant">-2</type> +</composite> +Composite encoding padding +When both mantissa and exponent are sent on the wire for a decimal, the elements are packed by default. However, byte alignment may be controlled by specifying offset of the exponent within the composite encoding. See section 4.4.4.3 below. +Examples of decimal fields +Examples show encoded bytes on the wire as hexadecimal digits, little-endian. +FIX Qty data type is a float type, but a decimal may be constrained to integer values by setting exponent to zero. +<composite name="intQty32" semanticType="Qty"> + <type name="mantissa" primitiveType="int32" /> + <type name="exponent" primitiveType="int8" + presence="constant">0</type> +</composite> +Field inherits semanticType from encoding +<field type="intQty32" name="OrderQty" id="38" + description="Total number of shares" /> +Wire format of decimal 123.45 with 2 significant decimal places. +3930000000000000fe +Wire format of decimal64 123.45 with 2 significant decimal places. Schema attribute exponent = -2 +3930000000000000 +Wire format of decimal32 123.45 with 2 significant decimal places. Schema attribute exponent = -2 +39300000 +Float encoding +Binary floating point encodings are compatible with IEEE Standard for Floating-Point Arithmetic (IEEE 754-2008). They should be used for floating point numeric fields that do not represent prices or monetary amounts. Examples include interest rates, volatility and dimensionless quantities such as ratios. On the other hand, decimal prices should be encoded as decimals; see section 2.5 above. +Primitive types +Both single and double precision encodings are supported as primitive data types. See the IEEE 754-2008 standard for ranges and details of the encodings. + + + +Primitive type +Description +IEEE 754-2008 format +Length (octets) + + + + +float +Single precision floating point +binary32 +4 + + +double +Double precision floating point +binary64 +8 + + + +Null values +For both float and double precision encodings, null value of an optional field is represented by the Not-a-Number format (NaN) of the standard encoding. Technically, it indicated by the so-called quiet NaN. +Byte order +Like integer encodings, floating point encodings follow the byte order specified by message schema. See section 4.3.1 for specification of message schema attributes, including byteOrder. +Float encoding specifications +These are valid encoding specifications for each of the floating point primitive types. +<type name="float" primitiveType="float" /> +<type name="double" primitiveType="double" /> +Examples of floating point fields +Examples show encoded bytes on the wire as hexadecimal digits, little-endian. +A single precision ratio +<type name="ratio" primitiveType="float" /> + +<field type="ratio" name="CurrencyRatio" id="1382" + semanticType="float"/> +Wire format of float 255.678 +91ad7f43 +Wire format of double 255.678 +04560e2db2f56f40 +String encodings +Character data may either be of fixed size or variable size. In Simple Binary Encoding, fixed-length fields are recommended in order to support direct access to data. Variable-length encoding should be reserved for character strings that cannot be constrained to a specific size. It may also be used for non-ASCII encoded strings. +Character +Character fields hold a single character. They are most commonly used for field with character code enumerations. See section 2.12 below for discussion of enum fields. + + + +FIX data type +Description +Backing primitive +Length (octet) + + + + +char +A single US-ASCII character +char +1 + + + +Range attributes for char fields +Valid values of a char field are printable characters of the US-ASCII character set (codes 20 to 7E hex.) The implicit nullValue is the NUL control character (code 0). + + + +Schema attribute +char + + + + +minValue +hex 20 + + +maxValue +hex 7e + + +nullValue +0 + + + +Encoding of char type +This is the standard encoding for char type. +<type name="char" primitiveType="char" semanticType="char" /> +Wire format of char encoding of “A” (ASCII value 65, hexadecimal 41) +41 +Fixed-length character array +Character arrays are allocated a fixed space in a message, supporting direct access to fields. A fixed size character array is distinguished from a variable length string by the presence of a length schema attribute or a constant attribute. + + + + + + + + + + +FIX data type +Description +Backing primitives +Length (octets) +Required schema attribute + + + + +String +character array +Array of char of specified length, delimited by NUL character if a string is shorter than the length specified for a field. +Specified by length attribute +length (except may be inferred from a constant value, if present). + + + +A length attribute set to zero indicates variable length. See section 2.7.3 below for variable-length data encoding. +Encoding specifications for fixed-length character array +A fixed-length character array encoding must specify primitiveType=“char” and a length attribute is required. +Range attributes minValue and maxValue do not apply to fixed-length character arrays. +US-ASCII is the default encoding of character arrays to conform to usual FIX values. The characterEncoding attribute may be specified to override encoding. +Examples of fixed-length character arrays +A typical string encoding specification +<type name="string6" primitiveType="char" semanticType="String" + length="6" /> + +<field type="string6" name="Symbol" id="55" /> +Wire format of a character array in character and hexadecimal formats +M S F T +4d5346540000 +A character array constant specification +<type name="EurexMarketID" semanticType="Exchange" + primitiveType="char" length="4" description="MIC code" + presence="constant">XEUR</type> + +<field type="EurexMarketID" name="MarketID" id="1301" /> +Variable-length string encoding +Variable-length string encoding is used for variable length ASCII strings or embedded non-ASCII character data (like EncodedText field). A separate length field coveys the size of the field. +On the wire, length immediately precedes the data. +The length subfield may not be null, but may be set to zero for an empty string. In that case, no space is reserved for the data. No distinction is made at an encoding layer between an empty string and a null string. Semantics of an empty variable-length string should be specified at an application layer. + + + + + + + + + +FIX data type +Description +Backing primitives +Length (octets) + + + + +Length +The length of variable data in octets +primitiveType=“uint8” or “uint16” May not hold null value. +1 or 2 + + +data +Raw data +Array of octet of size specified in associated Length field. The data field itself should be specified as variable length. primitiveType=“uint8” length=“0” indicates variable length +variable + + + +Optionally, implementations may support any other unsigned integer types for length. +Range attributes for string Length + + + +Schema attribute +length uint8 +length uint16 +data + + + + +minValue +0 +0 +N/A + + +maxValue +254 +65534 +N/A + + + +If the Length element has minValue and maxValue attributes, it specifies the minimum and maximum length of the variable-length data. +Range attributes minValue , maxValue, and nullValue do not apply to the data element. +If a field is required, both the Length and data fields must be set to a “required” attribute. +Encoding specifications for variable-length string +Variable length string is encoded as a composite type, consisting of a length sub field and data subfield. The length attribute of the varData element is set to zero in the XML message schema as special value to indicate that the character data is of variable length. +To map an SBE data field specification to traditional FIX, the field ID of a data field is used. Its associated length is implicitly contained by the composite type rather than specified as a separate field. +Encoding specification for variable length data up to 65535 octets +<composite name="varString" description="Variable-length string"> + <type name="length" primitiveType="uint16" semanticType="Length"/> + <type name="data" length="0" primitiveType="uint8" + semanticType="data" characterEncoding="UTF-16"/> +</composite> + +<data name="SecurityDesc" id="107" type="varString"/> +The characterEncoding attribute tells which variable-sized encoding is used if the data field represents encoded text. UTF-8 is the recommended encoding, but there is no default in the XML schema +Example of a variable-length string field +Example shows encoded bytes on the wire. +Wire format of variable-length String in character and hexadecimal formats, preceded by uint16 length of 4 octets in little-endian byte order +M S F T +04004d534654 +Data encodings +Raw data is opaque to SBE. In other words, it is not constrained by any value range or structure known to the messaging layer other than length. Data fields simply convey arrays of octets. +Data may either be of fixed-length or variable-length. In Simple Binary Encoding, fixed-length data encoding may be used for data of predetermined length, even though it does not represent a FIX data type. Variable-length encoding should be reserved for raw data when its length is not known until run-time. +Fixed-length data +Data arrays are allocated as a fixed space in a message, supporting direct access to fields. A fixed size array is distinguished from a variable length data by the presence of a length schema attribute rather than sending length on the wire. + + + + + + + + + + +FIX data type +Description +Backing primitives +Length (octets) +Required schema attribute + + + + +data +octet array +Array of uint8 of specified length. +Specified by length attribute +length + + + +Encoding specifications for fixed-length data +A fixed-length octet array encoding should specify primitiveType=“uint8” and a length attribute is required. +Data range attributes minValue and maxValue do not apply. +Since raw data is not constrained to a character set, characterEncoding attribute should not be specified. +Example of fixed-length data encoding +A fixed-length data encoding specification for a binary user ID +<type name="uuid" primitiveType="uint8" length="16" description="RFC 4122 compliant UUID"/> + +<field type="uuid" name="Username" id="553" /> +Variable-length data encoding +Variable-length data is used for variable length non-character data (such as RawData). A separate length field conveys the size of the field. On the wire, length immediately precedes the data. +The length subfield may not be null, but it may be set to zero. In that case, no space is reserved for the data. Semantics of an empty variable-length data element should be specified at an application layer. + + + + + + + + + +FIX data type +Description +Backing primitives +Length (octets) + + + + +Length +The length of variable data in octets +primitiveType=“uint8” or “uint16” May not hold null value. +1 or 2 + + +data +Raw data +Array of octet of size specified in associated Length field. The data field itself should be specified as variable length. primitiveType=“uint8” +variable + + + +Optionally, implementations may support any other unsigned integer types for length. +Range attributes for variable-length data Length + + + +Schema attribute +length uint8 +length uint16 +data + + + + +minValue +0 +0 +N/A + + +maxValue +254 +65534 +N/A + + + +If the Length field has minValue and maxValue attributes, it specifies the minimum and maximum length of the variable-length data. Data range attributes minValue , maxValue, and nullValue do not apply to a data field. +If a field is required, both the Length and data fields must be set to a “required” attribute. +Encoding specifications for variable-length data +Variable length data is encoded as composite type, consisting of a length sub field and data subfield. +To map an SBE data field specification to traditional FIX, the field ID of a data field is used. Its associated length is implicitly contained by the composite type rather than specified as a separate field. +Encoding specification for variable length data up to 65535 octets +<composite name="DATA" description="Variable-length data"> + <type name="length" primitiveType="uint16" semanticType="Length"/> + <type name="data" length="0" primitiveType="uint8" semanticType="data" /> +</composite> + +<data name="RawData" id="96" type="DATA"/> +Example of a data field +Example shows encoded bytes on the wire. +Wire format of data in character and hexadecimal formats, preceded by uint16 length of 4 octets in little-endian byte order +M S F T +04004d534654 +MonthYear encoding +MonthYear encoding contains four subfields representing respectively year, month, and optionally day or week. A field of this type is not constrained to one date format. One message may contain only year and month while another contains year, month and day in the same field, for example. +Values are distinguished by position in the field. Year and month must always be populated for a non-null field. Day and week are set to special value indicating null if not present. If Year is set to the null value, then the entire field is considered null. + + + +Subfield +Primitive type +Length (octets) +Null value + + + + +Year +uint16 +2 +65535 + + +Month (1-12) +uint8 +1 +— + + +Day of the month(1-31) optional +uint8 +1 +255 + + +Week of the month (1-5) optional +uint8 +1 +255 + + + +Composite encoding padding +The four subfields of MonthYear are packed at an octet level by default. However, byte alignment may be controlled by specifying offset of the elements within the composite encoding. See section 4.4.4.3 below. +Encoding specifications for MonthYear +MonthYear data type is based on a composite encoding that carries its required and optional elements. +The standard encoding specification for MonthYear +<composite name="monthYear" semanticType="MonthYear"> + <type name="year" primitiveType="uint16" presence="optional" + nullValue="65536" /> + <type name="month" primitiveType="uint8" minValue="1" maxValue="12" /> + <type name="day" primitiveType="uint8" minValue="1" maxValue="31" + presence="optional" nullValue="255" /> + <type name="week" description="week of month" primitiveType="uint8" + minValue="1" maxValue="5" presence="optional" nullValue="255" /> +</composite> +Example MonthYear field specification + +Wire format of MonthYear 2014 June week 3 as hexadecimal +de0706ff03 +Date and time encoding +Dates and times represent Coordinated Universal Time (UTC). This is the preferred date/time format, except where regulations require local time with time zone to be reported (see time zone encoding below). +Epoch +Each time type has an epoch, or start of a time period to count values. For timestamp and date, the standard epoch is the UNIX epoch, midnight January 1, 1970 UTC. +A time-only value may be thought of as a time with an epoch of midnight of the current day. Like current time, the epoch is also referenced as UTC. +Time unit +Time unit tells the precision at which times can be collected. Time unit may be serialized on the wire if timestamps are of mixed precision. On the other hand, if all timestamps have the same precision, then time unit may be set to a constant in the message schema. Then it need not be sent on the wire. + + + + + + + + + + +FIX data type +Description +Backing primitives +Length (octets) +Schema attributes + + + + +UTCTimestamp +UTC date/time Default: nanoseconds since Unix epoch Range Jan. 1, 1970 - July 21, 2554 +uint64 time +8 +epoch=”unix” (default) + + + +timeUnit = second or millisecond or microsecond or nanosecond May be constant +uint8 unit +1 + + + +UTCTimeOnly +UTC time of day only Default: nanoseconds since midnight today +uint64 time +8 + + + + +timeUnit = second or millisecond or microsecond or nanosecond May be constant +uint8 unit +1 + + + +UTCDateOnly +UTC calendar date Default: days since Unix epoch. Range: Jan. 1, 1970 - June 7, 2149 +uint16 +2 +epoch=”unix” (default) + + + +Encoding specifications for date and time +Time specifications use an enumeration of time units. See section 2.13 below for a fuller explanation of enumerations. +Enumeration of time units: +<enum name="TimeUnit" encodingType="uint8"> + <validValue name="second">0</validValue> + <validValue name="millisecond">3</validValue> + <validValue name="microsecond">6</validValue> + <validValue name="nanosecond">9</validValue> +</enum> +Timestamp with variable time units: +<composite name="UTCTimestamp" description="UTC timestamp with precision on the wire" semanticType="UTCTimestamp" > + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" /> +</composite> +Timestamp with constant time unit: +<composite name="UTCTimestampNanos" description="UTC timestamp with nanosecond precision" semanticType="UTCTimestamp" > + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" presence="constant" valueRef="TimeUnit.nanosecond" /> +</composite> +Time only with variable time units: +<composite name="UTCTime" description="Time of day with precision on the wire" semanticType="UTCTimeOnly" > + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" /> +</composite> +Time only with constant time unit: +<composite name="UTCTimeNanos" description="Time of day with millisecond precision" semanticType="UTCTimeOnly" > + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" presence="constant" valueRef="TimeUnit.millisecond" /> +</composite> +Date only specification: +<type name="date" primitiveType="uint16" semanticType="UTCDateOnly" /> +Examples of date/time fields +timestamp 14:17:22 Friday, October 4, 2024 UTC (20,000 days and 14 hours, 17 minutes and 22 seconds since the UNIX epoch) with default schema attributes +<composite name="UTCTimestampNanos" description="UTC timestamp with nanosecond precision" semanticType="UTCTimestamp" > +<type name="time" primitiveType="uint64" /> +<type name="unit" primitiveType="uint8" presence="constant" valueRef="TimeUnit.nanosecond" /> +</composite> +Wire format of UTCTimestamp with constant time unit in little-Endian byte order +4047baa145fb17 +time 10:24:39.123456000 (37,479 seconds and 123456000 nanoseconds since midnight UTC) with default schema attributes +<composite name="UTCTimeOnlyNanos" description="UTC time of day with nanosecond precision" semanticType="UTCTimeOnly" > + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" presence="constant" valueRef="TimeUnit.nanosecond" /> +</composite> +Wire format of UTCTimeOnly +10d74916220000 +date Friday, October 4, 2024 (20,000 days since UNIX epoch) with default schema attributes +<type name="date" primitiveType="uint16" semanticType="UTCDateOnly" /> +Wire format of UTCDateOnly +204e +Local date encoding +Local date is encoded the same as UTCDateOnly, but it represents local time at the market instead of UTC time. + + + + + + + + + + +FIX data type +Description +Backing primitives +Length (octets) +Schema attributes + + + + +LocalMktDate +Local calendar date Default: days since Unix epoch. Range: Jan. 1, 1970 - June 7, 2149 local time +uint16 +2 +epoch=”unix” (default) + + + +The standard encoding specification for LocalMktDate +<type name="localMktDate" primitiveType="uint16" semanticType="LocalMktDate" /> +Local time encoding +Time with time zone encoding should only be used when required by market regulations. Otherwise, use UTC time encoding (see above). +Time zone is represented as an offset from UTC in the ISO 8601:2004 format ±hhmm. +TZTimestamp encoding +A binary UTCTimestamp followed by a number representing the time zone indicator as defined in ISO 8601:2004. + + + + + + + + + + +FIX data type +Description +Backing primitives +Length (octets) +Schema attributes + + + + +TZTimestamp +date/time with timezone Default: nanoseconds since Unix epoch Range Jan. 1, 1970 - July 21, 2554 +uint64 +8 +epoch=”unix” (default) Represents Jan. 1, 1970 local time + + + +timeUnit = second or millisecond or microsecond or nanosecond May be constant +uint8 +1 + + + + +Time zone hour offset +int8 +1 +None + + + +Time zone minute offset +uint8 +1 +None + + + +Composite encoding padding +The subfields of TZTimestamp are packed at an octet level by default. However, byte alignment may be controlled by specifying offset of the elements within the composite encoding. See section 4.4.4.3 below. +Standard TZTimestamp encoding specification +<composite name="tzTimestamp" semanticType="TZTimestamp"> + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" /> + <!-- Sign of timezone offset is on hour subfield --> + <type name="timezoneHour" primitiveType="int8" minValue="-12" maxValue="14" /> + <type name="timezoneMinute" primitiveType="uint8" maxValue="59" /> +</composite> +Wire format of TZTimestamp 8:30 17 September 2013 with Chicago time zone offset (-6:00) +0050d489fea22413fa00 +TZTimeOnly encoding +A binary UTCTimeOnly followed by a number representing the time zone indicator as defined in ISO 8601:2004. +The time zone hour offset tells the number of hours different to UTC time. The time zone minute tells the number of minutes different to UTC. The sign telling ahead or behind UTC is on the hour subfield. + + + + + + + + + + +FIX data type +Description +Backing primitives +Length (octets) +Schema attributes + + + + +TZTimeOnly +Time of day only with time zone Default: nanoseconds since midnight today, local time +uint64 +8 +None + + + +timeUnit = second or millisecond or microsecond or nanosecond May be constant +uint8 +1 +None + + + +Time zone hour offset +int8 +1 +None + + + +Time zone minute offset +uint8 +1 +None + + + +Composite encoding padding +The subfields of TZTimeOnly are packed at an octet level by default. However, byte alignment may be controlled by specifying offset of the elements within the composite encoding. See section 4.4.4.3 below. +Standard TZTimeOnly encoding specification +<composite name="tzTimeOnly" semanticType="TZTimeOnly"> + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" /> + <!-- Sign of timezone offset is on hour subfield --> + <type name="timezoneHour" primitiveType="int8" + minValue="-12" maxValue="14" /> + <type name="timezoneMinute" primitiveType="uint8" minValue="0" + maxValue="59" /> +</composite> +Wire format of TZTimeOnly 8:30 with Chicago time zone offset (-6:00) +006c5ebe76000000fa00 +Enumeration encoding +An enumeration conveys a single choice of mutually exclusive valid values. +Primitive type encodings +An unsigned integer or character primitive type is selected to contain the number of choices. Implementations must support char and uint8 types. They may additionally support other unsigned integer types to allow more choices. + + + +Primitive type +Description +Length (octets) +Maximum number of choices + + + + +char +character +1 +95 + + +uint8 +8-bit unsigned integer +1 +255 + + + +Value encoding +If a field is of FIX data type char, then its valid values are restricted to US-ASCII printable characters. See section 2.7.1 above. +If the field is of FIX data type int, then a primitive integer data type should be selected that can contain the number of choices. For most cases, an 8 bit integer will be sufficient, allowing 255 possible values. +Enumerations of other data types, such as String valid values specified in FIX, should be mapped to an integer wire format in SBE. +Encoding specification of enumeration +In a message schema, the choices are specified a <validValue> members of an <enum>. An <enum> specification must contain at least one <validValue>. +The name and value of a validValue element must be unique within an enumeration. +An <enum> element must have an encodingType attribute to specify the type of its values. Two formats of encodingType are acceptable: + +In-line style: the value of encodingType is its primitive data type. +Reference style: the value of encodingType is the name of a <type> element that specifies the wire format. + +The length of a <type> associated to an enumeration must be 1. That is, enumerations should only be backed by scalar types, not arrays. +Enumeration examples +These examples use a char field for enumerated code values. +Example enum lists acceptable values and gives the underlying encoding, which in this case is char (in-line style) +<enum name="SideEnum" encodingType="char"> + <validValue name="Buy">1</validValue> + <validValue name="Sell">2</validValue> + <validValue name="SellShort">5</validValue> + <validValue name="SellShortExempt">6</validValue> + <!-- not all FIX values shown --> +</enum> +Reference to type: This specification is equivalent to the one above. +<type name="charEnumType" primitiveType="char"/> + <enum name="SideEnum" encodingType="charEnumType"> + <!-- valid values as above --> +</enum> +Side field specification references the enumeration type +<field name="Side" type="SideEnum" id="54" /> +Wire format of Side “Buy” code as hexadecimal +01 +Constant field of an enumeration value +A constant field may be specified as a value of an enumeration. The attribute valueRef is a cross-reference to validValue entry by symbolic name. +Example of a char field using a constant enum value +<enum name="PartyIDSourceEnum" encodingType="char"> + <validValue name="BIC">B</validValue> + <validValue name="GeneralIdentifier">C</validValue> + <validValue name="Proprietary">D</validValue> +</enum> + +<field type="PartyIDSourceEnum" name="PartyIDSource" id="447" + description="Party ID source is fixed" presence="constant" + valueRef="PartyIDSourceEnum.GeneralIdentifier" /> +Boolean encoding +A Boolean field is a special enumeration with predefined valid values: true and false. Like a standard enumeration, an optional Boolean field may have nullValue that indicates that the field is null (or not applicable). +Standard encoding specifications for required and optional Boolean fields +<enum name="booleanEnum" encodingType="uint8" semanticType="Boolean"> + <validValue name="false">0</validValue> + <validValue name="true">1</validValue> +</enum> + +<enum name="optionalBoolean" encodingType="uint8" semanticType="Boolean"> + <validValue name="false">0</validValue> + <validValue name="true">1</validValue> + <validValue name="nullValue">255</validValue> +</enum> +Example optional Boolean field +<field type="optionalBoolean" name="SolicitedFlag" id="377" /> +Wire format of true value as hexadecimal +01 +Wire format of false value as hexadecimal +00 +Wire format of null Boolean (or N/A) value as hexadecimal +ff +Multi-value choice encoding +A multi-value field conveys a choice of zero or more non-exclusive valid values. +Primitive type encodings +The binary encoding uses a bitset (a fixed-size sequence of bits, also known as bitmap, bit array or bit vector) to represent up to 64 possible choices. The encoding is backed by an unsigned integer. The smallest unsigned primitive type should be selected that can contain the number of valid choices. + + + +Primitive type +Description +Length (octets) +Maximum number of choices + + + + +uint8 +8-bit unsigned integer +1 +8 + + +uint16 +16-bit unsigned integer +2 +16 + + +uint32 +32-bit unsigned integer +4 +32 + + +uint64 +64-bit unsigned integer +8 +64 + + + +Like other integer-backed encodings, multi-value encodings follow the byte order specified by message schema when serializing to the wire. See section 4.3.1 for specification of message schema attributes, including byteOrder. +Value encoding +Each choice is assigned a bit of the primitive integer encoding, starting with the least significant bit. For each choice the value is selected or not, depending on whether it corresponding bit is set or cleared. +Any remaining unassigned bits in an octet should be cleared. +There is no explicit null value for multi-value choice encoding other than to set all bits off when no choices are selected. +Encoding specification of multi-value choice +In a message schema, the choices are specified as <choice> members of an <set> element. Choices are assigned values as an ordinal of bits in the bit set. The first Choice “0” is assigned the least significant bit; choice “1” is the second bit, and so forth. +The name and value (bit position) must be unique for element of a set. +A <set> element must have an encodingType attribute to specify the wire format of its values. Two formats of encodingType are recognized : + +In-line style: the value of encodingType is its primitive data type. +Reference style: the value of encodingType is the name of a <type> element that specifies the wire format. + +The length of a <type> associated to an bitset must be 1. That is, bitsets should not be specified as arrays. +Multi-value example +Example of a multi-value choice (was MultipleCharValue in tag-value encoding) Encoding type is in-line style. +<set name="FinancialStatusEnum" encodingType="uint8"> + <choice name="Bankrupt">0</choice> + <choice name="Pending delisting">1</choice> + <choice name="Restricted">2</choice> +</set> +Reference to type. This is equivalent to the example above. +<type name="u8Bitset" primitiveType="uint8"/> + +<set name="FinancialStatusEnum" encodingType="u8Bitset"> +<!--choices as above --> +</set> +A field using the multi-choice encoding +<field type="FinancialStatus" name="FinancialStatusEnum" + id="291" semanticType="MultipleCharValue"/> +Wire format of choices “Bankrupt” + “Pending delisting” (first and second bits set) +03 +Field value validation +These validations apply to message field values. +If a value violation is detected on a received message, the message should be rejected back to the counterparty in a way appropriate to the session protocol. + + + + + + + +Error condition +Error description + + + + +Field value less than minValue +The encoded value falls below the specified valid range. + + +Field value greater than maxValue +The encoded value exceeds the specified valid range. + + +Null value set for required field +The null value of a data type is invalid for a required field. + + +String contains invalid characters +A String contains non-US-ASCII printable characters or other invalid sequence if a different characterEncoding is specified. + + +Required subfields not populated in MonthYear +Year and month must be populated with non-null values, and the month must be in the range 1-12. + + +UTCTimeOnly exceeds day range +The value must not exceed the number of time units in a day, e.g. greater than 86400 seconds. + + +TZTimestamp and TZTimeOnly has missing or invalid time zone +The time zone hour and minute offset subfields must correspond to an actual time zone recognized by international standards. + + +Value must match valid value of an enumeration field +A value is invalid if it does not match one of the explicitly listed valid values. + + + +Message Structure +Message Framing +SBE messages have no defined message delimiter. Version 2.0 of SBE makes it possible to walk the elements of a message to determine its limit, even when the message has been extended. Nevertheless, since internal framing depends on a correct starting point and not encountering malformed messages, it may be desirable to use an external framing protocol when used with transports that do not preserve message boundaries, such as when they are transmitted on a streaming session protocol or when persisting messages in storage. +Simple Open Framing Header +FIX Protocol Ltd. offers the Simple Open Framing Header standard for framing messages encoded with binary wire formats, such as Simple Binary Encoding. +The framing header provides two features: + +An overall message size including headers to support framing +An identifier of the encoding used in the message payload. This supports selecting the correct decoder in the case where multiple message encodings are used on a session. It also aids tooling such as protocol analyzers to identify message protocols contained in network packets. + +While the Simple Open Framing Header specification is normative, the following is an interpretation of that standard as an SBE encoding. Note that the framing standard specifies that the framing header will always be encoded in big-endian byte order, also known as network byte order. +Simple Open Framing Header as an SBE composite encoding (big-endian) +<composite name="framingHeader"/> + <type name="messageLength" primitiveType="uint32" /> + <type name="encodingType" primitiveType="uint16" /> +</composite> +The values of encodingType used to indicate SBE payloads are currently defined as: + + + +Encoding +encodingType value + + + + +SBE version 1.0 big-endian +0x5BE0 + + +SBE version 1.0 little-endian +0xEB50 + + + +The Simple Open Framing Header specification also lists values for other wire formats. +SBE Message Encoding Header +The purpose of the message encoding header is to tell which message template was used to encode the message and to give information about the size of the message body to aid in decoding, even when a message template has been extended in a later version. See section 5 below for an explanation of the schema extension mechanism. +The fields of the SBE message header are: + +Block length of the message root - the total space reserved for the root level of the message not counting any repeating groups or variable-length fields. +Template ID - identifier of the message template +Schema ID - identifier of the message schema that contains the template +Schema version - the version of the message schema in which the message is defined +Group count - the number of repeating groups in the root level of the message +Variable-length field count - the number of variable-length fields in the root level of the message + +Block length is specified in a message schema, but it is also serialized on the wire. By default, block length is set to the sum of the sizes of body fields in the message. However, it may be increased to force padding at the end of block. See section 3.3.3.3 below. +Message header schema +The header fields precede the message body of every message in a fixed position as shown below. Each of these fields must be encoded as an unsigned integer type. The encoding must carry the name “messageHeader”. +The message header is encoded in the same byte order as the message body, as specified in a message schema. See section 4.3.1. +Recommended message header encoding +<composite name="messageHeader" description="Template ID 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"/> + <type name="numGroups" primitiveType="uint16" /> + <type name="numVarDataFields" primitiveType="uint16" /> +</composite> +The recommended header encoding is 12 octets. + + + +Element +Description +Primitive type +Length (octets) +Offset + + + + +blockLength +Root block length +uint16 +2 +0 + + +templateId +Template ID +uint16 +2 +2 + + +schemaId +Schema ID +uint16 +2 +4 + + +version +Schema Version +uint16 +2 +6 + + +numGroups +Number of repeating groups +uint16 +2 +8 + + +numVarDataFields +Number of variable-length fields +uint16 +2 +10 + + + +Optionally, implementations may support any other unsigned integer types for blockLength. +Root block length +The total space reserved for the root level of the message not counting any repeating groups or variable-length fields. (Repeating groups have their own block length; see section 3.4 below. Length of a variable-length Data field is given by its corresponding Length field; see section 2.7.3 above.) Block length only represents message body fields; it does not include the length of the message header itself, which is a fixed size. +The block size must be at least the sum of lengths of all fields at the root level of the message, and that is its default value. However, it may be set larger to reserve more space to effect alignment of blocks. This is specified by setting the blockLength attribute in a message schema. +Template ID +The identifier of a message type in a message schema. See section 4.5.2 below for schema attributes of a message. +Schema ID +The identifier of a message schema. See section 4.3.1 below for schema attributes. +Schema version +The version number of the message schema that was used to encode a message. See section 4.3.1 below for schema attributes. +Number of repeating groups +A count of repeating groups at the root level of the message. The count does not include nested repeating groups. +Number of variable-length fields +A count of the variable-length fields at the root level of the message. The count does not include variable-length fields within repeating groups. +Message Body +The message body conveys the business information of the message. +Data only on the wire +In SBE, fields of a message occupy proximate space without delimiters or metadata, such as tags. +Direct access +Access to data is positional, guided by a message schema that specifies a message type. +Data fields in the message body correspond to message schema fields; they are arranged in the same sequence. The first data field has the type and size specified by the first message schema field, the second data field is described by the second message schema field, and so forth. Since a message decoder follows the field descriptions in the schema for position, it is not necessary to send field tags on the wire. +In the simplest case, a message is flat record with a fixed length. Based on the sequence of field data types, the offset to a given data field is constant for a message type. This offset may be computed in advance, based on a message schema. Decoding a field consists of accessing the data at this fixed location. +Field position and padding +No padding by default +By default, there is no padding between fields. In other words, a field value is packed against values of its preceding and following fields. No consideration is given to byte boundary alignment. +By default, the position of a field in a message is determined by the sum of the sizes of prior fields, as they are defined by the message schema. +<field name="ClOrdID" id="11" type="string14" + semanticType="String"/> +<field name="Side" id="54" type="char" semanticType="char"/> +<field name="OrderQty" id="38" type="intQty32" + semanticType="Qty"/> +<field name="Symbol" id="55" type="string8" semanticType="String"/> + + + +Field +Size +Offset + + + + +ClOrdID +14 +0 + + +Side +1 +14 + + +OrderQty +4 +15 + + +Symbol +8 +19 + + + +Field offset specified by message schema +If a message designer wishes to introduce padding or control byte boundary alignment or map to an existing data structure, field offset may optionally be specified in a message schema. Field offset is the number of octets from the start of the message body or group to the first octet of the field. Offset is a zero-based index. +If specified, field offset must be greater than or equal to the sum of the sizes of prior fields. In other words, an offset is invalid if it would cause fields to overlap. +Extra octets specified for padding should never be interpreted as business data. They should be filled with binary zeros. +Example of fields with specified offsets +<field name="ClOrdID" id="11" type="string14" offset="0" + semanticType="String"/> +<field name="Side" id="54" type="char" offset="14" + semanticType="char"/> +<field name="OrderQty" id="38" type="intQty32" offset="16" + semanticType="Qty"/> +<field name="Symbol" id="55" type="string8" offset="20" + semanticType="String"/> + + + +Field +Size +Padding preceding field +Offset + + + + +ClOrdID +14 +0 +0 + + +Side +1 +0 +14 + + +OrderQty +4 +1 +16 + + +Symbol +8 +0 +20 + + + +Padding at end of a message or group +In order to force messages or groups to align on byte boundaries or map to an existing data structure, they may optionally be specified to occupy a certain space with a blockLength attribute in the message schema. The extra space is padded at the end of the message or group. If specified, blockLength must be greater than or equal to the sum of the sizes of all fields in the message or group. +The blockLength attribute applies only to the portion of message that contains fix-length fields; it does not apply to variable-length data elements of a message. +Extra octets specified for padding should be filled with binary zeros. +Example of blockLength specification for 24 octets +<message name="ListOrder" id="2" blockLength="24"> +Repeating Groups +A repeating group is a message structure that contains a variable number of entries. Each entry contains fields specified by a message schema. +The order and data types of the fields are the same for each entry in a group. That is, the entries are homogeneous. Position of a given field within any entry is fixed, with the exception of variable-length fields. +A message may have no groups or an unlimited number of repeating groups specified in its schema. +Schema specification of a group +A repeating group is defined in a message schema by adding a <group> element to a message template. An unlimited number of <field> elements may be added to a group, but a group must contain at least one field. +Example repeating group encoding specification +<group name="Parties" id="1012" blockLength="16"> + <field name="PartyID" id="448" type="string14" + semanticType="String"/> + <field name="PartyIDSource" id="447" type="char" + semanticType="char"/> + <field name="PartyRole" id="452" type="uint8" semanticType="int"/> +</group> +Group block length +The blockLength part of a group dimension represents total space reserved for each group entry, not counting any nested repeating groups or variable-length fields. (Length of a variable-length Data field is given by its corresponding Length field.) Block length only represents message body fields; it does not include the length of the group dimension itself, which is a fixed size. +Padding at end of a group entry +By default, the space reserved for an entry is the sum of a group’s field lengths, as defined by a message schema, without regard to byte alignment. +The space reserved for an entry may optionally be increased to effect alignment of entries or to plan for future growth. This is specified by adding the group attribute blockLength to reserve a specified number of octets per entry. If specified, the extra space is padded at the end of each entry and should be set to zeroes by encoders. The blockLength value does not include the group dimensions itself. +Note that padding will only result in deterministic alignment if the repeating group contains no variable-length fields. +Entry counter +Each group is associated with a required counter field of semantic data type NumInGroup to tell how many entries are contained by a message. The value of the counter is a non-negative integer. See “Encoding of repeating group dimensions” section below for encoding of that counter. +Empty group +The space reserved for all entries of a group is the product of the space reserved for each entry times the value of the associated NumInGroup counter. If the counter field is set to zero, then no entries are sent in the message, and no space is reserved for entries. The group dimensions including the zero-value counter is still transmitted, however. +Multiple repeating groups +A message may contain multiple repeating groups at the same level. +Example of encoding specification with multiple repeating groups +<message name="ExecutionReport" id="8"> + <group name="ContraGrp" id="2012"> + <!-- ContraGrp group fields --> + </group> + <group name="PreAllocGrp" id="2026"> + <!-- PreAllocGrp group fields --> + </group> +</message> +Nested repeating group specification +Repeating groups may be nested to an arbitrary depth. That is, a <group> in a message schema may contain one or more <group> child elements, each associated with their own counter fields. +The encoding specification of nested repeating groups is in the same format as groups at the root level of a message in a recursive procedure. +Example of nested repeating group specification +<group name="ListOrdGrp" id="2030"> + <field name="ClOrdID" id="11" type="string14" semanticType="String"/> + <field name="ListSeqNo" id="67" type="uint32" semanticType="int"/> + <field name="Symbol" id="55" type="string8" semanticType="String"/> + <field name="Side" id="54" type="char" semanticType="char"/> + <field name="OrderQty" id="38" type="intQty32" semanticType="Qty"/> + <group name="Parties" id="1012"> + <field name="PartyID" id="448" type="string14" semanticType="String"/> + <field name="PartyRole" id="452" type="int" semanticType="int"/> + </group> +</group> +Nested repeating group wire format +Nested repeating groups are encoded on the wire by a depth-first walk of the data hierarchy. For example, all inner entries under the first outer entry must be encoded before encoding outer entry 2. (This is the same element order as FIX tag=value encoding.) +On decoding, nested repeating groups do no support direct access to fields. It is necessary to walk all elements in sequence to discover the number of entries in each repeating group. +Empty group means nested group is empty +If a group contains nested repeating groups, then a NumInGroup counter of zero implies that both that group and its child groups are empty. In that case, no NumInGroup is encoded on the wire for the child groups. +Group dimension encoding +Every repeating group must be immediately preceded on the wire by its dimensions. The two dimensions are the count of entries in a repeating group and the space reserved for each entry of the group. +Range of group entry count +Implementations should support uint8 and uint16 types for repeating group entry counts. Optionally, implementations may support any other unsigned integer types. +By default, the minimum number of entries is zero, and the maximum number is the largest value of the primitiveType of the counter. + + + +Primitive type +Description +Length (octets) +Maximum number of entries + + + + +uint8 +8-bit unsigned integer +1 +255 + + +uint16 +16-bit unsigned integer +2 +65535 + + + +The number of entries may be restricted to a specific range; see “Restricting repeating group entries” below. +Encoding of repeating group dimensions +Conventionally in FIX, a NumInGroup field conveys the number of entries in a repeating group. In SBE, the encoding conveys two dimensions: the number of entries and the length of each entry in number octets. Therefore, the encoding is a composite of those two elements. Block length and entry count subfields must be encoded as unsigned integer types. +By default, the name of the group dimension encoding is groupSizeEncoding. This name may be overridden by setting the dimensionType attribute of a <group> element. +Recommended encoding of repeating group dimensions +<composite name="groupSizeEncoding"> + <type name="blockLength" primitiveType="uint16"/> + <type name="numInGroup" primitiveType="uint16" semanticType="NumInGroup"/> + <type name="numGroups" primitiveType="uint16" /> + <type name="numVarDataFields" primitiveType="uint16" /> +</composite> +Block length +The total space reserved for the fixed-length fields of this repeating group, not counting any repeating groups or variable-length fields. +Number of entries +The number of entries in this repeating group, called NumInGroup in FIX. +Number of repeating groups +A count nested repeating groups in this repeating group. +Number of variable-length fields +A count of the variable-length fields in this repeating group. +Wire format of NumInGroup with block length 55 octets by 3 entries, containing one nested group and two variable-length fields. +3700030001000200 +Restricting repeating group entries +The occurrences of a repeating group may be restricted to a specific range by modifying the numInGroup member of the group dimension encoding. The minValue attribute controls the minimum number of entries, overriding the default of zero, and the maxValue attribute restricts the maximum entry count to something less than the maximum corresponding to its primitiveType. Either or both attributes may be specified. +Example of a restricted group encoding +<type name="numInGroup" primitiveType="uint16" semanticType="NumInGroup" minValue="1" maxValue="10" /> +Sequence of message body elements +Root level elements +To maximize deterministic field positions, message schemas must be specified with this sequence of message body elements: + +Fixed-length fields that reside at the root level of the message (that is, not members of repeating groups), including any of the following, in the order specified by the message schema:: + +Fixed-length scalar fields, such as integers +Fixed-length character arrays +Fixed-length composite types, such as MonthYear + +Repeating groups, if any. +Data fields, including raw data and variable-length strings, if any. + +Repeating group elements +Repeating group entries are recursively organized in the same fashion as the root level: fixed-length fields, then nested repeating groups, and finally, variable-length data fields. +Message structure validation +Aside from message schema validations (see section 4.8 below), these validations apply to message structure. +If a message structure violation is detected on a received message, the message should be rejected back to the counterparty in a way appropriate to the session protocol. + + + + + + + +Error condition +Error description + + + + +Wrong message size in header +A message size value smaller than the actual message may cause a message to be truncated. + + +Wrong or unknown template ID in header +A mismatch of message schema would likely render a message unintelligible or cause fields to be misinterpreted. + + +Fixed-length field after repeating group or variable-length field +All fixed-length fields in the root of a message or in a repeating group entry must be listed before any (nested) repeating group or variable-length field. + + +Repeating group after variable-length field +All repeating groups at the root level or in a nested repeating group must be listed before any variable length field at the same level. + + + +Message Schema +XML schema for SBE message schemas +See sbe.xsd for the normative XML Schema Definition (XSD) for SBE. +XML namespace +The Simple Binary Encoding XML schema is identified by this URL [tentative]: +xmlns:sbe=http://fixprotocol.io/2017/sbe +Conventionally, the URI of the XML schema is aliased by the prefix “sbe”. +Caution: Users should treat the SBE XML namespace as a URI (unique identifier), not as a URL (physical resource locator). Firms should not depend on access to the FIX Trading Community web site to validate XML schemas at run-time +Name convention +All symbolic names in a message schema are restricted to alphanumeric characters plus underscore without spaces. This is the same restriction applied to all names in FIX specifications. +Capitalization +The value of a field’s semanticType attribute is a FIX data type. In this document, FIX types are capitalized exactly as in the FIX repository, from which all official FIX documentation and references are derived. Since the capitalization is somewhat inconsistent, however, it is recommended that matching of type names should be case insensitive in schema parsers. +Root element +The root element of the XML document is <messageSchema>. +<messageSchema> attributes +The root element provides basic identification of a schema. +The byteOrder attribute controls the byte order of integer encodings within the schema. It is a global setting for all specified messages and their encodings. + + + + + + + + + + +Schema attribute +Description +XML type +Usage +Valid values + + + + +package +Name or category of a schema +string +optional +Should be unique between counterparties but no naming convention is imposed. + + +id +Unique identifier of a schema +unsignedInt + +Should be unique between counterparties + + +version +Version of this schema +nonnegativeInteger + +Initial version is zero and is incremented for each version + + +semanticVersion +Version of FIX semantics +string +optional +FIX versions, such as “FIX.5.0_SP2” + + +byteOrder +Byte order of encoding +token +default = littleEndian +littleEndian bigEndian + + +description +Documentation of the schema +string +optional + + + +headerType +Name of the encoding type of the message header, which is the same for all messages in a schema. +string +default= messageHeader +An encoding with this name must be contained by ’`. + + + +Schema versioning +Changes to a message schema may be tracked by its version attribute. A version of a schema is a snapshot in time. All elements in a given generation of the schema share the same version number. That is, elements are not versioned individually. By convention, the initial version of a schema is version zero, and subsequent changes increment the version number. +The package attribute should remain constant between versions, if it is supplied. +Data encodings +Encoding sets +The <types> element contains one or more sets of data encodings used for messages within the schema. +Within each set, an unbound number of encodings will be listed in any sequence: + +Element <type> defines a simple encoding +Element <composite> defines a composite encoding +Element <enum> defines an enumeration +Element <set> defines a multi-value choice bitset encoding + +Encoding name +The namespace for encoding names is global across all encodings included in a schema, including simple, composite and enumeration types. That is, the name must be unique among all encoding instances. +All symbolic names should be alphanumeric without spaces. +Importing encodings +A suggested usage is to import common encodings that are used across message schemas as one set while defining custom encodings that are particular to a schema in another set. +Example of XML include usage to import common encoding types +<!-- included XML contains a <types> element --> +<xi:include href="sbe-builtins.xml"/> +Simple encodings +A simple encoding is backed by either a scalar type or an array of scalars, such as a character array. One or more simple encodings may be defined, each specified by a <type> element. +<type> element content +If the element has a value, it is used to indicate a special value of the encoding. +Constant value +The element value represents a constant if attribute presence="constant". In this case, the value is conditionally required. +<type> attributes + + + + + + + + + + +<type> attribute +Description +XML type +Usage +Valid values + + + + +name +Name of encoding +symbolicName_t +required +Must be unique among all encoding types in a schema. + + +description +Documentation of the type +string +optional + + + +presence +Presence of any field encoded with this type +token + +required optional constant + + +nullValue +Override of special value used to indicate null for an optional field +string +Only valid if presence = optional +The XML string must be convertible to the scalar data type specified by primitiveType. + + +minValue +Lowest acceptable value +string + + + + +maxValue +Highest acceptable value +string + + + + +length +Number of elements of the primitive data type +nonnegativeInteger +default = 1 +Value “0” represents variable length. + + +offset +If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. +unsignedInt +optional +See section 4.4.4.3 below + + +primitiveType +The primitive data type that backs the encoding +token +required +char int8 int16 int32 int64 uint8 uint16 uint32 uint64 float double + + +semanticType +Represents a FIX data type +token +optional +Same as field semanticType – see below. + + +sinceVersion +Documents the version of a schema in which a type was added +nonnegativeInteger +default = 0 +Must be less than or equal to the version of the message schema. + + +deprecated +Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + + +FIX data type specification +The attribute semanticType must be specified on either a field or on its corresponding type encoding. It need not be specified in both places, but if it is, the two values must match. +Simple type examples +<type name="FLOAT" primitiveType="double" + semanticType="float"/> +<type name="TIMESTAMP" primitiveType="uint64" + semanticType="UTCTimestamp"/> +<type name="GeneralIdentifier" primitiveType="char" + description="Identifies class or source + of the PartyID" presence="constant">C</type> +Composite encodings +Composite encoding types are composed of two or more simple types. +<composite> attributes + + + + + + + + + + +<composite> attribute +Description +XML type +Usage +Valid values + + + + +name +Name of encoding +symbolicName_t +required +Must be unique among all encoding types. + + +offset +The offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. +unsignedInt +optional + + + +description +Documentation of the type +string +optional + + + +semanticType +Represents a FIX data type +token +optional +Same as field semanticType – see below. + + +sinceVersion +Documents the version of a schema in which a type was added +nonnegativeInteger +default = 0 +Must be less than or equal to the version of the message schema. + + +deprecated +Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + + +Composite type elements +A <composite> composite encoding element may be composed of any combination of types, including <type> simple encoding, <enum> enumeration, <set> bitset, and nested composite type. The elements that compose a composite type carry the same XML attributes as stand-alone types. +Composite type example +In this example, a Price is encoded as 32 bit integer mantissa and a constant exponent, which is not sent on the wire. +<composite name="decimal32" semanticType="Price"> + <type name="mantissa" primitiveType="int32" /> + <type name="exponent" primitiveType="int8" + presence="constant">-4</type> +</composite> +Element offset within a composite type +If a message designer wishes to control byte boundary alignment or map to an existing data structure, element offset may optionally be specified on a simple type, enum or bitset within a composite type. Offset is the number of octets from the start of the composite; it is a zero-based index. +If specified, offset must be greater than or equal to the sum of the sizes of prior elements. In other words, an offset is invalid if it would cause elements to overlap. +Null value of a composite type +For a composite type, nullness is indicated by the value of its first element. For example, if a price field is optional, a null value in its mantissa element indicates that the price is null. +Reference to reusable types +A composite type often has its elements defined in-line within the <composite> XML element as shown in the example above. Alternatively, a common type may be defined once on its own, and then referred to by name with the composite type using a <ref> element. +<ref> attributes + + + + + + + + + + +<ref> attribute +Description +XML type +Usage +Valid values + + + + +name +Usage of the type in this composite +symbolicName_t +required + + + +type +Name of referenced encoding +symbolicName_t +required +Must match a defined type, enum or set or composite name attribute. + + +offset +The offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. +unsignedInt +optional + + + +sinceVersion +Documents the version of a schema in which a type was added +nonnegativeInteger +default = 0 +Must be less than or equal to the version of the message schema. + + +deprecated +Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + + +Type reference examples +Reference to an enum +In this example, a futuresPrice is encoded as 64 bit integer mantissa, 8 bit exponent, and a reused enum type. +<enum name="booleanEnum" encodingType="uint8" semanticType="Boolean"> + <validValue name="false">0</validValue> + <validValue name="true">1</validValue> +</enum> + +<composite name="futuresPrice"> + <type name="mantissa" primitiveType="int64" /> + <type name="exponent" primitiveType="int8" /> + <ref name="isSettlement" type="boolEnum" /> +</composite> +Reference to a composite type +In this example, a nested composite is formed by using a reference to another composite type. It supports the expresson of a monetary amount with its currency, such as USD150.45. Note that a reference may carry an offset within the composite encoding that contains it. +<composite name="price"> + <type name="mantissa" primitiveType="int64" /> + <type name="exponent" primitiveType="int8" /> +</composite> + +<composite name="money"> + <type name="currencyCode" primitiveType="char" length="3" semanticType="Currency" /> + <ref name="amount" type="price" semanticType="Price" offset="3" /> +</composite> +Enumeration encodings +An enumeration explicitly lists the valid values of a data domain. Any number of fields may share the same enumeration. +<enum> element +Each enumeration is represented by an <enum> element. It contains any number of <validValue> elements. +The encodingType attribute refers to a simple encoding of scalar type. The encoding of an enumeration may be char or any unsigned integer type. + + + + + + + + + + +<enum> attribute +Description +XML type +Usage +Valid values + + + + +name +Name of encoding +symbolicName_t +required +Must be unique among all encoding types. + + +description +Documentation of the type +string +optional + + + +encodingType +Name of a simple encoding type +symbolicName_t +required +Must match the name attribute of a scalar <type> element or a primitive type: char uint8 uint16 uint32 uint64 + + +sinceVersion +Documents the version of a schema in which a type was added +nonnegativeInteger +default = 0 +Must be less than or equal to the version of the message schema. + + +deprecated +Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + +offset +If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. +unsignedInt +optional + + + + +<validValue> element attributes +The name attribute of the <validValue> uniquely identifies it. + + + + + + + + + + +<validValue> attribute +Description +XML type +Usage +Valid values + + + + +name +Symbolic name of value +symbolicName_t +required +Must be unique among valid values in the enumeration. + + +description +Documentation of the value +string +optional + + + +sinceVersion +Documents the version of a schema in which a value was added +nonNegativeInteger +default = 0 + + + +deprecated +Documents the version of a schema in which a value was deprecated. It should no longer be used in new messages. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + + +<validValue> element content +The element is required to carry a value, which is the valid value as a string. The string value in XML must be convertible to the data type of the encoding, such as an integer. +<enum> and <validValue> elements +Enumeration example (not all valid values listed) +This enumeration is encoded as an 8 bit unsigned integer value. Others are encoded as char codes. +<type name="intEnum" primitiveType="uint8" /> + +<enum name="PartyRole" encodingType="intEnum"> + <validValue name="ExecutingFirm">1</validValue> + <validValue name="BrokerOfCredit">2</validValue> + <validValue name="ClientID">3</validValue> + <validValue name="ClearingFirm">4</validValue> +</enum> +Multi-value choice encodings (bitset) +An enumeration explicitly lists the valid values of a data domain. Any number of fields may share the same set of choices. +<set> element +Each multi-value choice is represented by a <set> element. It may contain a number of <choice> elements up to the number of bits in the primitive encoding type. The largest number possible is 64 choices in a uint64 encoding. +The encodingType attribute refers to a simple encoding of scalar type. The encoding of a bitset should be an unsigned integer type. + + + + + + + + + + +<set> attribute +Description +XML type +Usage +Valid values + + + + +name +Name of encoding +symbolicName_t +required +Must be unique among all encoding types. + + +description +Documentation of the type +string +optional + + + +encodingType +Name of a simple encoding type +string +required +Must match the name attribute of a scalar <type> element or a primitive type: uint8 uint16 uint32 uint64 + + +sinceVersion +Documents the version of a schema in which a type was added +nonnegativeInteger +default = 0 +Must be less than or equal to the version of the message schema. + + +deprecated +Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + +offset +If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. +unsignedInt +optional + + + + +<choice> element attributes +The name attribute of the <choice> uniquely identifies it. + + + + + + + + + + +<choice> attribute +Description +XML type +Usage +Valid values + + + + +name +Symbolic name of value +symbolicName_t +required +Must be unique among choices in the set. + + +description +Documentation of the value +string +optional + + + +sinceVersion +Documents the version of a schema in which a choice was added +nonNegativeInteger +default = 0 + + + +deprecated +Documents the version of a schema in which a choice was deprecated. It should no longer be used in new messages. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + + +< choice > element content +The element is required to carry a value, which is an unsigned integer representing a zero-based index to a bit within a bitset. Zero is the least significant bit. +<set> and <choice> XML elements +Multi-value choice example, The choice is encoded as a bitset. +<type name="bitset" primitiveType="uint8" /> + +<set name="Scope" encodingType="bitset" > + <choice name="LocalMarket">0</choice> + <choice name="National">1</choice> + <choice name="Global">2</choice> +</set> +Message template +To define a message type, add a <message> element to the root element of the XML document, <messageSchema>. +The name and id attributes are required. The first is a display name for a message, while the latter is a unique numeric identifier, commonly called template ID. +Reserved space +By default, message size is the sum of its field lengths. However, a larger size may be reserved by setting blockLength, either to allow for future growth or for desired byte alignment. If so, the extra reserved space should be filled with zeros by message encoders. +Message members +A <message> element contains its field definitions in three categories, which must appear in this sequence: + +Element <field> defines a fixed-length field +Element <group> defines a repeating group +Element <data> defines a variable-length field, such as raw data + +The number of members of each type is unbound. +Member order +The order that fields are listed in the message schema governs the order that they are encoded on the wire. +<message> element attributes + + + + + + + + + + +<message> attribute +Description +XML type +Usage +Valid values + + + + +name +Name of a message +symbolicName_t +required +Must be unique among all messages in a schema + + +id +Unique message template identifier +unsignedInt +required +Must be unique within a schema + + +description +Documentation +string +optional + + + +blockLength +Reserved size in number of octets for root level of message body +unsignedInt +optional +If specified, must be greater than or equal to the sum of field lengths. + + +semanticType +Documents value of FIX MsgType for a message +token +optional +Listed in FIX specifications + + +sinceVersion +Documents the version of a schema in which a message was added +nonNegativeInteger +default = 0 + + + +deprecated +Documents the version of a schema in which a message was deprecated. It should no longer be sent but is documented for back-compatibility. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + + +Note that there need not be a one-to-one relationship between message template (identified by id attribute) and semanticType attribute. You might design multiple templates for the same FIX MsgType to optimize different scenarios. +Example <message> element +<sbe:message name="NewOrderSingle" id="2" semanticType="D"> +Field attributes +Fields are added to a <message> element as child elements. See Field Encoding section above for a listing of all field types. +These are the common attributes of all field types. + + + + + + + + + + +Schema attribute +Description +XML type +Usage +Valid values + + + + +name +Name of a field +symbolicName_t +required +Name and id must uniquely identify a field type within a message schema. + + +id +Unique field identifier (FIX tag) +unsignedShort +required + + + +description +Documentation +string +optional + + + +type +Encoding type name, one of simple type, composite type or enumeration. +string +required +Must match the name attribute of a simple <type>, <composite> encoding type, <enum> or <set>. + + +offset +Offset to the start of the field within a message or repeating group entry. By default, the offset is the sum of preceding field sizes, but it may be increased to effect byte alignment. +unsignedInt +optional +Must be greater than or equal to the sum of preceding field sizes. + + +presence +Field presence +enumeration +Default = required +required = field value is required; not tested for null. optional = field value may be null. constant = constant value not sent on wire. + + +valueRef +Constant value of a field as a valid value of an enumeration +qualifiedName_t +optional Valid only if presence= ”constant” +If provided, the qualified name must match the name attribute of a <validValue> within an <enum> + + +sinceVersion +The version of a message schema in which this field was added. +InonnegativeInteger +default=0 +Must not be greater than version attribute of <messageSchema> element. + + +deprecated +Documents the version of a schema in which a field was deprecated. It should no longer be used in new messages. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + + +Example field schemas +Field that uses a composite encoding +<composite name="intQty32" semanticType="Qty"> + <type name="mantissa" primitiveType="int32" /> + <type name="exponent" primitiveType="int8" + presence="constant">0\</type> +</composite> + +<field type="intQty32" name="OrderQty" id="38" offset="16" + description="Shares: Total number of shares" /> +Repeating group schema +A <group> has the same attributes as a <message> element since they both inherit attributes from the blockType XML type. A group has the same child members as a message, and they must appear in the same order: + +Element <field> defines a fixed-length field +Element <group> defines a repeating group. Groups may be nested to any level. +Element <data> defines a variable-length field, such as raw data + +The number of members of each type is unbound. + + + + + + + + + + +<group> attribute +Description +XML type +Usage +Valid values + + + + +name +Name of a group +symbolicName_t +required +Name and id must uniquely identify a group type within a message schema. + + +id +Unique group identifier +unsignedShort +required + + + +description +Documentation +string +optional + + + +dimensionType +Dimensions of the repeating group +symbolicName_t +default = groupSizeEncoding +If specified, must be greater than or equal to the sum of field lengths. + + + +<group> element inherits attributes of blockType. See <message> above. +Example group schema with default dimension encoding +<composite name="groupSizeEncoding"> + <type name="blockLength" primitiveType="uint16"/> + <type name="numInGroup" primitiveType="uint16" + semanticType="NumInGroup"/> +</composite> + +<group name="Parties" id="1012" > + <field type="string14" name="PartyID" id="448" /> + <field type="partyRoleEnum" name="PartyRole" id="452" /> +</group> +Schema validation +The first level of schema validation is enforced by XML schema validation tools to make sure that a schema is well-formed according to XSD schema rules. Well-formed XML is necessary but insufficient to prove that a schema is correct according to FIX Simple Binary Encoding rules. +Additional conditions that render a schema invalid include the following. + + + + + + + +Error condition +Error description + + + + +Missing field encoding +A field or <enum> references a type name that is undefined. + + +Missing message header encoding +Missing encoding type for headerType specified in <messageSchema>. Default name is “messageHeader”. + + +Duplicate encoding name +An encoding name is non-unique, rendering a reference ambiguous. + + +nullValue specified for non-null encoding +Attribute nullValue is inconsistent with presence=required or constant + + +Attributes nullValue, minValue or maxValue of wrong data range +The specified values must be convertible to a scalar value consistent with the encoding. For example, if the primitive type is uint8, then the value must be in the range 0 through 255. + + +semanticType mismatch +If the attribute is specified on both a field and the encoding that it references, the values must be identical. + + +presence mismatch +If the attribute is specified on both a field and the encoding that it references, the values must be identical. + + +Missing constant value +If presence=constant is specified for a field or encoding, the element value must contain the constant value. + + +Missing validValue content +A <validValue> element is required to carry its value. + + +Incompatible offset and blockLength +A field offset greater than message or group blockLength is invalid + + +Duplicate ID or name of field or group +Attributes id and name must uniquely identify a type within a message schema. This applies to fields and groups. To be clear, the same field or group ID may be used in multiple messages, but each instance must represent the same type. Each of those instances must match on both id and name attributes. + + + +Message with a repeating group +<message name="ListOrder" id="2" description="Simplified + NewOrderList. Demonstrates repeating group"> + <field name="ListID" id="66" type="string14" semanticType="String"/> + <field name="BidType" id="394" type="uint8" semanticType="int"/> + <group name="ListOrdGrp" id="2030" > + <field name="ClOrdID" id="11" type="string14" semanticType="String"/> + <field name="ListSeqNo" id="67" type="uint32" semanticType="int"/> + <field name="Symbol" id="55" type="string8" semanticType="String"/> + <field name="Side" id="54" type="char" semanticType="char"/> + <field name="OrderQty" id="38" type="intQty32" semanticType="Qty"/> + </group> +</message> +Message with raw data fields +<message name="UserRequest" id="4" description="Demonstrates raw data usage"> + <field name="UserRequestId" id="923" type="string14" semanticType="String"/> + <field name="UserRequestType" id="924" type="uint8" semanticType="int"/> + <field name="UserName" id="553" type="string14" semanticType="String"/> + <field name="Password" id="554" type="string14" semanticType="String"/> + <field name="NewPassword" id="925" type="string14" semanticType="String"/> + <field name="EncryptedPasswordMethod" id="1400" type="uint8" description="This should be an enum but values undefined." + semanticType="int"/> + <field name="EncryptedPasswordLen" id="1401" type="uint8" semanticType="Length"/> + <field name="EncryptedNewPasswordLen" id="1403" type="uint8" semanticType="Length"/> + <field name="RawDataLength" id="95" type="uint8" semanticType="Length"/> + <data name="EncryptedPassword" id="1402" type="rawData" semanticType="data"/> + <data name="EncryptedNewPassword" id="1404" type="rawData" semanticType="data"/> + <data name="RawData" id="96" type="rawData" semanticType="data"/> +</message> +Reserved element names +Composite types + + + +Encoding type name (default names) + + + + +messageHeader + + +groupSizeEncoding + + + +Composite type elements + + + +Type name +Composite type + + + + +blockLength +messageHeader and groupSize + + +day +MonthYear + + +exponent +decimal + + +mantissa +decimal + + +month +MonthYear + + +numInGroup +groupSize + + +templateId +messageHeader + + +time +timestamp, TZ time + + +timezoneHour +TZ time + + +timezoneMinute +TZ time + + +unit +timestamp, TZ time + + +version +messageHeader + + +week +MonthYear + + +year +MonthYear + + + +Schema Extension Mechanism +Objective +It is not always practical to update all message publishers and consumers simultaneously. Within certain constraints, message schemas and wire formats can be extended in a controlled way. Consumers using an older version of a schema should be compatible if interpretation of added fields or messages is not required for business processing. +This specification only details compatibility at the presentation layer. It does not relieve application developers of any responsibility for carefully planning a migration strategy and for handling exceptions at the application layer. +Constraints +Compatibility is only ensured under these conditions: + +Fields may be added to either the root of a message or to a repeating group, but in each case, they must be appended to end of a block. +Existing fields cannot change data type or move within a message. +A repeating group may be added after existing groups at the root level or nested within another repeating group. +A variable-length data field may be added after existing variable-length data at the root level or within a repeating group. +Message header encoding cannot change. +In general, metadata changes such as name or description corrections do not break compatibility so long as wire format does not change. + +Changes that break those constraints require consumers to update to the current schema used by publishers. An message template that has changed in an incompatible way must be assinged a new template “id” attribute. +Message schema features for extension +Schema version +The <messageSchema> root element contains a version number attribute. By default, version is zero, the initial version of a message schema. Each time a message schema is changed, the version number is incremented. +Version applies to the schema as a whole, not to individual elements. Version is sent in the message header so the consumer can determine which version of the message schema was used to encode the message. +See section 4.3.1 above for schema attributes. +Since version +When a new field, enumeration value, group or message is added to a message schema, the extension may be documented by adding a sinceVersion attribute to the element. The sinceVersion attribute tells in which schema version the element was added. This attribute remains the same for that element for the lifetime of the schema. This attribute is for documentation purposes only, it is not sent on the wire. +Over time, multiple extensions may be added to a message schema. New fields must be appended following earlier extensions. By documenting when each element was added, it possible to verify that extensions were appended in proper order. +Block length +The length of the root level of the message may optionally be documented on a <message> element in the schema using the blockLength attribute. See section 4.5.3 above for message attributes. If not set in the schema, block length of the message root is the sum of its field lengths. Whether it is set in the schema or not, the block length is sent on the wire to consumers. +Likewise, a repeating group has a blockLength attribute to tell how much space is reserved for group entries, and the value is sent on the wire. It is encoded in the schema as part of the NumInGroup field encoding. See section 3.4.8.2 above. +Deprecated elements +A message schema may document obsolete elements, such as messages, fields, and valid values of enumerations with deprecated attribute. Updated applications should not publish deprecated messages or values, but declarations may remain in the message schema during a staged migration to replacement message layouts. +Wire format features for extension +Block size +The length of the root level of the message is sent on the wire in the SBE message header. See section 3.2.2 above. Therefore, if new fields were appended in a later version of the schema, the consumer would still know how many octets to consume to find the next message element, such as repeating group or variable-length Data field. Without the current schema version, the consumer cannot interpret the new fields, but it does not break parsing of earlier fields. +Likewise, block size of a repeating group is conveyed in the NumInGroup encoding. +Number of repeating groups and variable data +Message headers and repeating group dimensions carry a count of the number of repeating groups and a count of variable-length data fields on the wire. This supports a walk by a decoder of all the elements of a message, even when the decoder was built with an older version of a schema. As for added fixed-length fields, new repeating groups cannot be interpreted by the decoder, but it still can process the ones it knows, and it can correctly reach the end of a message. +Comaptibility strategy +This suggested strategy is non-normative. +A message decoder compares the schema version in a received message header to the version that the decoder was built with. +If the received version is equal to the decoder’s version, then all fields known to the decoder may be parsed, and no further analysis is required. +If the received version is greater than the decoder’s version (that is, the producer’s encoder is newer than the consumer’s decoder), then all fields known to the decoder may be parsed but it will be unable to parse added fields. +Also, an old decoder may encounter unexpected enumeration values. The application layer determines whether an unexpected value is a fatal error. Probably so for a required field since the business meaning is unknown, but it may choose to allow an unknown value of an optional field to pass through. For example, if OrdType value J=“Market If Touched” is added to a schema, and the consumer does not recognize it, then the application returns an order rejection with reason “order type not supported”, even if it does not know what “J” represents. Note that this is not strictly a versioning problem, however. This exception handling is indistinguishable from the case where “J” was never added to the enum but was simply sent in error. +If the received version is less than the decoder’s version (that is, the producer’s encoder is older than the consumer’s decoder), then only the fields of the older version may be parsed. This information is available through metadata as “sinceVersion” attribute of a field. If sinceVersion is greater than received schema version, then the field is not available. How a decoder signals an application that a field is unavailable is an implementation detail. One strategy is for an application to provide a default value for unavailable fields. +Message schema extension example +Initial version of a message schema +<messageSchema package="FIXBinaryTest" byteOrder="littleEndian"> + <types> + <type name="int8" primitiveType="int8"/> + </types> + +<message name="FIX Binary Message1" id="1" blockLength="4"> + <field name="Field1" id="1" type="int8" semanticType="int"/> +</message> + +</messageSchema> +Second version - a new message is added +<messageSchema package="FIXBinaryTest" byteOrder="littleEndian" + version="1"> + +<types> + <type name="int8" primitiveType="int8"/> + <type name="int16" primitiveType="int16" + sinceVersion="1"/> +</types> + +<message name="FIX Binary Message1" id="1" blockLength="4"> + <field name="Field1" id="1" type="int8" semanticType="int"/> +</message> + +<!-- New message added in this version--> +<message name="FIX Binary Message2" id="2" blockLength="4" + sinceVersion="1"> + <field name="Field2" id="2" type="int16" semanticType="int"/> +</message> +</messageSchema> +Third version - a field is added +<messageSchema package="FIXBinaryTest" byteOrder="littleEndian" + version="2"> + +<types> + <type name="int8" primitiveType="int8"/> + <type name="int16" primitiveType="int16" + sinceVersion="1"/> + <type name="int32" primitiveType="int32" + sinceVersion="2"/> +</types> + +<message name="FIX Binary Message1" id="1" blockLength="8"> + <field name="Field1" id="1" type="int8" semanticType="int"/> + <field name="Field11" id="11" type="int32" semanticType="int" + sinceVersion="2"/> +</message> + +<message name="FIX Binary Message2" id="2" blockLength="4" + sinceVersion="1"> + <field name="Field2" id="2" type="int16" semanticType="int"/> +</message> +</messageSchema> +Usage Guidelines +Identifier encodings +FIX specifies request and entity identifiers as String type. Common practice is to specify an identifier field as fixed-length character of a certain size. +Optionally, a message schema may restrict such identifiers to numeric encodings. +Example of an identifier field with character encoding +<type name="idString" primitiveType="char" length="16" /> + +<field name="QuoteReqId" id="131" type="idString" + semanticType="String"/> +Example of an identifier field with numeric encoding +<type name="uint64" primitiveType="uint64" /> + +<field name="QuoteReqId" id="131" type="uint64" + semanticType="String"/> +Examples +The example messages are preceded by Simple Open Framing Header. Note that SOFH encoding is always big-endian, regardless of the byte order of the SBE message body. See that FIX standard for details. +Not all FIX enumeration values are listed in the samples. +Flat, fixed-length message +This is an example of a simple, flat order message without repeating groups or variable-length data. +Sample order message schema +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> + +<sbe:messageSchema + xmlns:sbe="http://fixprotocol.io/2016/sbe" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + package="Examples" id="100" + description="Test dictionary" + byteOrder="littleEndian" + xsi:schemaLocation="http://fixprotocol.io/2016/sbe sbe.xsd"> + +<types> + <type name="enumEncoding" primitiveType="char"/> + <type name="idString" length="8" primitiveType="char" semanticType="String"/> + <type name="timestampEncoding" primitiveType="uint64" semanticType="UTCTimestamp"/> + + <composite name="messageHeader"> + <type name="blockLength" primitiveType="uint16"/> + <type name="templateId" primitiveType="uint16"/> + <type name="schemaId" primitiveType="uint16"/> + <type name="version" primitiveType="uint16"/> + </composite> + + <composite name="optionalDecimalEncoding" + description="Optional decimal with constant exponent"> + <type name="mantissa" presence="optional" primitiveType="int64"/> + <type name="exponent" presence="constant" primitiveType="int8">-3</type> + </composite> + + <composite name="qtyEncoding" description="Decimal constrained to integers"> + <type name="mantissa" primitiveType="int32"/> + <type name="exponent" presence="constant" primitiveType="int8">0</type> + </composite> + + <enum name="ordTypeEnum" encodingType="enumEncoding"> + <validValue name="Market" description="Market">1</validValue> + <validValue name="Limit" description="Limit">2</validValue> + <validValue name="Stop" description="Stop Loss">3</validValue> + <validValue name="StopLimit" description="Stop Limit">4</validValue> + </enum> + + <enum name="sideEnum" encodingType="enumEncoding"> + <validValue name="Buy" description="Buy">1</validValue> + <validValue name="Sell" description="Sell">2</validValue> + </enum> + +</types> + +<sbe:message name="NewOrderSingle" id="99" blockLength="54" +semanticType="D"> + <field name="ClOrdID" id="11" type="idString" description="Customer Order ID" + offset="0" semanticType="String"/> + <field name="Account" id="1" type="idString" description="Account mnemonic" + offset="8" semanticType="String"/> + <field name="Symbol" id="55" type="idString" description="Security ID" + offset="16" semanticType="String"/> + <field name="Side" id="54" type="sideEnum" description="Side" offset="24" + semanticType="char"/> + <field name="TransactTime" id="60" type="timestampEncoding" + description="Order entry time" offset="25" semanticType="UTCTimestamp"/> + <field name="OrderQty" id="38" type="qtyEncoding" description="Order quantity" + offset="33" semanticType="Qty"/> + <field name="OrdType" id="40" type="ordTypeEnum" description="Order type" + offset="37" semanticType="char"/> + <field name="Price" id="44" type="optionalDecimalEncoding" + description="Limit price" offset="38" semanticType="Price"/> + <field name="StopPx" id="99" type="optionalDecimalEncoding" + description="Stop price" offset="46" semanticType="Price"/> +</sbe:message> + +</sbe:messageSchema> +Notes on the message schema +In this case, there is a lot of verbiage for one message, but in practice, a schema would define a set of messages. The same encodings within the <types> element would be used for a whole collection of messages. For example, a price encoding need only be defined once but can be used in any number of messages in a schema. Many of the attributes, such as description, offset, and semanticType, are optional but are shown here for a full illustration. +All character fields in the message are fixed-length. Values may be shorter than the specified field length, but not longer. Since all fields are fixed-length, they are always in a fixed position, supporting direct access to data. +An enumeration gives the valid values of a field. Both enumerations in the example use character encoding, but note that some enumerations in FIX are of integer type. +There are two decimal encodings. The one used for quantity sets the exponent to constant zero. In effect there is no fractional part and only the mantissa is sent on the wire, acting as an integer. However, FIX defines Qty as a float type since certain asset classes may use fractional shares. +The other decimal encoding is used for prices. The exponent is constant -3. In essence, each price is transmitted as an integer on the wire with assumed three decimal places. Each of the prices in the message is conditionally required. If OrdType=Limit, then Price field required. If OrdType=Stop then StopPx is required. Otherwise, if OrdType=Market, then neither price is required. Therefore, the price takes an optional encoding. To indicate that it is null, a special value is sent on the wire. See the table in section 2.4.2 above for the null value of the int64 mantissa. +In this example, all fields are packed without special byte alignment. Performance testing may prove better results with a different arrangement of the fields or adjustments to field offsets. However, those sorts of optimizations are platform dependent. +Wire format of an order message +Hexadecimal and ASCII representations (little-endian byte order): +00 00 00 44 eb 50 36 00 63 00 5b 00 00 00 4f 52 : D P6 c [ OR +44 30 30 30 30 31 41 43 43 54 30 31 00 00 47 45 :D00001ACCT01 GE +4d 34 00 00 00 00 31 80 16 b3 3b 13 65 29 15 07 :M4 1 ; e) +00 00 00 32 1a 85 01 00 00 00 00 00 00 00 00 00 : 2 +00 00 00 80 +Interpretation + + + +Wire format +Field ID +Name +Offset +Length +Interpreted value + + + + +00000044 + +SOFH message length +0 +4 +68 + + +eb50 + +SOFH encoding +4 +2 +SBE little-endian + + +3600 + +SBE block length +0 +2 +54 + + +6300 + +SBE template ID +2 +2 +99 + + +5b00 + +SBE schema ID +4 +2 +91 + + +0000 + +SBE schema version +6 +2 +0 + + +4f52443030303031 +11 +ClOrdId +0 +8 +ORD00001 + + +4143435430310000 +1 +Account +8 +8 +ACCT01 + + +47454d3400000000 +55 +Symbol +16 +8 +GEM4 + + +31 +54 +Side +24 +1 +Buy + + +8016b33b13652915 +60 +TransactTime +25 +8 +2018-04-27T20:31:22.122Z + + +07000000 +38 +OrderQty +33 +4 +7 + + +32 +40 +OrdType +37 +1 +Limit + + +1a85010000000000 +44 +Price +38 +8 +99.610 + + +0000000000000080 +99 +StopPx +46 +8 +null + + + +Message with a repeating group +This is an example of a message with a repeating group. +Sample execution report message schema +Add this encoding types element to those in the previous example. +<types> + <type name="date" primitiveType="uint16" semanticType="LocalMktDate"/> + <composite name="MONTH_YEAR" semanticType="MonthYear"> + <type name="year" primitiveType="uint16"/> + <type name="month" primitiveType="uint8"/> + <type name="day" primitiveType="uint8"/> + <type name="week" primitiveType="uint8"/> + </composite> + + <composite name="groupSizeEncoding" description="Repeating group dimensions"> + <type name="blockLength" primitiveType="uint16" + semanticType="Length"/> + <type name="numInGroup" primitiveType="uint16" + semanticType="NumInGroup"/> + </composite> + + <enum name="execTypeEnum" encodingType="enumEncoding"> + <validValue name="New" description="New">0</validValue> + <validValue name="DoneForDay" description="Done for day">3</validValue> + <validValue name="Canceled" description="Canceled">4</validValue> + <validValue name="Replaced" description="Replaced">5</validValue> + <validValue name="PendingCancel">6</validValue> + <validValue name="Rejected" description="Rejected">8</validValue> + <validValue name="PendingNew" description="Pending New">A</validValue> + <validValue name="Trade" description="partial fill or fill">F</validValue> + </enum> + + <enum name="ordStatusEnum" encodingType="enumEncoding"> + <validValue name="New" description="New">0</validValue> + <validValue name="PartialFilled">1</validValue> + <validValue name="Filled" description="Filled">2</validValue> + <validValue name="DoneForDay" description="Done for day">3</validValue> + <validValue name="Canceled" description="Canceled">4</validValue> + <validValue name="PendingCancel">6</validValue> + <validValue name="Rejected" description="Rejected">8</validValue> + <validValue name="PendingNew" description="Pending New">A</validValue> + <validValue name="PendingReplace" >E</validValue> + </enum> + +</types> + +<sbe:message name="ExecutionReport" id="98" blockLength="42" +semanticType="8"> + <field name="OrderID" id="37" type="idString" description="Order ID" + offset="0" semanticType="String"/> + <field name="ExecID" id="17" type="idString" description="Execution ID" + offset="8" semanticType="String"/> + <field name="ExecType" id="150" type="execTypeEnum" + description="Execution type" offset="16" semanticType="char"/> + <field name="OrdStatus" id="39" type="ordStatusEnum" + description="Order status" offset="17" semanticType="char"/> + <field name="Symbol" id="55" type="idString" description="Security ID" + offset="18" semanticType="String"/> + <field name="MaturityMonthYear" id="200" type="MONTH_YEAR" + description="Expiration" offset="26" semanticType="MonthYear"/> + <field name="Side" id="54" type="sideEnum" description="Side" offset="31" + semanticType="char"/> + <field name="LeavesQty" id="151" type="qtyEncoding" + description="Quantity open" offset="32" semanticType="Qty"/> + <field name="CumQty" id="14" type="qtyEncoding" + description="Executed quantity" offset="36" semanticType="Qty"/> + <field name="TradeDate" id="75" type="date" + description="Trade date" offset="40" semanticType="LocalMktDate"/> + <group name="FillsGrp" id="2112" description="Partial fills" + blockLength="12" dimensionType="groupSizeEncoding"> + <field name="FillPx" id="1364" type="optionalDecimalEncoding" + description="Price of partial fill" offset="0" semanticType="Price"/> + <field name="FillQty" id="1365" type="qtyEncoding" + description="Executed quantity" offset="8" semanticType="Qty"/> + </group> +</sbe:message> +Notes on the message schema +The message contains a MonthYear field. It is encoded as a composite type with year, month, day and week subfields. +This message layout contains a repeating group containing a collection of partial fills for an execution report. The <group> XML tag enclosed the fields within a group entry. The dimensions of the repeating group are encoding as a composite type called groupSizeEncoding. +Wire format of an execution message +Hexadecimal and ASCII representations (little-endian byte order): +00 00 00 54 eb 50 2a 00 62 00 5b 00 00 00 4f 30 : T P* b [ O0 +30 30 30 30 30 31 45 58 45 43 30 30 30 30 46 31 :000001EXEC0000F1 +47 45 4d 34 00 00 00 00 de 07 06 ff ff 31 01 00 :GEM4 1 +00 00 06 00 00 00 75 3e 0c 00 02 00 1a 85 01 00 : u> +00 00 00 00 02 00 00 00 24 85 01 00 00 00 00 00 : $ +04 00 00 00 : +Interpretation +Offset is from beginning of block. + + + +Wire format +Field ID +Name +Offset +Length +Interpreted value + + + + +00000054 + +SOFH message length +0 +4 +84 + + +eb50 + +SOFH encoding +4 +2 +SBE little-endian + + +2a00 + +SBE block length +0 +2 +42 + + +6200 + +SBE template ID +2 +2 +98 + + +5b00 + +SBE schema ID +4 +2 +91 + + +0000 + +SBE schema version +6 +2 +0 + + +4558454330303030 +37 +OrderID +8 +8 +O0000001 + + +4558454330303030 +17 +ExecID +8 +8 +EXEC0000 + + +30 +39 +OrdStatus +1 +1 +PartialFilled + + +47454d3400000000 +55 +Symbol +18 +8 +GEM4 + + +de0706ffff +200 +MaturityMonthYear +26 +5 +year=2014 month=6 + + +30 +54 +Side +1 +1 +Buy + + +01000000 +151 +LeavesQty +32 +4 +1 + + +06000000 +14 +CumQty +36 +4 +6 + + +753e +75 +TradeDate +40 +2 +2013-10-11 + + +0c000200 + +FillGrp +0 +4 +Block length=12 count=2 + + +1a85010000000000 +1364 +FillPx +0 +8 +99.610 + + +02000000 +1365 +FillQty +8 +4 +2 + + +2485010000000000 +1364 +FillPx +0 +8 +99.620 + + +04000000 +1365 +FillQty +8 +4 +4 + + + +Message with a variable-length field +Sample business reject message schema +Add this encoding types element to those in the previous example. + +<types> + <type name="intEnumEncoding" primitiveType="uint8"/> + + <composite name="DATA" description="Variable-length data"> + <type name="length" primitiveType="uint16" /> + <type name="varData" length="0" primitiveType="uint8"> + </composite> + + <enum name="businessRejectReasonEnum" encodingType="intEnumEncoding">> + <validValue name="Other" 0</validValue> + <validValue name="UnknownID" 1</validValue> + <validValue name="UnknownSecurity" >2</validValue> + <validValue name="ApplicationNotAvailable" >4</validValue> + <validValue name="NotAuthorized" >6</validValue> + </enum> + +</types> + + <sbe:message name="BusinessMessageReject" id="97" + blockLength="9" semanticType="j"> + <field name="BusinesRejectRefId" id="379" type="idString" + offset="0" semanticType="String" /> + <field name="BusinessRejectReason" id="380" type="businessRejectReasonEnum" + offset="8" semanticType="int" /> + <data name="Text" id="58" type="DATA" semanticType="data" /> + </sbe:message> +Wire format of a business reject message +Hexadecimal and ASCII representations (little-endian byte order): +00 00 00 40 eb 50 09 00 61 00 5b 00 00 00 4f 52 : @ P a [ OR +44 30 30 30 30 31 06 27 00 4e 6f 74 20 61 75 74 :D00001 ' Not aut +68 6f 72 69 7a 65 64 20 74 6f 20 74 72 61 64 65 :horized to trade +20 74 68 61 74 20 69 6e 73 74 72 75 6d 65 6e 74 : that instrument +Interpretation + + + +Wire format +Field ID +Name +Offset +Length +Interpreted value + + + + +00000040 + +SOFH message length +0 +4 +64 + + +eb50 + +SOFH encoding +4 +2 +SBE little-endian + + +0900 + +SBE block length +0 +2 +9 + + +6100 + +SBE template ID +2 +2 +97 + + +5b00 + +SBE schema ID +4 +2 +91 + + +0000 + +SBE schema version +6 +2 +0 + + +4f52443030303031 +379 +BusinesRejectRefId +0 +8 +ORD00001 + + +06 +380 +BusinessRejectReason +8 +1 +NotAuthorized + + +4e6f74206175... +58 +Text +0 +39 +Not authorized to trade that instrument + + + + + diff --git a/v1-0-STANDARD/doc/publication/SBEONLINE_PROD_with_November_2020_errata.html b/v1-0-STANDARD/doc/publication/SBEONLINE_PROD_with_November_2020_errata.html new file mode 100644 index 0000000..07e2d34 --- /dev/null +++ b/v1-0-STANDARD/doc/publication/SBEONLINE_PROD_with_November_2020_errata.html @@ -0,0 +1,3883 @@ + + + + + + + + + + + + + + Simple Binary Encoding (SBE) + + + + + +Technical Specification +Version 1.0 with Errata – Technical Standard – November 2020 + +THIS DOCUMENT IS THE FINAL VERSION OF A FIX TECHNICAL STANDARD. THIS VERSION HAS BEEN +APPROVED BY THE GLOBAL TECHNICAL COMMITTEE AS THE FINAL STEP IN CREATING A NEW FIX +TECHNICAL STANDARD OR A NEW VERSION OF AN EXISTING FIX TECHNICAL STANDARD. POTENTIAL +ADOPTERS ARE STRONGLY ENCOURAGED TO USE ONLY THE FINAL VERSION. EXISTING ADOPTERS ARE +STRONGLY ENCOURAGED TO UPGRADE TO THE FINAL VERSION. + +Table of Contents + + +Scope + +Binary type system +Design principles +Message schema +Documentation + +Normative references +Terms and definitions + +Specification terms + +Field Encoding + +Field aspects +FIX datatype summary +Common field schema attributes +Integer encoding +Decimal encoding +Float encoding +String encodings +Data encodings +MonthYear encoding +Date and time encoding +Local date encoding +Local time encoding +Enumeration encoding +Multi-value choice encoding +Field value validation + +Message Structure + +Message Framing +SBE Message Encoding Header +Message Body +Repeating Groups +Sequence of message body elements +Message structure validation + +Message Schema + +XML schema for SBE message schemas +XML namespace +Name convention +Root element +Data encodings +Message template +Field attributes +Repeating group schema +Schema validation +Reserved element names + +Schema Extension Mechanism + +Objective +Message schema features for extension +Wire format features for extension +Comaptibility strategy +Message schema extension example + +Usage Guidelines + +Identifier encodings + +Examples + +Flat, fixed-length message +Message with a repeating group +Message with a variable-length field + + + +Scope +The Financial Information eXchange Simple Binary Encoding (SBE) targets high performance trading systems. It is optimized for low latency of encoding and decoding while keeping bandwidth utilization reasonably small. For compatibility, it is intended to represent all FIX semantics. +This encoding specification describes the wire protocol for messages. Thus, it provides a standard for interoperability between communicating parties. Users are free to implement the standard in a way that best suits their needs. +The encoding standard is complimentary to other FIX standards for session protocol and application level behavior. +Binary type system +In order to support traditional FIX semantics, all the documented field types are supported. However, instead of printable character representations of tag-value encoding, the type system binds to native binary datatypes, and defines derived types as needed. +The binary type system has been enhanced in these ways: + +Provides a means to specify precision of decimal numbers and timestamps, as well as valid ranges of numbers. +Differentiates fixed-length character arrays from variable-length strings. Allows a way to specify the minimum and maximum length of strings that an application can accept. +Provides a consistent system of enumerations, Boolean switches and multiple-choice fields. + +Design principles +The message design strives for direct data access without complex transformations or conditional logic. This is achieved by: + +Usage of native binary datatypes and simple types derived from native binaries, such as prices and timestamps. +Preference for fixed positions and fixed length fields, supporting direct access to data and avoiding the need for management of heaps of variable-length elements which must be sequentially processed. + +Message schema +This standard describes how fields are encoded and the general structure of messages. The content of a message type is specified by a message schema. A message schema tells which fields belong to a message and their location within a message. Additionally, the metadata describes valid value ranges and information that need not be sent on the wire, such as constant values. +Message schemas may be based on standard FIX message specifications or may be customized as needed by agreement between counterparties. +Documentation +This document explains: + +The binary type system for field encoding +Message structure, including field arrangement, repeating groups, and relationship to a message header that may be provided by a session protocol. +The Simple Binary Encoding message schema. + +Document format +In this document, these formats are used for technical specifications and data examples. +This is a sample encoding specification +<type name="short" primitiveType="int16" semanticType="int" /> +This is sample data as it would be transmitted on the wire +10270000 +Normative references +The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies. +— IETF RFC 2119 – Key words for use in RFCs to Indicate Requirement Levels March 1997 +Related FIX Standards +Simple Open Framing Header, technical specification of a message framing standard for FIX messages. +FIX Latest, normative specification of the application layer of the FIX Protocol. +Dependencies on other standards +SBE is dependent on several industry standards. Implementations must conform to these standards to interoperate. Therefore, they are normative for SBE. +IEEE 754-2008 A Standard for Binary Floating-Point Arithmetic +ISO 639-1:2002 Codes for the representation of names of languages - Part 1: Alpha-2 code +ISO 3166-1:2013 Codes for the representation of names of countries and their subdivisions - Part 1: Country codes +ISO 4217:2015 Codes for the representation of currencies and funds +ISO 8601:2004 Data elements and interchange formats - Information interchange - Representation of dates and times +ISO 10383:2012 Securities and related financial instruments - Codes for exchanges and market identification (MIC) +ISO/IEC 11404:2007 Information technology – General-Purpose Datatypes (GPD) +XML 1.1 schema standards are located here W3C XML Schema +Terms and definitions +datatype - A field type with its associated encoding attributes, including backing primitive types and valid values or range. Some types have additional attributes, e.g. epoch of a date. +Encoding - a message format for interchange. The term is commonly used to mean the conversion of one data format to another, such as text to binary. However, Simple Binary Encoding strives to use native binary datatypes in order to make conversion unnecessary, or at least trivial. Encoding also refers to the act of formatting a message, as opposed to decoding. +Message schema - metadata that specifies messages and their data types and identifiers. Message schemas may be disseminated out of band. For Simple Binary Encoding, message schemas are expressed as an XML document that conforms to an XML schema that is published as part of this standard. +Message template - metadata that specifies the fields that belong to one particular message type. A message template is contained by a message schema. +Session protocol - a protocol concerned with the reliable delivery of messages over a transport. FIX protocol makes a distinction between session protocol and the encoding of a message payload, as described by this document. See the specifications section of the FIX protocol web site for supported protocols. +XML schema - defines the elements and attributes that may appear in an XML document. The SBE message schema is defined in W3C (XSD) schema language since it is the most widely adopted format for XML schemas. +Specification terms +These key words in this document are to be interpreted as described in Internet Engineering Task Force RFC2119. These terms indicate an absolute requirement for implementations of the standard: “must”, or “required”. +This term indicates an absolute prohibition: “must not”. +These terms indicate that a feature is allowed by the standard but not required: “may”, “optional”. An implementation that does not provide an optional feature must be prepared to interoperate with one that does. +These terms give guidance, recommendation or best practices: “should” or “recommended”. A recommended choice among alternatives is described as “preferred”. +These terms give guidance that a practice is not recommended: “should not” or “not recommended”. +Field Encoding +Field aspects +A field is a unit of data contained by a FIX message. Every field has the following aspects: semantic datatype, encoding, and metadata. They will be specified in more detail in the sections on datatype encoding and message schema but are introduced here as an overview. +Semantic datatype +FIX datatype +The FIX semantic datatype of a field tells a data domain in a broad sense, for example, whether it is numeric or character data, or whether it represents a time or price. Simple Binary Encoding represents all of the semantic datatypes that FIX protocol has defined across all encodings. In message specifications, FIX datatype is declared with attribute semanticType. See the section FIX datatype summary for details. +Generic datatype +A datatype is defined as a combination of a value space and a lexical space. Value space is the range of its possible values while lexical space is how those values are represented in a message encoding, in this case SBE. Value space of datatypes is defined using the vocabulary in ISO/IEC 11404:2007 Information technology – General-Purpose Datatypes (GPD). That standard defines types independently of platform and programming language. +Encoding +Encoding tells how a field of a specific datatype is encoded on the wire. An encoding maps a FIX datatype to either a simple, primitive datatype, such as a 32-bit signed integer, or to a composite type. A composite type is composed of two or more simple primitive types. For example, the FIX datatype Price is encoded as a decimal, a composite type containing a mantissa and an exponent. Note that many fields may share a datatype and an encoding. The sections that follow explain the valid encodings for each datatype. +Metadata +Field metadata, part of a message schema, describes a field to application developers. Elements of field metadata are: + +Field ID, also known as FIX tag, is a unique identifier of a field for semantic purposes. For example, tag 55 identifies the Symbol field of an instrument. +Field name, as it is known in FIX specifications +The FIX semantic datatype and encoding type that it maps to +Valid values or data range accepted +Documentation + +Metadata is normally not sent on the wire with Simple Binary Encoding messages. It is necessary to possess the message schema that was used to encode a message in order to decode it. In other words, Simple Binary Encoding messages are not self-describing. Rather, message schemas are typically exchanged out-of-band between counterparties. +See section Message Schema for details. +Field presence +By default, fields are assumed to be required in a message. However, fields may be specified as optional. To indicate that a value is not set, a special null indicator value is sent on the wire. The null value varies according to datatype and encoding. Global defaults for null value may be overridden in a message schema by explicitly specifying the value that indicates nullness. +Alternatively, fields may be specified as constant. In which case, the data is not sent on the wire, but may be treated as constants by applications. +Default value +Default value handling is not specified by the encoding layer. A null value of an optional field does not necessarily imply that a default value should be applied. Rather, default handling is left to application layer specifications. +FIX datatype summary +FIX semantic types are mapped to binary field encodings as follows. See sections below for more detail about each type. +Schema attributes may restrict the range of valid values for a field. See section Common field schema attributes for details. + + + + + + + + + +FIX semantic type +Binary type +Value space (ISO/IEC 11404:2007) +Description + + + + +int +Integer encoding +integer range +An integer number + + +Length +Integer encoding +size +Field length in octets. Value must be non-negative. + + +TagNum +Integer encoding +ordinal +A field’s tag number. Value must be positive. + + +SeqNum +Integer encoding +ordinal +A field representing a message sequence number. Value must be positive + + +NumInGroup +Group dimension encoding +size +A counter representing the number of entries in a repeating group. Value must be positive. + + +DayOfMonth +Integer encoding +integer range 1..31 +A field representing a day during a particular month (values 1 to 31). + + +Qty +Decimal encoding +Scaled +A number representing quantity of a security, such as shares. The encoding may constrain values to integers, if desired. + + +float +Float encoding +real +A real number with binary representation of specified precision + + +Price +Decimal encoding +Scaled +A decimal number representing a price + + +PriceOffset +Decimal encoding +Scaled +A decimal number representing a price offset, which can be mathematically added to a Price. + + +Amt +Decimal encoding +Scaled +A field typically representing a Price times a Qty. + + +Percentage +Decimal encoding +Scaled +A field representing a percentage (e.g. 0.05 represents 5% and 0.9525 represents 95.25%). + + +char +Character +character +Single US-ASCII character value. Can include any alphanumeric character or punctuation. All char fields are case sensitive (i.e. m != M). + + +String +Fixed-length character array +array element = character +A fixed-length character array of ASCII encoding + + +String +Variable-length data encoding +characterstring +Alpha-numeric free format strings can include any character or punctuation. All String fields are case sensitive (i.e. morstatt != Morstatt). ASCII encoding. + + +String—EncodedText +String encoding +characterstring +Non-ASCII string. The character encoding may be specified by a schema attribute. + + +XMLData +String encoding +characterstring +Variable-length XML. Must be paired with a Length field. + + +data +Fixed-length data +array element=octet +Fixed-length non-character data + + +data +Variable-length data encoding +octetstring +Variable-length data. Must be paired with a Length field. + + +Country +Fixed-length character array; size = 2 or a subset of values may use Enumeration encoding +array (1..2) of character +ISO 3166-1:2013 Country code + + +Currency +Fixed-length character array; size = 3 or a subset of values may use Enumeration encoding +array (1..3) of character +ISO 4217:2015 Currency code (3 character) + + +Exchange +Fixed-length character array; size = 4 or a subset of values may use Enumeration encoding +array (1..4) of character +ISO 10383:2012 Market Identifier Code (MIC) + + +Language +Fixed-length character array; size = 2 or a subset of values may use Enumeration encoding +array (1..2) of character +National language - uses ISO 639-1:2002 standard + + +Implicit enumeration—char or int +Enumeration encoding +state +A single choice of alternative values + + +Boolean +Boolean encoding +boolean +Values true or false + + +MultipleCharValue +Multi-value choice encoding +set element = character +Multiple choice of a set of values + + +MultipleStringValue +Multi-value choice encoding. String choices must be mapped to int values. +set element = characterstring +Multiple choice of a set of values + + +MonthYear +MonthYear encoding +record +A flexible date format that must include month and year at least but may also include day or week. + + +UTCTimestamp +Date and time encoding +time +Time/date combination represented in UTC (Universal Time Coordinated, also known as “GMT”) + + +UTCTimeOnly +Date and time encoding +time +Time-only represented in UTC (Universal Time Coordinated, also known as “GMT”) + + +UTCDateOnly +Date and time encoding +time +Date represented in UTC (Universal Time Coordinated, also known as “GMT”) + + +LocalMktDate +Local date encoding +time +Local date (as opposed to UTC) + + +TZTimeOnly +TZTimeOnly encoding +time +Time of day + + +TZTimestamp +TZTimestamp encoding +time +Time/date combination representing local time with an offset to UTC to allow identification of local time and timezone offset of that time. The representation is based on ISO 8601:2004 + + + +The FIX semantic types listed above are spelled and capitalized exactly as they are in the FIX repository from which official FIX documents and references are derived. +Common field schema attributes +Schema attributes alter the range of valid values for a field. Attributes are optional unless specified otherwise. + + + + + + + +Schema attribute +Description + + + + +presence=required +The field must always be set. This is the default presence. Mutually exclusive with nullValue. + + +presence=constant +The field has a constant value that need not be transmitted on the wire. Mutually exclusive with value attributes. + + +presence=optional +The field need not be populated. A special null value indicates that a field is not set. The presence attribute may be specified on either on a field or its encoding. + + +nullValue +A special value that indicates that an optional value is not set. See encodings below for default nullValue for each type. Mutually exclusive with presence=required and constant. + + +minValue +The lowest valid value of a range. Applies to scalar datatypes, but not to String or datatypes. + + +maxValue +The highest valid value of a range (inclusive unless specified otherwise). Applies to scalar datatypes, but not to String or datatypes. + + +semanticType +Specifies the FIX semantic type of a field or encoding. It may be specified on either a field or its encoding. + + + +Inherited attributes +The attributes listed above apply to a field element or its encoding (wire format). Any attributes specified on an encoding are inherited by fields that use that encoding. +Non-FIX types +Encodings may be added to SBE messages that do not correspond to listed FIX datatypes. In that case, the encoding and fields that use the encoding will not have a semanticType attribute. +Integer encoding +Integer encodings should be used for cardinal or ordinal number fields. Signed integers are encoded in a two’s complement binary format. +Primitive type encodings +Numeric datatypes may be specified by range and signed or unsigned attribute. Integer types are intended to convey common platform primitive datatypes as they reside in memory. An integer type should be selected to hold the maximum range of values that a field is expected to hold. + + + +Primitive type +Description +Length (octets) + + + + +int8 +Signed byte +1 + + +uint8 +Unsigned byte / single-byte character +1 + + +int16 +16-bit signed integer +2 + + +uint16 +16-bit unsigned integer +2 + + +int32 +32-bit signed integer +4 + + +uint32 +32-bit unsigned integer +4 + + +int64 +64-bit signed integer +8 + + +uint64 +64-bit unsigned integer +8 + + + +Range attributes for integer fields +The default data range and null indicator are listed below for each integer encoding. +A message schema may optionally specify a more restricted range of valid values for a field. +For optional fields, a special null value is used to indicate that a field value is not set. The default null indicator may also be overridden by a message schema. +Required and optional fields of the same primitive type have the same data range. The null value must not be set for a required field. + + + +Schema attribute +int8 +uint8 +int16 +uint16 +int32 +uint32 +int64 +uint64 + + + + +minValue +–127 +0 +–32767 +0 +–231 + 1 +0 +–263 + 1 +0 + + +maxValue +127 +254 +32767 +65534 +231 – 1 +232 – 2 +263 – 1 +264 – 2 + + +nullValue +–128 +255 +–32768 +65535 +–231 +232 – 1 +–263 +264 – 1 + + + +Byte order +The byte order of integer fields, and for derived types that use integer components, is specified globally in a message schema. Little-Endian order is the default encoding, meaning that the least significant byte is serialized first on the wire. +See section Message schema attributes for the specification, including byteOrder. Message schema designers should specify the byte order most appropriate to their system architecture and that of their counterparties. +Integer encoding specifications +By nature, integers map to simple encodings. These are valid encoding specifications for each of the integer primitive types. +<type name="int8" primitiveType="int8" /> +<type name="int16" primitiveType="int16" /> +<type name="int32" primitiveType="int32" /> +<type name="int64" primitiveType="int64" /> +<type name="uint8" primitiveType="uint8" /> +<type name="uint16" primitiveType="uint16" /> +<type name="uint32" primitiveType="uint32" /> +<type name="uint64" primitiveType="uint64" /> +Examples of integer fields +Examples show example schemas and encoded bytes on the wire as hexadecimal digits in Little-Endian byte order. +Example integer field specification +<field type="uint32" name="ListSeqNo" id="67" semanticType="int" + description="Order number within the list" /> +Value on the wire - uint32 value decimal 10,000, hexadecimal 2710. +10270000 +Optional field with a valid range 0-6 +<type name="range06" primitiveType="uint8" maxValue="6" + presence="optional" nullValue="255" /> +<field type="range06" name="MaxPriceLevels" id="1090" + semanticType="int"/> +Wire format of uint8 value decimal 3. +03 +Sequence number field with integer encoding +<field type="uint64" name="MsgSeqNum" id="34" + semanticType="SeqNum" /> +Wire format of uint64 value decimal 100,000,000,000, hexadecimal 174876E800. +00e8764817000000 +Wire format of uint16 value decimal 10000, hexadecimal 2710. +1027 +Wire format of uint32 null value 232 - 1 +ffffffff +Decimal encoding +Decimal encodings should be used for prices and related monetary data types like PriceOffset and Amt. +FIX specifies Qty as a float type to support fractional quantities. However, decimal encoding may be constrained to integer values if that is appropriate to the application or market. +Composite encodings +Prices are encoded as a scaled decimal, consisting of a signed integer mantissa and signed exponent. For example, a mantissa of 123456 and exponent of -4 represents the decimal number 12.3456. +Mantissa +Mantissa represents the significant digits of a decimal number. Mantissa is a commonly used term in computing, but it is properly known in mathematics as significand or coefficient. +Exponent +Exponent represents scale of a decimal number as a power of 10. +Floating point and fixed point encodings +A floating-point decimal transmits the exponent on the wire while a fixed-point decimal specifies a fixed exponent in a message schema. A constant negative exponent specifies a number of assumed decimal places to the right of the decimal point. +Implementations should support both 32-bit and 64-bit mantissa. The usage depends on the data range that must be represented for a particular application. It is expected that an 8-bit exponent should be sufficient for all FIX uses. + + + +Encoding type +Description +Backing primitives +Length (octets) + + + + +decimal +Floating-point decimal +Composite: int64 mantissa, int8 exponent +9 + + +decimal64 +Fixed-point decimal +int64 mantissa, constant exponent +8 + + +decimal32 +Fixed-point decimal +int32 mantissa, constant exponent +4 + + + +Optionally, implementations may support any other signed integer types for mantissa and exponent. +Range attributes for decimal fields +The default data ranges and null indicator are listed below for each decimal encoding. +A message schema may optionally specify a more restricted range of valid values for a field. For optional fields, a special mantissa value is used to indicate that a field value is null. + + + +Schema attribute +decimal +decimal64 +decimal32 + + + + +exponent range +–128 to 127 +–128 to 127 +–128 to 127 + + +mantissa range +–263 + 1 to 263 – 1 +–263 + 1 to 263 – 1 +–231 + 1 to 231 – 1 + + +minValue +(–263 + 1) * 10127 +(–263 + 1) * 10127 +(–231 + 1) * 10127 + + +maxValue +(263 – 1) * 10127 +(263 – 1) * 10127 +(231 – 1) * 10127 + + +nullValue +mantissa=–263, exponent=–128 +mantissa =–263 +mantissa =–231 + + + +Encoding specifications for decimal types +Decimal encodings are composite types, consisting of two subfields, mantissa and exponent. The exponent may either be serialized on the wire or may be set to constant. A constant exponent is a way to specify an assumed number of decimal places. +Decimal encoding specifications that an implementation must support +<composite name="decimal" > + <type name="mantissa" primitiveType="int64" /> + <type name="exponent" primitiveType="int8" /> +</composite> + +<composite name="decimal32" > + <type name="mantissa" primitiveType="int32" /> + <type name="exponent" primitiveType="int8" + presence="constant">-2</type> +</composite> + +<composite name="decimal64"> + <type name="mantissa" primitiveType="int64" /> + <type name="exponent" primitiveType="int8" + presence="constant">-2</type> +</composite> +Composite encoding padding +When both mantissa and exponent are sent on the wire for a decimal, the elements are packed by default. However, byte alignment may be controlled by specifying offset of the exponent within the composite encoding. See section Element offset within a composite type for details. +Examples of decimal fields +Examples show encoded bytes on the wire as hexadecimal digits, little-endian. +FIX Qty datatype is a float type, but a decimal may be constrained to integer values by setting exponent to zero. +<composite name="intQty32" semanticType="Qty"> + <type name="mantissa" primitiveType="int32" /> + <type name="exponent" primitiveType="int8" + presence="constant">0</type> +</composite> +Field inherits semanticType from encoding +<field type="intQty32" name="OrderQty" id="38" + description="Total number of shares" /> +Wire format of decimal 123.45 with 2 significant decimal places. +3930000000000000fe +Wire format of decimal64 123.45 with 2 significant decimal places. Schema attribute exponent = -2 +3930000000000000 +Wire format of decimal32 123.45 with 2 significant decimal places. Schema attribute exponent = -2 +39300000 +Float encoding +Binary floating point encodings are compatible with IEEE Standard for Floating-Point Arithmetic (IEEE 754-2008). They should be used for floating point numeric fields that do not represent prices or monetary amounts. Examples include interest rates, volatility and dimensionless quantities such as ratios. On the other hand, decimal prices should be encoded as decimals; see section Decimal encoding for details. +Primitive types +Both single and double precision encodings are supported as primitive datatypes. See the IEEE 754-2008 standard for ranges and details of the encodings. + + + +Primitive type +Description +IEEE 754-2008 format +Length (octets) + + + + +float +Single precision floating point +binary32 +4 + + +double +Double precision floating point +binary64 +8 + + + +Null values +For both float and double precision encodings, null value of an optional field is represented by the Not-a-Number format (NaN) of the standard encoding. Technically, it indicated by the so-called quiet NaN. +Byte order +Like integer encodings, floating point encodings follow the byte order specified by message schema. See section Message schema attributes for the specification, including byteOrder. +Float encoding specifications +These are valid encoding specifications for each of the floating point primitive types. +<type name="float" primitiveType="float" /> +<type name="double" primitiveType="double" /> +Examples of floating point fields +Examples show encoded bytes on the wire as hexadecimal digits, little-endian. +A single precision ratio +<type name="ratio" primitiveType="float" /> + +<field type="ratio" name="CurrencyRatio" id="1382" + semanticType="float"/> +Wire format of float 255.678 +91ad7f43 +Wire format of double 255.678 +04560e2db2f56f40 +String encodings +Character data may either be of fixed size or variable size. In Simple Binary Encoding, fixed-length fields are recommended in order to support direct access to data. Variable-length encoding should be reserved for character strings that cannot be constrained to a specific size. It may also be used for non-ASCII encoded strings. +Character +Character fields hold a single character. They are most commonly used for field with character code enumerations. See section Enumeration encoding for details. + + + +FIX datatype +Description +Backing primitive +Length (octet) + + + + +char +A single US-ASCII character +char +1 + + + +Range attributes for char fields +Valid values of a char field are printable characters of the US-ASCII character set (codes 20 to 7E hex.) The implicit nullValue is the NUL control character (code 0). + + + +Schema attribute +char + + + + +minValue +hex 20 + + +maxValue +hex 7e + + +nullValue +0 + + + +Encoding of char type +This is the standard encoding for char type. +<type name="char" primitiveType="char" semanticType="char" /> +Wire format of char encoding of “A” (ASCII value 65, hexadecimal 41) +41 +Fixed-length character array +Character arrays are allocated a fixed space in a message, supporting direct access to fields. A fixed size character array is distinguished from a variable length string by the presence of a length schema attribute or a constant attribute. + + + + + + + + + + +FIX datatype +Description +Backing primitives +Length (octets) +Required schema attribute + + + + +String +character array +Array of char of specified length, padded by NUL character if a string is shorter than the length specified for a field. +Specified by length attribute +length (except may be inferred from a constant value, if present). + + + +A length attribute set to zero indicates variable length. See section Variable-length string encoding for details. +Encoding specifications for fixed-length character array +A fixed-length character array encoding must specify primitiveType=“char” and a length attribute is required. +Range attributes minValue and maxValue do not apply to fixed-length character arrays. +US-ASCII is the default encoding of character arrays to conform to usual FIX values. The characterEncoding attribute may be specified to override encoding. +Examples of fixed-length character arrays +A typical string encoding specification +<type name="string6" primitiveType="char" semanticType="String" + length="6" /> + +<field type="string6" name="Symbol" id="55" /> +Wire format of a character array in character and hexadecimal formats +M S F T +4d5346540000 +A character array constant specification +<type name="EurexMarketID" semanticType="Exchange" + primitiveType="char" length="4" description="MIC code" + presence="constant">XEUR</type> + +<field type="EurexMarketID" name="MarketID" id="1301" /> +Variable-length string encoding +Variable-length string encoding is used for variable length ASCII strings or embedded non-ASCII character data (like EncodedText field). A separate length field coveys the size of the field. +On the wire, length immediately precedes the data. +The length subfield may not be null, but may be set to zero for an empty string. In that case, no space is reserved for the data. No distinction is made at an encoding layer between an empty string and a null string. Semantics of an empty variable-length string should be specified at an application layer. + + + + + + + + + +FIX datatype +Description +Backing primitives +Length (octets) + + + + +Length +The length of variable data in octets +primitiveType=“uint8” or “uint16” May not hold null value. +1 or 2 + + +data +Raw data +Array of octet of size specified in associated Length field. The data field itself should be specified as variable length. primitiveType=“uint8” length=“0” indicates variable length +variable + + + +Optionally, implementations may support any other unsigned integer types for length. +Range attributes for string Length + + + +Schema attribute +length uint8 +length uint16 +data + + + + +minValue +0 +0 +N/A + + +maxValue +254 +65534 +N/A + + + +If the Length element has minValue and maxValue attributes, it specifies the minimum and maximum length of the variable-length data. +Range attributes minValue , maxValue, and nullValue do not apply to the data element. +If a field is required, both the Length and data fields must be set to a “required” attribute. +Encoding specifications for variable-length string +Variable length string is encoded as a composite type, consisting of a length sub field and data subfield. The length attribute of the varData element is set to zero in the XML message schema as special value to indicate that the character data is of variable length. +To map an SBE data field specification to traditional FIX, the field ID of a data field is used. Its associated length is implicitly contained by the composite type rather than specified as a separate field. +Encoding specification for variable length data up to 65535 octets +<composite name="varString" description="Variable-length string"> + <type name="length" primitiveType="uint16" semanticType="Length"/> + <type name="data" length="0" primitiveType="uint8" + semanticType="data" characterEncoding="UTF-16"/> +</composite> + +<data name="SecurityDesc" id="107" type="varString"/> +The characterEncoding attribute tells which variable-sized encoding is used if the data field represents encoded text. UTF-8 is the recommended encoding, but there is no default in the XML schema +Example of a variable-length string field +Example shows encoded bytes on the wire. +Wire format of variable-length String in character and hexadecimal formats, preceded by uint16 length of 4 octets in little-endian byte order +M S F T +04004d534654 +Data encodings +Raw data is opaque to SBE. In other words, it is not constrained by any value range or structure known to the messaging layer other than length. Data fields simply convey arrays of octets. +Data may either be of fixed-length or variable-length. In Simple Binary Encoding, fixed-length data encoding may be used for data of predetermined length, even though it does not represent a FIX datatype. Variable-length encoding should be reserved for raw data when its length is not known until run-time. +Fixed-length data +Data arrays are allocated as a fixed space in a message, supporting direct access to fields. A fixed size array is distinguished from a variable length data by the presence of a length schema attribute rather than sending length on the wire. + + + + + + + + + + +FIX datatype +Description +Backing primitives +Length (octets) +Required schema attribute + + + + +data +octet array +Array of uint8 of specified length. +Specified by length attribute +length + + + +Encoding specifications for fixed-length data +A fixed-length octet array encoding should specify primitiveType=“uint8” and a length attribute is required. +Data range attributes minValue and maxValue do not apply. +Since raw data is not constrained to a character set, characterEncoding attribute should not be specified. +Example of fixed-length data encoding +A fixed-length data encoding specification for a binary user ID +<type name="uuid" primitiveType="uint8" length="16" description="RFC 4122 compliant UUID"/> + +<field type="uuid" name="Username" id="553" /> +Variable-length data encoding +Variable-length data is used for variable length non-character data (such as RawData). A separate length field conveys the size of the field. On the wire, length immediately precedes the data. +The length subfield may not be null, but it may be set to zero. In that case, no space is reserved for the data. Semantics of an empty variable-length data element should be specified at an application layer. + + + + + + + + + +FIX datatype +Description +Backing primitives +Length (octets) + + + + +Length +The length of variable data in octets +primitiveType=“uint8” or “uint16” May not hold null value. +1 or 2 + + +data +Raw data +Array of octet of size specified in associated Length field. The data field itself should be specified as variable length. primitiveType=“uint8” +variable + + + +Optionally, implementations may support any other unsigned integer types for length. +Range attributes for variable-length data Length + + + +Schema attribute +length uint8 +length uint16 +data + + + + +minValue +0 +0 +N/A + + +maxValue +254 +65534 +N/A + + + +If the Length field has minValue and maxValue attributes, it specifies the minimum and maximum length of the variable-length data. Data range attributes minValue , maxValue, and nullValue do not apply to a data field. +If a field is required, both the Length and data fields must be set to a “required” attribute. +Encoding specifications for variable-length data +Variable length data is encoded as composite type, consisting of a length sub field and data subfield. +To map an SBE data field specification to traditional FIX, the field ID of a data field is used. Its associated length is implicitly contained by the composite type rather than specified as a separate field. +Encoding specification for variable length data up to 65535 octets +<composite name="DATA" description="Variable-length data"> + <type name="length" primitiveType="uint16" semanticType="Length"/> + <type name="data" length="0" primitiveType="uint8" semanticType="data" /> +</composite> + +<data name="RawData" id="96" type="DATA"/> +Example of a data field +Example shows encoded bytes on the wire. +Wire format of data in character and hexadecimal formats, preceded by uint16 length of 4 octets in little-endian byte order +M S F T +04004d534654 +MonthYear encoding +MonthYear encoding contains four subfields representing respectively year, month, and optionally day or week. A field of this type is not constrained to one date format. One message may contain only year and month while another contains year, month and day in the same field, for example. +Values are distinguished by position in the field. Year and month must always be populated for a non-null field. Day and week are set to special value indicating null if not present. If Year is set to the null value, then the entire field is considered null. + + + +Subfield +Primitive type +Length (octets) +Null value + + + + +Year +uint16 +2 +65535 + + +Month (1-12) +uint8 +1 +— + + +Day of the month(1-31) optional +uint8 +1 +255 + + +Week of the month (1-5) optional +uint8 +1 +255 + + + +Composite encoding padding +The four subfields of MonthYear are packed at an octet level by default. However, byte alignment may be controlled by specifying offset of the elements within the composite encoding. See section Element offset within a composite type for details. +Encoding specifications for MonthYear +MonthYear datatype is based on a composite encoding that carries its required and optional elements. +The standard encoding specification for MonthYear +<composite name="monthYear" semanticType="MonthYear"> + <type name="year" primitiveType="uint16" presence="optional" + nullValue="65536" /> + <type name="month" primitiveType="uint8" minValue="1" maxValue="12" /> + <type name="day" primitiveType="uint8" minValue="1" maxValue="31" + presence="optional" nullValue="255" /> + <type name="week" description="week of month" primitiveType="uint8" + minValue="1" maxValue="5" presence="optional" nullValue="255" /> +</composite> +Example MonthYear field specification + +Wire format of MonthYear 2014 June week 3 as hexadecimal +de0706ff03 +Date and time encoding +Dates and times represent Coordinated Universal Time (UTC). This is the preferred date/time format, except where regulations require local time with time zone to be reported (see time zone encoding below). +Epoch +Each time type has an epoch, or start of a time period to count values. For timestamp and date, the standard epoch is the UNIX epoch, midnight January 1, 1970 UTC. +A time-only value may be thought of as a time with an epoch of midnight of the current day. Like current time, the epoch is also referenced as UTC. +Time unit +Time unit tells the precision at which times can be collected. Time unit may be serialized on the wire if timestamps are of mixed precision. On the other hand, if all timestamps have the same precision, then time unit may be set to a constant in the message schema. Then it need not be sent on the wire. + + + + + + + + + + +FIX datatype +Description +Backing primitives +Length (octets) +Schema attributes + + + + +UTCTimestamp +UTC date/time Default: nanoseconds since Unix epoch Range Jan. 1, 1970 - July 21, 2554 +uint64 time +8 +epoch=”unix” (default) + + + +timeUnit = second or millisecond or microsecond or nanosecond May be constant +uint8 unit +1 + + + +UTCTimeOnly +UTC time of day only Default: nanoseconds since midnight today +uint64 time +8 + + + + +timeUnit = second or millisecond or microsecond or nanosecond May be constant +uint8 unit +1 + + + +UTCDateOnly +UTC calendar date Default: days since Unix epoch. Range: Jan. 1, 1970 - June 7, 2149 +uint16 +2 +epoch=”unix” (default) + + + +Encoding specifications for date and time +Time specifications use an enumeration of time units. See section Enumeration encoding for details. +Enumeration of time units: +<enum name="TimeUnit" encodingType="uint8"> + <validValue name="second">0</validValue> + <validValue name="millisecond">3</validValue> + <validValue name="microsecond">6</validValue> + <validValue name="nanosecond">9</validValue> +</enum> +Timestamp with variable time units: +<composite name="UTCTimestamp" description="UTC timestamp with precision on the wire" semanticType="UTCTimestamp" > + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" /> +</composite> +Timestamp with constant time unit: +<composite name="UTCTimestampNanos" description="UTC timestamp with nanosecond precision" semanticType="UTCTimestamp" > + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" presence="constant" valueRef="TimeUnit.nanosecond" /> +</composite> +Time only with variable time units: +<composite name="UTCTime" description="Time of day with precision on the wire" semanticType="UTCTimeOnly" > + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" /> +</composite> +Time only with constant time unit: +<composite name="UTCTimeNanos" description="Time of day with millisecond precision" semanticType="UTCTimeOnly" > + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" presence="constant" valueRef="TimeUnit.millisecond" /> +</composite> +Date only specification: +<type name="date" primitiveType="uint16" semanticType="UTCDateOnly" /> +Examples of date/time fields +timestamp 14:17:22 Friday, October 4, 2024 UTC (20,000 days and 14 hours, 17 minutes and 22 seconds since the UNIX epoch) with default schema attributes +<composite name="UTCTimestampNanos" description="UTC timestamp with nanosecond precision" semanticType="UTCTimestamp" > +<type name="time" primitiveType="uint64" /> +<type name="unit" primitiveType="uint8" presence="constant" valueRef="TimeUnit.nanosecond" /> +</composite> +Wire format of UTCTimestamp with constant time unit in little-Endian byte order +004047baa145fb17 +time 10:24:39.123456000 (37,479 seconds and 123456000 nanoseconds since midnight UTC) with default schema attributes +<composite name="UTCTimeOnlyNanos" description="UTC time of day with nanosecond precision" semanticType="UTCTimeOnly" > + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" presence="constant" valueRef="TimeUnit.nanosecond" /> +</composite> +Wire format of UTCTimeOnly +0010d74916220000 +date Friday, October 4, 2024 (20,000 days since UNIX epoch) with default schema attributes +<type name="date" primitiveType="uint16" semanticType="UTCDateOnly" /> +Wire format of UTCDateOnly +204e +Local date encoding +Local date is encoded the same as UTCDateOnly, but it represents local time at the market instead of UTC time. + + + + + + + + + + +FIX datatype +Description +Backing primitives +Length (octets) +Schema attributes + + + + +LocalMktDate +Local calendar date Default: days since Unix epoch. Range: Jan. 1, 1970 - June 7, 2149 local time +uint16 +2 +epoch=”unix” (default) + + + +The standard encoding specification for LocalMktDate +<type name="localMktDate" primitiveType="uint16" semanticType="LocalMktDate" /> +Local time encoding +Time with time zone encoding should only be used when required by market regulations. Otherwise, use UTC time encoding (see above). +Time zone is represented as an offset from UTC in the ISO 8601:2004 format ±hhmm. +TZTimestamp encoding +A binary UTCTimestamp followed by a number representing the time zone indicator as defined in ISO 8601:2004. + + + + + + + + + + +FIX datatype +Description +Backing primitives +Length (octets) +Schema attributes + + + + +TZTimestamp +date/time with timezone Default: nanoseconds since Unix epoch Range Jan. 1, 1970 - July 21, 2554 +uint64 +8 +epoch=”unix” (default) Represents Jan. 1, 1970 local time + + + +timeUnit = second or millisecond or microsecond or nanosecond May be constant +uint8 +1 + + + + +Time zone hour offset +int8 +1 +None + + + +Time zone minute offset +uint8 +1 +None + + + +Composite encoding padding +The subfields of TZTimestamp are packed at an octet level by default. However, byte alignment may be controlled by specifying offset of the elements within the composite encoding. See section Element offset within a composite type for details. +Standard TZTimestamp encoding specification +<composite name="tzTimestamp" semanticType="TZTimestamp"> + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" /> + <!-- Sign of timezone offset is on hour subfield --> + <type name="timezoneHour" primitiveType="int8" minValue="-12" maxValue="14" /> + <type name="timezoneMinute" primitiveType="uint8" maxValue="59" /> +</composite> +Wire format of TZTimestamp 8:30 17 September 2013 with Chicago time zone offset (-6:00) and nanosecond timeunit +0050d489fea2241309fa00 +TZTimeOnly encoding +A binary UTCTimeOnly followed by a number representing the time zone indicator as defined in ISO 8601:2004. +The time zone hour offset tells the number of hours different to UTC time. The time zone minute tells the number of minutes different to UTC. The sign telling ahead or behind UTC is on the hour subfield. + + + + + + + + + + +FIX datatype +Description +Backing primitives +Length (octets) +Schema attributes + + + + +TZTimeOnly +Time of day only with time zone Default: nanoseconds since midnight today, local time +uint64 +8 +None + + + +timeUnit = second or millisecond or microsecond or nanosecond May be constant +uint8 +1 +None + + + +Time zone hour offset +int8 +1 +None + + + +Time zone minute offset +uint8 +1 +None + + + +Composite encoding padding +The subfields of TZTimeOnly are packed at an octet level by default. However, byte alignment may be controlled by specifying offset of the elements within the composite encoding. See section Element offset within a composite type for details. +Standard TZTimeOnly encoding specification +<composite name="tzTimeOnly" semanticType="TZTimeOnly"> + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" /> + <!-- Sign of timezone offset is on hour subfield --> + <type name="timezoneHour" primitiveType="int8" + minValue="-12" maxValue="14" /> + <type name="timezoneMinute" primitiveType="uint8" minValue="0" + maxValue="59" /> +</composite> +Wire format of TZTimeOnly 8:30 with Chicago time zone offset (-6:00) +006c5ebe76000000fa00 +Enumeration encoding +An enumeration conveys a single choice of mutually exclusive valid values. +Primitive type encodings +An unsigned integer or character primitive type is selected to contain the number of choices. Implementations must support char and uint8 types. They may additionally support other unsigned integer types to allow more choices. + + + +Primitive type +Description +Length (octets) +Maximum number of choices + + + + +char +character +1 +95 + + +uint8 +8-bit unsigned integer +1 +255 + + + +Value encoding +If a field is of FIX datatype char, then its valid values are restricted to US-ASCII printable characters. See section Character for details. +If the field is of FIX datatype int, then a primitive integer datatype should be selected that can contain the number of choices. For most cases, an 8-bit integer will be sufficient, allowing 255 possible values. +Enumerations of other datatypes, such as String valid values specified in FIX, should be mapped to an integer wire format in SBE. +Encoding specification of enumeration +In a message schema, the choices are specified a <validValue> members of an <enum>. An <enum> specification must contain at least one <validValue>. +The name and value of a validValue element must be unique within an enumeration. +An <enum> element must have an encodingType attribute to specify the type of its values. Two formats of encodingType are acceptable: + +In-line style: the value of encodingType is its primitive datatype. +Reference style: the value of encodingType is the name of a <type> element that specifies the wire format. + +The length of a <type> associated to an enumeration must be 1. That is, enumerations should only be backed by scalar types, not arrays. +Enumeration examples +These examples use a char field for enumerated code values. +Example enum lists acceptable values and gives the underlying encoding, which in this case is char (in-line style) +<enum name="SideEnum" encodingType="char"> + <validValue name="Buy">1</validValue> + <validValue name="Sell">2</validValue> + <validValue name="SellShort">5</validValue> + <validValue name="SellShortExempt">6</validValue> + <!-- not all FIX values shown --> +</enum> +Reference to type: This specification is equivalent to the one above. +<type name="charEnumType" primitiveType="char"/> + <enum name="SideEnum" encodingType="charEnumType"> + <!-- valid values as above --> +</enum> +Side field specification references the enumeration type +<field name="Side" type="SideEnum" id="54" /> +Wire format of Side “Buy” code as hexadecimal +01 +Constant field of an enumeration value +A constant field may be specified as a value of an enumeration. The attribute valueRef is a cross-reference to validValue entry by symbolic name. +Example of a char field using a constant enum value +<enum name="PartyIDSourceEnum" encodingType="char"> + <validValue name="BIC">B</validValue> + <validValue name="GeneralIdentifier">C</validValue> + <validValue name="Proprietary">D</validValue> +</enum> + +<field type="PartyIDSourceEnum" name="PartyIDSource" id="447" + description="Party ID source is fixed" presence="constant" + valueRef="PartyIDSourceEnum.GeneralIdentifier" /> +Boolean encoding +A Boolean field is a special enumeration with predefined valid values: true and false. Like a standard enumeration, an optional Boolean field may have nullValue that indicates that the field is null (or not applicable). +Standard encoding specifications for required and optional Boolean fields +<enum name="booleanEnum" encodingType="uint8" semanticType="Boolean"> + <validValue name="false">0</validValue> + <validValue name="true">1</validValue> +</enum> + +<enum name="optionalBoolean" encodingType="uint8" semanticType="Boolean"> + <validValue name="false">0</validValue> + <validValue name="true">1</validValue> + <validValue name="nullValue">255</validValue> +</enum> +Example optional Boolean field +<field type="optionalBoolean" name="SolicitedFlag" id="377" /> +Wire format of true value as hexadecimal +01 +Wire format of false value as hexadecimal +00 +Wire format of null Boolean (or N/A) value as hexadecimal +ff +Multi-value choice encoding +A multi-value field conveys a choice of zero or more non-exclusive valid values. +Primitive type encodings +The binary encoding uses a bitset (a fixed-size sequence of bits, also known as bitmap, bit array or bit vector) to represent up to 64 possible choices. The encoding is backed by an unsigned integer. The smallest unsigned primitive type should be selected that can contain the number of valid choices. + + + +Primitive type +Description +Length (octets) +Maximum number of choices + + + + +uint8 +8-bit unsigned integer +1 +8 + + +uint16 +16-bit unsigned integer +2 +16 + + +uint32 +32-bit unsigned integer +4 +32 + + +uint64 +64-bit unsigned integer +8 +64 + + + +Like other integer-backed encodings, multi-value encodings follow the byte order specified by message schema when serializing to the wire. See section Message schema attributes for the specification, including byteOrder. +Value encoding +Each choice is assigned a bit of the primitive integer encoding, starting with the least significant bit. For each choice the value is selected or not, depending on whether it corresponding bit is set or cleared. +Any remaining unassigned bits in an octet should be cleared. +There is no explicit null value for multi-value choice encoding other than to set all bits off when no choices are selected. +Encoding specification of multi-value choice +In a message schema, the choices are specified as <choice> members of an <set> element. Choices are assigned values as an ordinal of bits in the bit set. The first Choice “0” is assigned the least significant bit; choice “1” is the second bit, and so forth. +The name and value (bit position) must be unique for element of a set. +A <set> element must have an encodingType attribute to specify the wire format of its values. Two formats of encodingType are recognized : + +In-line style: the value of encodingType is its primitive datatype. +Reference style: the value of encodingType is the name of a <type> element that specifies the wire format. + +The length of a <type> associated to an bitset must be 1. That is, bitsets should not be specified as arrays. +Multi-value example +Example of a multi-value choice (was MultipleCharValue in tag-value encoding) Encoding type is in-line style. +<set name="FinancialStatusEnum" encodingType="uint8"> + <choice name="Bankrupt">0</choice> + <choice name="Pending delisting">1</choice> + <choice name="Restricted">2</choice> +</set> +Reference to type. This is equivalent to the example above. +<type name="u8Bitset" primitiveType="uint8"/> + +<set name="FinancialStatusEnum" encodingType="u8Bitset"> +<!--choices as above --> +</set> +A field using the multi-choice encoding +<field type="FinancialStatus" name="FinancialStatusEnum" + id="291" semanticType="MultipleCharValue"/> +Wire format of choices “Bankrupt” + “Pending delisting” (first and second bits set) +03 +Field value validation +These validations apply to message field values. +If a value violation is detected on a received message, the message should be rejected back to the counterparty in a way appropriate to the session protocol. + + + + + + + +Error condition +Error description + + + + +Field value less than minValue +The encoded value falls below the specified valid range. + + +Field value greater than maxValue +The encoded value exceeds the specified valid range. + + +Null value set for required field +The null value of a datatype is invalid for a required field. + + +String contains invalid characters +A String contains non-US-ASCII printable characters or other invalid sequence if a different characterEncoding is specified. + + +Required subfields not populated in MonthYear +Year and month must be populated with non-null values, and the month must be in the range 1-12. + + +UTCTimeOnly exceeds day range +The value must not exceed the number of time units in a day, e.g. greater than 86400 seconds. + + +TZTimestamp and TZTimeOnly has missing or invalid time zone +The time zone hour and minute offset subfields must correspond to an actual time zone recognized by international standards. + + +Value must match valid value of an enumeration field +A value is invalid if it does not match one of the explicitly listed valid values. + + + +Message Structure +Message Framing +SBE messages have no defined message delimiter. Version 2.0 of SBE makes it possible to walk the elements of a message to determine its limit, even when the message has been extended. Nevertheless, since internal framing depends on a correct starting point and not encountering malformed messages, it may be desirable to use an external framing protocol when used with transports that do not preserve message boundaries, such as when they are transmitted on a streaming session protocol or when persisting messages in storage. +Simple Open Framing Header +FIX Protocol Ltd. offers the Simple Open Framing Header standard for framing messages encoded with binary wire formats, such as Simple Binary Encoding. +The framing header provides two features: + +An overall message size including headers to support framing +An identifier of the encoding used in the message payload. This supports selecting the correct decoder in the case where multiple message encodings are used on a session. It also aids tooling such as protocol analyzers to identify message protocols contained in network packets. + +While the Simple Open Framing Header specification is normative, the following is an interpretation of that standard as an SBE encoding. Note that the framing standard specifies that the framing header will always be encoded in big-endian byte order, also known as network byte order. +Simple Open Framing Header as an SBE composite encoding (big-endian) +<composite name="framingHeader"/> + <type name="messageLength" primitiveType="uint32" /> + <type name="encodingType" primitiveType="uint16" /> +</composite> +The values of encodingType used to indicate SBE payloads are currently defined as: + + + +Encoding +encodingType value + + + + +SBE version 1.0 big-endian +0x5BE0 + + +SBE version 1.0 little-endian +0xEB50 + + + +The Simple Open Framing Header specification also lists values for other wire formats. +SBE Message Encoding Header +The purpose of the message encoding header is to tell which message template was used to encode the message and to give information about the size of the message body to aid in decoding, even when a message template has been extended in a later version. See section Schema Extension Mechanism for details. +The fields of the SBE message header are: + +Block length of the message root - the total space reserved for the root level of the message not counting any repeating groups or variable-length fields. +Template ID - identifier of the message template +Schema ID - identifier of the message schema that contains the template +Schema version - the version of the message schema in which the message is defined +Group count - the number of repeating groups in the root level of the message +Variable-length field count - the number of variable-length fields in the root level of the message + +Block length is specified in a message schema, but it is also serialized on the wire. By default, block length is set to the sum of the sizes of body fields in the message. However, it may be increased to force padding at the end of block. See section Padding at end of a message or group for details. +Message header schema +The header fields precede the message body of every message in a fixed position as shown below. Each of these fields must be encoded as an unsigned integer type. The encoding must carry the name “messageHeader”. +The message header is encoded in the same byte order as the message body, as specified in a message schema. See section Message schema attributes for the specification. +Recommended message header encoding +<composite name="messageHeader" description="Template ID 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"/> + <type name="numGroups" primitiveType="uint16" /> + <type name="numVarDataFields" primitiveType="uint16" /> +</composite> +The recommended header encoding is 12 octets. + + + +Element +Description +Primitive type +Length (octets) +Offset + + + + +blockLength +Root block length +uint16 +2 +0 + + +templateId +Template ID +uint16 +2 +2 + + +schemaId +Schema ID +uint16 +2 +4 + + +version +Schema Version +uint16 +2 +6 + + +numGroups +Number of repeating groups +uint16 +2 +8 + + +numVarDataFields +Number of variable-length fields +uint16 +2 +10 + + + +Optionally, implementations may support any other unsigned integer types for blockLength. +Root block length +The total space reserved for the root level of the message not counting any repeating groups or variable-length fields. (Repeating groups have their own block length; see section Repeating groups for details. Length of a variable-length Data field is given by its corresponding Length field; see section Variable-length string encoding for details.) Block length only represents message body fields; it does not include the length of the message header itself, which is a fixed size. +The block size must be at least the sum of lengths of all fields at the root level of the message, and that is its default value. However, it may be set larger to reserve more space to effect alignment of blocks. This is specified by setting the blockLength attribute in a message schema. +Template ID +The identifier of a message type in a message schema. See section Message schema attributes for the specification. +Schema ID +The identifier of a message schema. See section Message schema attributes for the specification. +Schema version +The version number of the message schema that was used to encode a message. See section Message schema attributes for the specification. +Number of repeating groups +A count of repeating groups at the root level of the message. The count does not include nested repeating groups. +Number of variable-length fields +A count of the variable-length fields at the root level of the message. The count does not include variable-length fields within repeating groups. +Message Body +The message body conveys the business information of the message. +Data only on the wire +In SBE, fields of a message occupy proximate space without delimiters or metadata, such as tags. +Direct access +Access to data is positional, guided by a message schema that specifies a message type. +Data fields in the message body correspond to message schema fields; they are arranged in the same sequence. The first data field has the type and size specified by the first message schema field, the second data field is described by the second message schema field, and so forth. Since a message decoder follows the field descriptions in the schema for position, it is not necessary to send field tags on the wire. +In the simplest case, a message is flat record with a fixed length. Based on the sequence of field data types, the offset to a given data field is constant for a message type. This offset may be computed in advance, based on a message schema. Decoding a field consists of accessing the data at this fixed location. +Field position and padding +No padding by default +By default, there is no padding between fields. In other words, a field value is packed against values of its preceding and following fields. No consideration is given to byte boundary alignment. +By default, the position of a field in a message is determined by the sum of the sizes of prior fields, as they are defined by the message schema. +<field name="ClOrdID" id="11" type="string14" + semanticType="String"/> +<field name="Side" id="54" type="char" semanticType="char"/> +<field name="OrderQty" id="38" type="intQty32" + semanticType="Qty"/> +<field name="Symbol" id="55" type="string8" semanticType="String"/> + + + +Field +Size +Offset + + + + +ClOrdID +14 +0 + + +Side +1 +14 + + +OrderQty +4 +15 + + +Symbol +8 +19 + + + +Field offset specified by message schema +If a message designer wishes to introduce padding or control byte boundary alignment or map to an existing data structure, field offset may optionally be specified in a message schema. Field offset is the number of octets from the start of the message body or group to the first octet of the field. Offset is a zero-based index. +If specified, field offset must be greater than or equal to the sum of the sizes of prior fields. In other words, an offset is invalid if it would cause fields to overlap. +Extra octets specified for padding should never be interpreted as business data. They should be filled with binary zeros. +Example of fields with specified offsets +<field name="ClOrdID" id="11" type="string14" offset="0" + semanticType="String"/> +<field name="Side" id="54" type="char" offset="14" + semanticType="char"/> +<field name="OrderQty" id="38" type="intQty32" offset="16" + semanticType="Qty"/> +<field name="Symbol" id="55" type="string8" offset="20" + semanticType="String"/> + + + +Field +Size +Padding preceding field +Offset + + + + +ClOrdID +14 +0 +0 + + +Side +1 +0 +14 + + +OrderQty +4 +1 +16 + + +Symbol +8 +0 +20 + + + +Padding at end of a message or group +In order to force messages or groups to align on byte boundaries or map to an existing data structure, they may optionally be specified to occupy a certain space with a blockLength attribute in the message schema. The extra space is padded at the end of the message or group. If specified, blockLength must be greater than or equal to the sum of the sizes of all fields in the message or group. +The blockLength attribute applies only to the portion of message that contains fix-length fields; it does not apply to variable-length data elements of a message. +Extra octets specified for padding should be filled with binary zeros. +Example of blockLength specification for 24 octets +<message name="ListOrder" id="2" blockLength="24"> +Repeating Groups +A repeating group is a message structure that contains a variable number of entries. Each entry contains fields specified by a message schema. +The order and data types of the fields are the same for each entry in a group. That is, the entries are homogeneous. Position of a given field within any entry is fixed, with the exception of variable-length fields. +A message may have no groups or an unlimited number of repeating groups specified in its schema. +Schema specification of a group +A repeating group is defined in a message schema by adding a <group> element to a message template. An unlimited number of <field> elements may be added to a group, but a group must contain at least one field. +Example repeating group encoding specification +<group name="Parties" id="1012" blockLength="16"> + <field name="PartyID" id="448" type="string14" + semanticType="String"/> + <field name="PartyIDSource" id="447" type="char" + semanticType="char"/> + <field name="PartyRole" id="452" type="uint8" semanticType="int"/> +</group> +Group block length +The blockLength part of a group dimension represents total space reserved for each group entry, not counting any nested repeating groups or variable-length fields. (Length of a variable-length Data field is given by its corresponding Length field.) Block length only represents message body fields; it does not include the length of the group dimension itself, which is a fixed size. +Padding at end of a group entry +By default, the space reserved for an entry is the sum of a group’s field lengths, as defined by a message schema, without regard to byte alignment. +The space reserved for an entry may optionally be increased to effect alignment of entries or to plan for future growth. This is specified by adding the group attribute blockLength to reserve a specified number of octets per entry. If specified, the extra space is padded at the end of each entry and should be set to zeroes by encoders. The blockLength value does not include the group dimensions itself. +Note that padding will only result in deterministic alignment if the repeating group contains no variable-length fields. +Entry counter +Each group is associated with a required counter field of semantic data type NumInGroup to tell how many entries are contained by a message. The value of the counter is a non-negative integer. See section Encoding of repeating group dimensions for details. +Empty group +The space reserved for all entries of a group is the product of the space reserved for each entry times the value of the associated NumInGroup counter. If the counter field is set to zero, then no entries are sent in the message, and no space is reserved for entries. The group dimensions including the zero-value counter is still transmitted, however. +Multiple repeating groups +A message may contain multiple repeating groups at the same level. +Example of encoding specification with multiple repeating groups +<message name="ExecutionReport" id="8"> + <group name="ContraGrp" id="2012"> + <!-- ContraGrp group fields --> + </group> + <group name="PreAllocGrp" id="2026"> + <!-- PreAllocGrp group fields --> + </group> +</message> +Nested repeating group specification +Repeating groups may be nested to an arbitrary depth. That is, a <group> in a message schema may contain one or more <group> child elements, each associated with their own counter fields. +The encoding specification of nested repeating groups is in the same format as groups at the root level of a message in a recursive procedure. +Example of nested repeating group specification +<group name="ListOrdGrp" id="2030"> + <field name="ClOrdID" id="11" type="string14" semanticType="String"/> + <field name="ListSeqNo" id="67" type="uint32" semanticType="int"/> + <field name="Symbol" id="55" type="string8" semanticType="String"/> + <field name="Side" id="54" type="char" semanticType="char"/> + <field name="OrderQty" id="38" type="intQty32" semanticType="Qty"/> + <group name="Parties" id="1012"> + <field name="PartyID" id="448" type="string14" semanticType="String"/> + <field name="PartyRole" id="452" type="int" semanticType="int"/> + </group> +</group> +Nested repeating group wire format +Nested repeating groups are encoded on the wire by a depth-first walk of the data hierarchy. For example, all inner entries under the first outer entry must be encoded before encoding outer entry 2. (This is the same element order as FIX tag=value encoding.) +On decoding, nested repeating groups do no support direct access to fields. It is necessary to walk all elements in sequence to discover the number of entries in each repeating group. +Empty group means nested group is empty +If a group contains nested repeating groups, then a NumInGroup counter of zero implies that both that group and its child groups are empty. In that case, no NumInGroup is encoded on the wire for the child groups. +Group dimension encoding +Every repeating group must be immediately preceded on the wire by its dimensions. The two dimensions are the count of entries in a repeating group and the space reserved for each entry of the group. +Range of group entry count +Implementations should support uint8 and uint16 types for repeating group entry counts. Optionally, implementations may support any other unsigned integer types. +By default, the minimum number of entries is zero, and the maximum number is the largest value of the primitiveType of the counter. + + + +Primitive type +Description +Length (octets) +Maximum number of entries + + + + +uint8 +8-bit unsigned integer +1 +255 + + +uint16 +16-bit unsigned integer +2 +65535 + + + +The number of entries may be restricted to a specific range; see section Restricting repeating group entries for details. +Encoding of repeating group dimensions +Conventionally in FIX, a NumInGroup field conveys the number of entries in a repeating group. In SBE, the encoding conveys two dimensions: the number of entries and the length of each entry in number octets. Therefore, the encoding is a composite of those two elements. Block length and entry count subfields must be encoded as unsigned integer types. +By default, the name of the group dimension encoding is groupSizeEncoding. This name may be overridden by setting the dimensionType attribute of a <group> element. +Recommended encoding of repeating group dimensions +<composite name="groupSizeEncoding"> + <type name="blockLength" primitiveType="uint16"/> + <type name="numInGroup" primitiveType="uint16" semanticType="NumInGroup"/> + <type name="numGroups" primitiveType="uint16" /> + <type name="numVarDataFields" primitiveType="uint16" /> +</composite> +Block length +The total space reserved for the fixed-length fields of this repeating group, not counting any repeating groups or variable-length fields. +Number of entries +The number of entries in this repeating group, called NumInGroup in FIX. +Number of repeating groups +A count nested repeating groups in this repeating group. +Number of variable-length fields +A count of the variable-length fields in this repeating group. +Wire format of NumInGroup with block length 55 octets by 3 entries, containing one nested group and two variable-length fields. +3700030001000200 +Restricting repeating group entries +The occurrences of a repeating group may be restricted to a specific range by modifying the numInGroup member of the group dimension encoding. The minValue attribute controls the minimum number of entries, overriding the default of zero, and the maxValue attribute restricts the maximum entry count to something less than the maximum corresponding to its primitiveType. Either or both attributes may be specified. +Example of a restricted group encoding +<type name="numInGroup" primitiveType="uint16" semanticType="NumInGroup" minValue="1" maxValue="10" /> +Sequence of message body elements +Root level elements +To maximize deterministic field positions, message schemas must be specified with this sequence of message body elements: + +Fixed-length fields that reside at the root level of the message (that is, not members of repeating groups), including any of the following, in the order specified by the message schema:: + +Fixed-length scalar fields, such as integers +Fixed-length character arrays +Fixed-length composite types, such as MonthYear + +Repeating groups, if any. +Data fields, including raw data and variable-length strings, if any. + +Repeating group elements +Repeating group entries are recursively organized in the same fashion as the root level: fixed-length fields, then nested repeating groups, and finally, variable-length data fields. +Message structure validation +Aside from message schema validations (see section Schema validation), these validations apply to message structure. +If a message structure violation is detected on a received message, the message should be rejected back to the counterparty in a way appropriate to the session protocol. + + + + + + + +Error condition +Error description + + + + +Wrong message size in header +A message size value smaller than the actual message may cause a message to be truncated. + + +Wrong or unknown template ID in header +A mismatch of message schema would likely render a message unintelligible or cause fields to be misinterpreted. + + +Fixed-length field after repeating group or variable-length field +All fixed-length fields in the root of a message or in a repeating group entry must be listed before any (nested) repeating group or variable-length field. + + +Repeating group after variable-length field +All repeating groups at the root level or in a nested repeating group must be listed before any variable length field at the same level. + + + +Message Schema +XML schema for SBE message schemas +See sbe.xsd for the normative XML Schema Definition (XSD) for SBE. +XML namespace +The Simple Binary Encoding XML schema is identified by this URL [tentative]: +xmlns:sbe=http://fixprotocol.io/2017/sbe +Conventionally, the URI of the XML schema is aliased by the prefix “sbe”. +Caution: Users should treat the SBE XML namespace as a URI (unique identifier), not as a URL (physical resource locator). Firms should not depend on access to the FIX Trading Community web site to validate XML schemas at run-time +Name convention +All symbolic names in a message schema are restricted to alphanumeric characters plus underscore without spaces. This is the same restriction applied to all names in FIX specifications. +Capitalization +The value of a field’s semanticType attribute is a FIX data type. In this document, FIX types are capitalized exactly as in the FIX repository, from which all official FIX documentation and references are derived. Since the capitalization is somewhat inconsistent, however, it is recommended that matching of type names should be case insensitive in schema parsers. +Root element +The root element of the XML document is <messageSchema>. +<messageSchema> attributes +The root element provides basic identification of a schema. +The byteOrder attribute controls the byte order of integer and float encodings within the schema. It is a global setting for all specified messages and their encodings. + + + + + + + + + + +Schema attribute +Description +XML type +Usage +Valid values + + + + +package +Name or category of a schema +string +optional +Should be unique between counterparties but no naming convention is imposed. + + +id +Unique identifier of a schema +unsignedInt + +Should be unique between counterparties + + +version +Version of this schema +nonnegativeInteger + +Initial version is zero and is incremented for each version + + +semanticVersion +Version of FIX semantics +string +optional +FIX versions, such as “FIX.5.0_SP2” + + +byteOrder +Byte order of encoding +token +default = littleEndian +littleEndian bigEndian + + +description +Documentation of the schema +string +optional + + + +headerType +Name of the encoding type of the message header, which is the same for all messages in a schema. +string +default= messageHeader +An encoding with this name must be contained by <types>. + + + +Schema versioning +Changes to a message schema may be tracked by its version attribute. A version of a schema is a snapshot in time. All elements in a given generation of the schema share the same version number. That is, elements are not versioned individually. By convention, the initial version of a schema is version zero, and subsequent changes increment the version number. +The package attribute should remain constant between versions, if it is supplied. +Data encodings +Encoding sets +The <types> element contains one or more sets of data encodings used for messages within the schema. +Within each set, an unbound number of encodings will be listed in any sequence: + +Element <type> defines a simple encoding +Element <composite> defines a composite encoding +Element <enum> defines an enumeration +Element <set> defines a multi-value choice bitset encoding + +Encoding name +The namespace for encoding names is global across all encodings included in a schema, including simple, composite and enumeration types. That is, the name must be unique among all encoding instances. +All symbolic names should be alphanumeric without spaces. +Importing encodings +A suggested usage is to import common encodings that are used across message schemas as one set while defining custom encodings that are particular to a schema in another set. +Example of XML include usage to import common encoding types +<!-- included XML contains a <types> element --> +<xi:include href="sbe-builtins.xml"/> +Simple encodings +A simple encoding is backed by either a scalar type or an array of scalars, such as a character array. One or more simple encodings may be defined, each specified by a <type> element. +<type> element content +If the element has a value, it is used to indicate a special value of the encoding. +Constant value +The element value represents a constant if attribute presence="constant". In this case, the value is conditionally required. +<type> attributes + + + + + + + + + + +<type> attribute +Description +XML type +Usage +Valid values + + + + +name +Name of encoding +symbolicName_t +required +Must be unique among all encoding types in a schema. + + +description +Documentation of the type +string +optional + + + +presence +Presence of any field encoded with this type +token + +required optional constant + + +nullValue +Override of special value used to indicate null for an optional field +string +Only valid if presence = optional +The XML string must be convertible to the scalar data type specified by primitiveType. + + +minValue +Lowest acceptable value +string + + + + +maxValue +Highest acceptable value +string + + + + +length +Number of elements of the primitive data type +nonnegativeInteger +default = 1 +Value “0” represents variable length. + + +offset +If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. +unsignedInt +optional +See section Element offset within a composite type + + +primitiveType +The primitive data type that backs the encoding +token +required +char int8 int16 int32 int64 uint8 uint16 uint32 uint64 float double + + +semanticType +Represents a FIX data type +token +optional +Same as field semanticType – see below. + + +sinceVersion +Documents the version of a schema in which a type was added +nonnegativeInteger +default = 0 +Must be less than or equal to the version of the message schema. + + +deprecated +Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + + +FIX data type specification +The attribute semanticType must be specified on either a field or on its corresponding type encoding. It need not be specified in both places, but if it is, the two values must match. +Simple type examples +<type name="FLOAT" primitiveType="double" + semanticType="float"/> +<type name="TIMESTAMP" primitiveType="uint64" + semanticType="UTCTimestamp"/> +<type name="GeneralIdentifier" primitiveType="char" + description="Identifies class or source + of the PartyID" presence="constant">C</type> +Composite encodings +Composite encoding types are composed of two or more simple types. +<composite> attributes + + + + + + + + + + +<composite> attribute +Description +XML type +Usage +Valid values + + + + +name +Name of encoding +symbolicName_t +required +Must be unique among all encoding types. + + +offset +The offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. +unsignedInt +optional + + + +description +Documentation of the type +string +optional + + + +semanticType +Represents a FIX data type +token +optional +Same as field semanticType – see below. + + +sinceVersion +Documents the version of a schema in which a type was added +nonnegativeInteger +default = 0 +Must be less than or equal to the version of the message schema. + + +deprecated +Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + + +Composite type elements +A <composite> composite encoding element may be composed of any combination of types, including <type> simple encoding, <enum> enumeration, <set> bitset, and nested composite type. The elements that compose a composite type carry the same XML attributes as stand-alone types. +Composite type example +In this example, a Price is encoded as 32-bit integer mantissa and a constant exponent, which is not sent on the wire. +<composite name="decimal32" semanticType="Price"> + <type name="mantissa" primitiveType="int32" /> + <type name="exponent" primitiveType="int8" + presence="constant">-4</type> +</composite> +Element offset within a composite type +If a message designer wishes to control byte boundary alignment or map to an existing data structure, element offset may optionally be specified on a simple type, enum or bitset within a composite type. Offset is the number of octets from the start of the composite; it is a zero-based index. +If specified, offset must be greater than or equal to the sum of the sizes of prior elements. In other words, an offset is invalid if it would cause elements to overlap. +Null value of a composite type +For a composite type, nullness is indicated by the value of its first element. For example, if a price field is optional, a null value in its mantissa element indicates that the price is null. +Reference to reusable types +A composite type often has its elements defined in-line within the <composite> XML element as shown in the example above. Alternatively, a common type may be defined once on its own, and then referred to by name with the composite type using a <ref> element. +<ref> attributes + + + + + + + + + + +<ref> attribute +Description +XML type +Usage +Valid values + + + + +name +Usage of the type in this composite +symbolicName_t +required + + + +type +Name of referenced encoding +symbolicName_t +required +Must match a defined type, enum or set or composite name attribute. + + +offset +The offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. +unsignedInt +optional + + + +sinceVersion +Documents the version of a schema in which a type was added +nonnegativeInteger +default = 0 +Must be less than or equal to the version of the message schema. + + +deprecated +Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + + +Type reference examples +Reference to an enum +In this example, a futuresPrice is encoded as 64-bit integer mantissa, 8-bit exponent, and a reused enum type. +<enum name="booleanEnum" encodingType="uint8" semanticType="Boolean"> + <validValue name="false">0</validValue> + <validValue name="true">1</validValue> +</enum> + +<composite name="futuresPrice"> + <type name="mantissa" primitiveType="int64" /> + <type name="exponent" primitiveType="int8" /> + <ref name="isSettlement" type="boolEnum" /> +</composite> +Reference to a composite type +In this example, a nested composite is formed by using a reference to another composite type. It supports the expresson of a monetary amount with its currency, such as USD150.45. Note that a reference may carry an offset within the composite encoding that contains it. +<composite name="price"> + <type name="mantissa" primitiveType="int64" /> + <type name="exponent" primitiveType="int8" /> +</composite> + +<composite name="money"> + <type name="currencyCode" primitiveType="char" length="3" semanticType="Currency" /> + <ref name="amount" type="price" semanticType="Price" offset="3" /> +</composite> +Enumeration encodings +An enumeration explicitly lists the valid values of a data domain. Any number of fields may share the same enumeration. +<enum> element +Each enumeration is represented by an <enum> element. It contains any number of <validValue> elements. +The encodingType attribute refers to a simple encoding of scalar type. The encoding of an enumeration may be char or any unsigned integer type. + + + + + + + + + + +<enum> attribute +Description +XML type +Usage +Valid values + + + + +name +Name of encoding +symbolicName_t +required +Must be unique among all encoding types. + + +description +Documentation of the type +string +optional + + + +encodingType +Name of a simple encoding type +symbolicName_t +required +Must match the name attribute of a scalar <type> element or a primitive type: char uint8 uint16 uint32 uint64 + + +sinceVersion +Documents the version of a schema in which a type was added +nonnegativeInteger +default = 0 +Must be less than or equal to the version of the message schema. + + +deprecated +Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + +offset +If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. +unsignedInt +optional + + + + +<validValue> element attributes +The name attribute of the <validValue> uniquely identifies it. + + + + + + + + + + +<validValue> attribute +Description +XML type +Usage +Valid values + + + + +name +Symbolic name of value +symbolicName_t +required +Must be unique among valid values in the enumeration. + + +description +Documentation of the value +string +optional + + + +sinceVersion +Documents the version of a schema in which a value was added +nonNegativeInteger +default = 0 + + + +deprecated +Documents the version of a schema in which a value was deprecated. It should no longer be used in new messages. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + + +<validValue> element content +The element is required to carry a value, which is the valid value as a string. The string value in XML must be convertible to the data type of the encoding, such as an integer. +<enum> and <validValue> elements +Enumeration example (not all valid values listed) +This enumeration is encoded as an 8-bit unsigned integer value. Others are encoded as char codes. +<type name="intEnum" primitiveType="uint8" /> + +<enum name="PartyRole" encodingType="intEnum"> + <validValue name="ExecutingFirm">1</validValue> + <validValue name="BrokerOfCredit">2</validValue> + <validValue name="ClientID">3</validValue> + <validValue name="ClearingFirm">4</validValue> +</enum> +Multi-value choice encodings (bitset) +An enumeration explicitly lists the valid values of a data domain. Any number of fields may share the same set of choices. +<set> element +Each multi-value choice is represented by a <set> element. It may contain a number of <choice> elements up to the number of bits in the primitive encoding type. The largest number possible is 64 choices in a uint64 encoding. +The encodingType attribute refers to a simple encoding of scalar type. The encoding of a bitset should be an unsigned integer type. + + + + + + + + + + +<set> attribute +Description +XML type +Usage +Valid values + + + + +name +Name of encoding +symbolicName_t +required +Must be unique among all encoding types. + + +description +Documentation of the type +string +optional + + + +encodingType +Name of a simple encoding type +string +required +Must match the name attribute of a scalar <type> element or a primitive type: uint8 uint16 uint32 uint64 + + +sinceVersion +Documents the version of a schema in which a type was added +nonnegativeInteger +default = 0 +Must be less than or equal to the version of the message schema. + + +deprecated +Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + +offset +If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. +unsignedInt +optional + + + + +<choice> element attributes +The name attribute of the <choice> uniquely identifies it. + + + + + + + + + + +<choice> attribute +Description +XML type +Usage +Valid values + + + + +name +Symbolic name of value +symbolicName_t +required +Must be unique among choices in the set. + + +description +Documentation of the value +string +optional + + + +sinceVersion +Documents the version of a schema in which a choice was added +nonNegativeInteger +default = 0 + + + +deprecated +Documents the version of a schema in which a choice was deprecated. It should no longer be used in new messages. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + + +<choice> element content +The element is required to carry a value, which is an unsigned integer representing a zero-based index to a bit within a bitset. Zero is the least significant bit. +<set> and <choice> XML elements +Multi-value choice example, the choice is encoded as a bitset. +<type name="bitset" primitiveType="uint8" /> + +<set name="Scope" encodingType="bitset" > + <choice name="LocalMarket">0</choice> + <choice name="National">1</choice> + <choice name="Global">2</choice> +</set> +Message template +To define a message type, add a <message> element to the root element of the XML document, <messageSchema>. +The name and id attributes are required. The first is a display name for a message, while the latter is a unique numeric identifier, commonly called template ID. +Reserved space +By default, message size is the sum of its field lengths. However, a larger size may be reserved by setting blockLength, either to allow for future growth or for desired byte alignment. If so, the extra reserved space should be filled with zeros by message encoders. +Message members +A <message> element contains its field definitions in three categories, which must appear in this sequence: + +Element <field> defines a fixed-length field +Element <group> defines a repeating group +Element <data> defines a variable-length field, such as raw data + +The number of members of each type is unbound. +Member order +The order that fields are listed in the message schema governs the order that they are encoded on the wire. +<message> element attributes + + + + + + + + + + +<message> attribute +Description +XML type +Usage +Valid values + + + + +name +Name of a message +symbolicName_t +required +Must be unique among all messages in a schema + + +id +Unique message template identifier +unsignedInt +required +Must be unique within a schema + + +description +Documentation +string +optional + + + +blockLength +Reserved size in number of octets for root level of message body +unsignedInt +optional +If specified, must be greater than or equal to the sum of field lengths. + + +semanticType +Documents value of FIX MsgType for a message +token +optional +Listed in FIX specifications + + +sinceVersion +Documents the version of a schema in which a message was added +nonNegativeInteger +default = 0 + + + +deprecated +Documents the version of a schema in which a message was deprecated. It should no longer be sent but is documented for back-compatibility. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + + +Note that there need not be a one-to-one relationship between message template (identified by id attribute) and semanticType attribute. You might design multiple templates for the same FIX MsgType to optimize different scenarios. +Example <message> element +<sbe:message name="NewOrderSingle" id="2" semanticType="D"> +Field attributes +Fields are added to a <message> element as child elements. See section Field Encoding for a listing of all field types. +These are the common attributes of all field types. + + + + + + + + + + +Schema attribute +Description +XML type +Usage +Valid values + + + + +name +Name of a field +symbolicName_t +required +Name and id must uniquely identify a field type within a message schema. + + +id +Unique field identifier (FIX tag) +unsignedShort +required + + + +description +Documentation +string +optional + + + +type +Encoding type name, one of simple type, composite type or enumeration. +string +required +Must match the name attribute of a simple <type>, <composite> encoding type, <enum> or <set>. + + +offset +Offset to the start of the field within a message or repeating group entry. By default, the offset is the sum of preceding field sizes, but it may be increased to effect byte alignment. +unsignedInt +optional +Must be greater than or equal to the sum of preceding field sizes. + + +presence +Field presence +enumeration +Default = required +required = field value is required; not tested for null. optional = field value may be null. constant = constant value not sent on wire. + + +valueRef +Constant value of a field as a valid value of an enumeration +qualifiedName_t +optional Valid only if presence= ”constant” +If provided, the qualified name must match the name attribute of a <validValue> within an <enum> + + +sinceVersion +The version of a message schema in which this field was added. +InonnegativeInteger +default=0 +Must not be greater than version attribute of <messageSchema> element. + + +deprecated +Documents the version of a schema in which a field was deprecated. It should no longer be used in new messages. +nonnegativeInteger +optional +Must be less than or equal to the version of the message schema. + + + +Example field schemas +Field that uses a composite encoding +<composite name="intQty32" semanticType="Qty"> + <type name="mantissa" primitiveType="int32" /> + <type name="exponent" primitiveType="int8" + presence="constant">0\</type> +</composite> + +<field type="intQty32" name="OrderQty" id="38" offset="16" + description="Shares: Total number of shares" /> +Repeating group schema +A <group> has the same attributes as a <message> element since they both inherit attributes from the blockType XML type. A group has the same child members as a message, and they must appear in the same order: + +Element <field> defines a fixed-length field +Element <group> defines a repeating group. Groups may be nested to any level. +Element <data> defines a variable-length field, such as raw data + +The number of members of each type is unbound. + + + + + + + + + + +<group> attribute +Description +XML type +Usage +Valid values + + + + +name +Name of a group +symbolicName_t +required +Name and id must uniquely identify a group type within a message schema. + + +id +Unique group identifier +unsignedShort +required + + + +description +Documentation +string +optional + + + +dimensionType +Dimensions of the repeating group +symbolicName_t +default = groupSizeEncoding +If specified, must be greater than or equal to the sum of field lengths. + + + +<group> element inherits attributes of blockType. See <message> element above. +Example group schema with default dimension encoding +<composite name="groupSizeEncoding"> + <type name="blockLength" primitiveType="uint16"/> + <type name="numInGroup" primitiveType="uint16" + semanticType="NumInGroup"/> +</composite> + +<group name="Parties" id="1012" > + <field type="string14" name="PartyID" id="448" /> + <field type="partyRoleEnum" name="PartyRole" id="452" /> +</group> +Schema validation +The first level of schema validation is enforced by XML schema validation tools to make sure that a schema is well-formed according to XSD schema rules. Well-formed XML is necessary but insufficient to prove that a schema is correct according to FIX Simple Binary Encoding rules. +Additional conditions that render a schema invalid include the following. + + + + + + + +Error condition +Error description + + + + +Missing field encoding +A field or <enum> references a type name that is undefined. + + +Missing message header encoding +Missing encoding type for headerType specified in <messageSchema>. Default name is “messageHeader”. + + +Duplicate encoding name +An encoding name is non-unique, rendering a reference ambiguous. + + +nullValue specified for non-null encoding +Attribute nullValue is inconsistent with presence=required or constant + + +Attributes nullValue, minValue or maxValue of wrong data range +The specified values must be convertible to a scalar value consistent with the encoding. For example, if the primitive type is uint8, then the value must be in the range 0 through 255. + + +semanticType mismatch +If the attribute is specified on both a field and the encoding that it references, the values must be identical. + + +presence mismatch +If the attribute is specified on both a field and the encoding that it references, the values must be identical. + + +Missing constant value +If presence=constant is specified for a field or encoding, the element value must contain the constant value. + + +Missing validValue content +A <validValue> element is required to carry its value. + + +Incompatible offset and blockLength +A field offset greater than message or group blockLength is invalid + + +Duplicate ID or name of field or group +Attributes id and name must uniquely identify a type within a message schema. This applies to fields and groups. To be clear, the same field or group ID may be used in multiple messages, but each instance must represent the same type. Each of those instances must match on both id and name attributes. + + + +Message with a repeating group +<message name="ListOrder" id="2" description="Simplified + NewOrderList. Demonstrates repeating group"> + <field name="ListID" id="66" type="string14" semanticType="String"/> + <field name="BidType" id="394" type="uint8" semanticType="int"/> + <group name="ListOrdGrp" id="2030" > + <field name="ClOrdID" id="11" type="string14" semanticType="String"/> + <field name="ListSeqNo" id="67" type="uint32" semanticType="int"/> + <field name="Symbol" id="55" type="string8" semanticType="String"/> + <field name="Side" id="54" type="char" semanticType="char"/> + <field name="OrderQty" id="38" type="intQty32" semanticType="Qty"/> + </group> +</message> +Message with raw data fields +<message name="UserRequest" id="4" description="Demonstrates raw data usage"> + <field name="UserRequestId" id="923" type="string14" semanticType="String"/> + <field name="UserRequestType" id="924" type="uint8" semanticType="int"/> + <field name="UserName" id="553" type="string14" semanticType="String"/> + <field name="Password" id="554" type="string14" semanticType="String"/> + <field name="NewPassword" id="925" type="string14" semanticType="String"/> + <field name="EncryptedPasswordMethod" id="1400" type="uint8" description="This should be an enum but values undefined." + semanticType="int"/> + <field name="EncryptedPasswordLen" id="1401" type="uint8" semanticType="Length"/> + <field name="EncryptedNewPasswordLen" id="1403" type="uint8" semanticType="Length"/> + <field name="RawDataLength" id="95" type="uint8" semanticType="Length"/> + <data name="EncryptedPassword" id="1402" type="rawData" semanticType="data"/> + <data name="EncryptedNewPassword" id="1404" type="rawData" semanticType="data"/> + <data name="RawData" id="96" type="rawData" semanticType="data"/> +</message> +Reserved element names +Composite types + + + +Encoding type name (default names) + + + + +messageHeader + + +groupSizeEncoding + + + +Composite type elements + + + +Type name +Composite type + + + + +blockLength +messageHeader and groupSize + + +day +MonthYear + + +exponent +decimal + + +mantissa +decimal + + +month +MonthYear + + +numInGroup +groupSize + + +templateId +messageHeader + + +time +timestamp, TZ time + + +timezoneHour +TZ time + + +timezoneMinute +TZ time + + +unit +timestamp, TZ time + + +version +messageHeader + + +week +MonthYear + + +year +MonthYear + + + +Schema Extension Mechanism +Objective +It is not always practical to update all message publishers and consumers simultaneously. Within certain constraints, message schemas and wire formats can be extended in a controlled way. Consumers using an older version of a schema should be compatible if interpretation of added fields or messages is not required for business processing. +This specification only details compatibility at the presentation layer. It does not relieve application developers of any responsibility for carefully planning a migration strategy and for handling exceptions at the application layer. +Constraints +Compatibility is only ensured under these conditions: + +Fields may be added to either the root of a message or to a repeating group, but in each case, they must be appended to end of a block. +Existing fields cannot change data type or move within a message. +A repeating group may be added after existing groups at the root level or nested within another repeating group. +A variable-length data field may be added after existing variable-length data at the root level or within a repeating group. +Message header encoding cannot change. +In general, metadata changes such as name or description corrections do not break compatibility so long as wire format does not change. + +Changes that break those constraints require consumers to update to the current schema used by publishers. An message template that has changed in an incompatible way must be assinged a new template “id” attribute. +Message schema features for extension +Schema version +The <messageSchema> root element contains a version number attribute. By default, version is zero, the initial version of a message schema. Each time a message schema is changed, the version number is incremented. +Version applies to the schema as a whole, not to individual elements. Version is sent in the message header so the consumer can determine which version of the message schema was used to encode the message. +See section Message schema attributes for the specification. +Since version +When a new field, enumeration value, group or message is added to a message schema, the extension may be documented by adding a sinceVersion attribute to the element. The sinceVersion attribute tells in which schema version the element was added. This attribute remains the same for that element for the lifetime of the schema. This attribute is for documentation purposes only, it is not sent on the wire. +Over time, multiple extensions may be added to a message schema. New fields must be appended following earlier extensions. By documenting when each element was added, it possible to verify that extensions were appended in proper order. +Block length +The length of the root level of the message may optionally be documented on a <message> element in the schema using the blockLength attribute. See section Message element attributes for details. If not set in the schema, block length of the message root is the sum of its field lengths. Whether it is set in the schema or not, the block length is sent on the wire to consumers. +Likewise, a repeating group has a blockLength attribute to tell how much space is reserved for group entries, and the value is sent on the wire. It is encoded in the schema as part of the NumInGroup field encoding. See section Encoding of repeating group dimensions for details. +Deprecated elements +A message schema may document obsolete elements, such as messages, fields, and valid values of enumerations with deprecated attribute. Updated applications should not publish deprecated messages or values, but declarations may remain in the message schema during a staged migration to replacement message layouts. +Wire format features for extension +Block size +The length of the root level of the message is sent on the wire in the SBE message header. See section Root block length for details. Therefore, if new fields were appended in a later version of the schema, the consumer would still know how many octets to consume to find the next message element, such as repeating group or variable-length Data field. Without the current schema version, the consumer cannot interpret the new fields, but it does not break parsing of earlier fields. +Likewise, block size of a repeating group is conveyed in the NumInGroup encoding. +Number of repeating groups and variable data +Message headers and repeating group dimensions carry a count of the number of repeating groups and a count of variable-length data fields on the wire. This supports a walk by a decoder of all the elements of a message, even when the decoder was built with an older version of a schema. As for added fixed-length fields, new repeating groups cannot be interpreted by the decoder, but it still can process the ones it knows, and it can correctly reach the end of a message. +Comaptibility strategy +This suggested strategy is non-normative. +A message decoder compares the schema version in a received message header to the version that the decoder was built with. +If the received version is equal to the decoder’s version, then all fields known to the decoder may be parsed, and no further analysis is required. +If the received version is greater than the decoder’s version (that is, the producer’s encoder is newer than the consumer’s decoder), then all fields known to the decoder may be parsed but it will be unable to parse added fields. +Also, an old decoder may encounter unexpected enumeration values. The application layer determines whether an unexpected value is a fatal error. Probably so for a required field since the business meaning is unknown, but it may choose to allow an unknown value of an optional field to pass through. For example, if OrdType(40)=J (Market If Touched (MIT)) is added to a schema, and the consumer does not recognize it, then the application returns an order rejection with reason “order type not supported”, even if it does not know what “J” represents. Note that this is not strictly a versioning problem, however. This exception handling is indistinguishable from the case where “J” was never added to the enum but was simply sent in error. +If the received version is less than the decoder’s version (that is, the producer’s encoder is older than the consumer’s decoder), then only the fields of the older version may be parsed. This information is available through metadata as “sinceVersion” attribute of a field. If sinceVersion is greater than received schema version, then the field is not available. How a decoder signals an application that a field is unavailable is an implementation detail. One strategy is for an application to provide a default value for unavailable fields. +Message schema extension example +Initial version of a message schema +<messageSchema package="FIXBinaryTest" byteOrder="littleEndian"> + <types> + <type name="int8" primitiveType="int8"/> + </types> + +<message name="FIX Binary Message1" id="1" blockLength="4"> + <field name="Field1" id="1" type="int8" semanticType="int"/> +</message> + +</messageSchema> +Second version - a new message is added +<messageSchema package="FIXBinaryTest" byteOrder="littleEndian" + version="1"> + +<types> + <type name="int8" primitiveType="int8"/> + <type name="int16" primitiveType="int16" + sinceVersion="1"/> +</types> + +<message name="FIX Binary Message1" id="1" blockLength="4"> + <field name="Field1" id="1" type="int8" semanticType="int"/> +</message> + +<!-- New message added in this version--> +<message name="FIX Binary Message2" id="2" blockLength="4" + sinceVersion="1"> + <field name="Field2" id="2" type="int16" semanticType="int"/> +</message> +</messageSchema> +Third version - a field is added +<messageSchema package="FIXBinaryTest" byteOrder="littleEndian" + version="2"> + +<types> + <type name="int8" primitiveType="int8"/> + <type name="int16" primitiveType="int16" + sinceVersion="1"/> + <type name="int32" primitiveType="int32" + sinceVersion="2"/> +</types> + +<message name="FIX Binary Message1" id="1" blockLength="8"> + <field name="Field1" id="1" type="int8" semanticType="int"/> + <field name="Field11" id="11" type="int32" semanticType="int" + sinceVersion="2"/> +</message> + +<message name="FIX Binary Message2" id="2" blockLength="4" + sinceVersion="1"> + <field name="Field2" id="2" type="int16" semanticType="int"/> +</message> +</messageSchema> +Usage Guidelines +Identifier encodings +FIX specifies request and entity identifiers as String type. Common practice is to specify an identifier field as fixed-length character of a certain size. +Optionally, a message schema may restrict such identifiers to numeric encodings. +Example of an identifier field with character encoding +<type name="idString" primitiveType="char" length="16" /> + +<field name="QuoteReqId" id="131" type="idString" + semanticType="String"/> +Example of an identifier field with numeric encoding +<type name="uint64" primitiveType="uint64" /> + +<field name="QuoteReqId" id="131" type="uint64" + semanticType="String"/> +Examples +The example messages are preceded by Simple Open Framing Header. Note that SOFH encoding is always big-endian, regardless of the byte order of the SBE message body. See that FIX standard for details. +Not all FIX enumeration values are listed in the samples. +Flat, fixed-length message +This is an example of a simple, flat order message without repeating groups or variable-length data. +Sample order message schema +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> + +<sbe:messageSchema + xmlns:sbe="http://fixprotocol.io/2016/sbe" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + package="Examples" id="100" + description="Test dictionary" + byteOrder="littleEndian" + xsi:schemaLocation="http://fixprotocol.io/2016/sbe sbe.xsd"> + +<types> + <type name="enumEncoding" primitiveType="char"/> + <type name="idString" length="8" primitiveType="char" semanticType="String"/> + <type name="timestampEncoding" primitiveType="uint64" semanticType="UTCTimestamp"/> + + <composite name="messageHeader"> + <type name="blockLength" primitiveType="uint16"/> + <type name="templateId" primitiveType="uint16"/> + <type name="schemaId" primitiveType="uint16"/> + <type name="version" primitiveType="uint16"/> + </composite> + + <composite name="optionalDecimalEncoding" + description="Optional decimal with constant exponent"> + <type name="mantissa" presence="optional" primitiveType="int64"/> + <type name="exponent" presence="constant" primitiveType="int8">-3</type> + </composite> + + <composite name="qtyEncoding" description="Decimal constrained to integers"> + <type name="mantissa" primitiveType="int32"/> + <type name="exponent" presence="constant" primitiveType="int8">0</type> + </composite> + + <enum name="ordTypeEnum" encodingType="enumEncoding"> + <validValue name="Market" description="Market">1</validValue> + <validValue name="Limit" description="Limit">2</validValue> + <validValue name="Stop" description="Stop Loss">3</validValue> + <validValue name="StopLimit" description="Stop Limit">4</validValue> + </enum> + + <enum name="sideEnum" encodingType="enumEncoding"> + <validValue name="Buy" description="Buy">1</validValue> + <validValue name="Sell" description="Sell">2</validValue> + </enum> + +</types> + +<sbe:message name="NewOrderSingle" id="99" blockLength="54" +semanticType="D"> + <field name="ClOrdID" id="11" type="idString" description="Customer Order ID" + offset="0" semanticType="String"/> + <field name="Account" id="1" type="idString" description="Account mnemonic" + offset="8" semanticType="String"/> + <field name="Symbol" id="55" type="idString" description="Security ID" + offset="16" semanticType="String"/> + <field name="Side" id="54" type="sideEnum" description="Side" offset="24" + semanticType="char"/> + <field name="TransactTime" id="60" type="timestampEncoding" + description="Order entry time" offset="25" semanticType="UTCTimestamp"/> + <field name="OrderQty" id="38" type="qtyEncoding" description="Order quantity" + offset="33" semanticType="Qty"/> + <field name="OrdType" id="40" type="ordTypeEnum" description="Order type" + offset="37" semanticType="char"/> + <field name="Price" id="44" type="optionalDecimalEncoding" + description="Limit price" offset="38" semanticType="Price"/> + <field name="StopPx" id="99" type="optionalDecimalEncoding" + description="Stop price" offset="46" semanticType="Price"/> +</sbe:message> + +</sbe:messageSchema> +Notes on the message schema +In this case, there is a lot of verbiage for one message, but in practice, a schema would define a set of messages. The same encodings within the <types> element would be used for a whole collection of messages. For example, a price encoding need only be defined once but can be used in any number of messages in a schema. Many of the attributes, such as description, offset, and semanticType, are optional but are shown here for a full illustration. +All character fields in the message are fixed-length. Values may be shorter than the specified field length, but not longer. Since all fields are fixed-length, they are always in a fixed position, supporting direct access to data. +An enumeration gives the valid values of a field. Both enumerations in the example use character encoding, but note that some enumerations in FIX are of integer type. +There are two decimal encodings. The one used for quantity sets the exponent to constant zero. In effect there is no fractional part and only the mantissa is sent on the wire, acting as an integer. However, FIX defines Qty as a float type since certain asset classes may use fractional shares. +The other decimal encoding is used for prices. The exponent is constant -3. In essence, each price is transmitted as an integer on the wire with assumed three decimal places. Each of the prices in the message is conditionally required. If OrdType(40)=2 (Limit), then the field Price(44) is required. If OrdType(40)=3 (Stop/Stop Loss) then StopPx(99) is required. Otherwise, if OrdType(40)=1 (Market), then neither price is required. Therefore, the price fields take an optional encoding. To indicate that it is null, a special value is sent on the wire. See the table in section Range attributes for integer fields for the null value of the int64 mantissa. +In this example, all fields are packed without special byte alignment. Performance testing may prove better results with a different arrangement of the fields or adjustments to field offsets. However, those sorts of optimizations are platform dependent. +Wire format of an order message +Hexadecimal and ASCII representations (little-endian byte order): +00 00 00 44 eb 50 36 00 63 00 5b 00 00 00 4f 52 : D P6 c [ OR +44 30 30 30 30 31 41 43 43 54 30 31 00 00 47 45 :D00001ACCT01 GE +4d 34 00 00 00 00 31 80 16 b3 3b 13 65 29 15 07 :M4 1 ; e) +00 00 00 32 1a 85 01 00 00 00 00 00 00 00 00 00 : 2 +00 00 00 80 +Interpretation + + + +Wire format +Field ID +Name +Offset +Length +Interpreted value + + + + +00000044 + +SOFH message length +0 +4 +68 + + +eb50 + +SOFH encoding +4 +2 +SBE little-endian + + +3600 + +SBE block length +0 +2 +54 + + +6300 + +SBE template ID +2 +2 +99 + + +5b00 + +SBE schema ID +4 +2 +91 + + +0000 + +SBE schema version +6 +2 +0 + + +4f52443030303031 +11 +ClOrdID +0 +8 +ORD00001 + + +4143435430310000 +1 +Account +8 +8 +ACCT01 + + +47454d3400000000 +55 +Symbol +16 +8 +GEM4 + + +31 +54 +Side +24 +1 +Buy + + +00b863e7343d2a15 +60 +TransactTime +25 +8 +2018-04-30T14:32:01.248Z + + +07000000 +38 +OrderQty +33 +4 +7 + + +32 +40 +OrdType +37 +1 +Limit + + +1a85010000000000 +44 +Price +38 +8 +99.610 + + +0000000000000080 +99 +StopPx +46 +8 +null + + + +Message with a repeating group +This is an example of a message with a repeating group. +Sample execution report message schema +Add this encoding types element to those in the previous example. +<types> + <type name="date" primitiveType="uint16" semanticType="LocalMktDate"/> + <composite name="MONTH_YEAR" semanticType="MonthYear"> + <type name="year" primitiveType="uint16"/> + <type name="month" primitiveType="uint8"/> + <type name="day" primitiveType="uint8"/> + <type name="week" primitiveType="uint8"/> + </composite> + + <composite name="groupSizeEncoding" description="Repeating group dimensions"> + <type name="blockLength" primitiveType="uint16" + semanticType="Length"/> + <type name="numInGroup" primitiveType="uint16" + semanticType="NumInGroup"/> + </composite> + + <enum name="execTypeEnum" encodingType="enumEncoding"> + <validValue name="New" description="New">0</validValue> + <validValue name="DoneForDay" description="Done for day">3</validValue> + <validValue name="Canceled" description="Canceled">4</validValue> + <validValue name="Replaced" description="Replaced">5</validValue> + <validValue name="PendingCancel">6</validValue> + <validValue name="Rejected" description="Rejected">8</validValue> + <validValue name="PendingNew" description="Pending New">A</validValue> + <validValue name="Trade" description="partial fill or fill">F</validValue> + </enum> + + <enum name="ordStatusEnum" encodingType="enumEncoding"> + <validValue name="New" description="New">0</validValue> + <validValue name="PartialFilled">1</validValue> + <validValue name="Filled" description="Filled">2</validValue> + <validValue name="DoneForDay" description="Done for day">3</validValue> + <validValue name="Canceled" description="Canceled">4</validValue> + <validValue name="PendingCancel">6</validValue> + <validValue name="Rejected" description="Rejected">8</validValue> + <validValue name="PendingNew" description="Pending New">A</validValue> + <validValue name="PendingReplace" >E</validValue> + </enum> + +</types> + +<sbe:message name="ExecutionReport" id="98" blockLength="42" +semanticType="8"> + <field name="OrderID" id="37" type="idString" description="Order ID" + offset="0" semanticType="String"/> + <field name="ExecID" id="17" type="idString" description="Execution ID" + offset="8" semanticType="String"/> + <field name="ExecType" id="150" type="execTypeEnum" + description="Execution type" offset="16" semanticType="char"/> + <field name="OrdStatus" id="39" type="ordStatusEnum" + description="Order status" offset="17" semanticType="char"/> + <field name="Symbol" id="55" type="idString" description="Security ID" + offset="18" semanticType="String"/> + <field name="MaturityMonthYear" id="200" type="MONTH_YEAR" + description="Expiration" offset="26" semanticType="MonthYear"/> + <field name="Side" id="54" type="sideEnum" description="Side" offset="31" + semanticType="char"/> + <field name="LeavesQty" id="151" type="qtyEncoding" + description="Quantity open" offset="32" semanticType="Qty"/> + <field name="CumQty" id="14" type="qtyEncoding" + description="Executed quantity" offset="36" semanticType="Qty"/> + <field name="TradeDate" id="75" type="date" + description="Trade date" offset="40" semanticType="LocalMktDate"/> + <group name="FillsGrp" id="2112" description="Partial fills" + blockLength="12" dimensionType="groupSizeEncoding"> + <field name="FillPx" id="1364" type="optionalDecimalEncoding" + description="Price of partial fill" offset="0" semanticType="Price"/> + <field name="FillQty" id="1365" type="qtyEncoding" + description="Executed quantity" offset="8" semanticType="Qty"/> + </group> +</sbe:message> +Notes on the message schema +The message contains a MonthYear field. It is encoded as a composite type with year, month, day and week subfields. +This message layout contains a repeating group containing a collection of partial fills for an execution report. The <group> XML tag enclosed the fields within a group entry. The dimensions of the repeating group are encoding as a composite type called groupSizeEncoding. +Wire format of an execution message +Hexadecimal and ASCII representations (little-endian byte order): +00 00 00 54 eb 50 2a 00 62 00 5b 00 00 00 4f 30 : T P* b [ O0 +30 30 30 30 30 31 45 58 45 43 30 30 30 30 46 31 :000001EXEC0000F1 +47 45 4d 34 00 00 00 00 de 07 06 ff ff 31 01 00 :GEM4 1 +00 00 06 00 00 00 75 3e 0c 00 02 00 1a 85 01 00 : u> +00 00 00 00 02 00 00 00 24 85 01 00 00 00 00 00 : $ +04 00 00 00 : +Interpretation +Offset is from beginning of block. + + + +Wire format +Field ID +Name +Offset +Length +Interpreted value + + + + +00000054 + +SOFH message length +0 +4 +84 + + +eb50 + +SOFH encoding +4 +2 +SBE little-endian + + +2a00 + +SBE block length +0 +2 +42 + + +6200 + +SBE template ID +2 +2 +98 + + +5b00 + +SBE schema ID +4 +2 +91 + + +0000 + +SBE schema version +6 +2 +0 + + +4558454330303030 +37 +OrderID +8 +8 +O0000001 + + +4558454330303030 +17 +ExecID +8 +8 +EXEC0000 + + +30 +39 +OrdStatus +1 +1 +PartiallyFilled + + +47454d3400000000 +55 +Symbol +18 +8 +GEM4 + + +de0706ffff +200 +MaturityMonthYear +26 +5 +year=2014 month=6 + + +30 +54 +Side +1 +1 +Buy + + +01000000 +151 +LeavesQty +32 +4 +1 + + +06000000 +14 +CumQty +36 +4 +6 + + +753e +75 +TradeDate +40 +2 +2013-10-11 + + +0c000200 + +FillsGrp +0 +4 +Block length=12 count=2 + + +1a85010000000000 +1364 +FillPx +0 +8 +99.610 + + +02000000 +1365 +FillQty +8 +4 +2 + + +2485010000000000 +1364 +FillPx +0 +8 +99.620 + + +04000000 +1365 +FillQty +8 +4 +4 + + + +Message with a variable-length field +Sample business reject message schema +Add this encoding types element to those in the previous example. + +<types> + <type name="intEnumEncoding" primitiveType="uint8"/> + + <composite name="DATA" description="Variable-length data"> + <type name="length" primitiveType="uint16" /> + <type name="varData" length="0" primitiveType="uint8"> + </composite> + + <enum name="businessRejectReasonEnum" encodingType="intEnumEncoding">> + <validValue name="Other">0</validValue> + <validValue name="UnknownID">1</validValue> + <validValue name="UnknownSecurity">2</validValue> + <validValue name="ApplicationNotAvailable">4</validValue> + <validValue name="NotAuthorized">6</validValue> + </enum> + +</types> + + <sbe:message name="BusinessMessageReject" id="97" + blockLength="9" semanticType="j"> + <field name="BusinessRejectRefID" id="379" type="idString" + offset="0" semanticType="String" /> + <field name="BusinessRejectReason" id="380" type="businessRejectReasonEnum" + offset="8" semanticType="int" /> + <data name="Text" id="58" type="DATA" semanticType="String" /> + </sbe:message> +Wire format of a business reject message +Hexadecimal and ASCII representations (little-endian byte order): +00 00 00 40 eb 50 09 00 61 00 5b 00 00 00 4f 52 : @ P a [ OR +44 30 30 30 30 31 06 27 00 4e 6f 74 20 61 75 74 :D00001 ' Not aut +68 6f 72 69 7a 65 64 20 74 6f 20 74 72 61 64 65 :horized to trade +20 74 68 61 74 20 69 6e 73 74 72 75 6d 65 6e 74 : that instrument +Interpretation + + + +Wire format +Field ID +Name +Offset +Length +Interpreted value + + + + +00000040 + +SOFH message length +0 +4 +64 + + +eb50 + +SOFH encoding +4 +2 +SBE little-endian + + +0900 + +SBE block length +0 +2 +9 + + +6100 + +SBE template ID +2 +2 +97 + + +5b00 + +SBE schema ID +4 +2 +91 + + +0000 + +SBE schema version +6 +2 +0 + + +4f52443030303031 +379 +BusinessRejectRefID +0 +8 +ORD00001 + + +06 +380 +BusinessRejectReason +8 +1 +NotAuthorized + + +4e6f74206175... +58 +Text +0 +39 +Not authorized to trade that instrument + + + + + diff --git a/v1-0-STANDARD/doc/publication/Simple Binary Encoding - Technical Specification version1-0.docx b/v1-0-STANDARD/doc/publication/Simple Binary Encoding - Technical Specification version1-0.docx new file mode 100644 index 0000000..235f826 Binary files /dev/null and b/v1-0-STANDARD/doc/publication/Simple Binary Encoding - Technical Specification version1-0.docx differ diff --git a/v1-0-STANDARD/doc/publication/Simple Binary Encoding - Technical Specification version1-0.pdf b/v1-0-STANDARD/doc/publication/Simple Binary Encoding - Technical Specification version1-0.pdf new file mode 100755 index 0000000..3b4aa8d Binary files /dev/null and b/v1-0-STANDARD/doc/publication/Simple Binary Encoding - Technical Specification version1-0.pdf differ diff --git a/v1-0-STANDARD/doc/publication/Simple Binary Encoding Technical Proposal V1.0 with Errata Nov 2020.docx b/v1-0-STANDARD/doc/publication/Simple Binary Encoding Technical Proposal V1.0 with Errata Nov 2020.docx new file mode 100644 index 0000000..3da7363 Binary files /dev/null and b/v1-0-STANDARD/doc/publication/Simple Binary Encoding Technical Proposal V1.0 with Errata Nov 2020.docx differ diff --git a/v1-0-STANDARD/doc/publication/Simple-Binary-Encoding-Draft-Standard-v1.0.pdf b/v1-0-STANDARD/doc/publication/Simple-Binary-Encoding-Draft-Standard-v1.0.pdf new file mode 100644 index 0000000..b299ae4 Binary files /dev/null and b/v1-0-STANDARD/doc/publication/Simple-Binary-Encoding-Draft-Standard-v1.0.pdf differ diff --git a/v1-0-STANDARD/doc/publication/Simple-Binary-Encoding-Technical-Specification-version1-0-with-20180727-errata.docx b/v1-0-STANDARD/doc/publication/Simple-Binary-Encoding-Technical-Specification-version1-0-with-20180727-errata.docx new file mode 100644 index 0000000..c947e0e Binary files /dev/null and b/v1-0-STANDARD/doc/publication/Simple-Binary-Encoding-Technical-Specification-version1-0-with-20180727-errata.docx differ diff --git a/v1-0-STANDARD/doc/publication/Simple-Binary-Encoding-Technical-Specification-version1-0-with-20180727-errata.pdf b/v1-0-STANDARD/doc/publication/Simple-Binary-Encoding-Technical-Specification-version1-0-with-20180727-errata.pdf new file mode 100644 index 0000000..c5140d2 Binary files /dev/null and b/v1-0-STANDARD/doc/publication/Simple-Binary-Encoding-Technical-Specification-version1-0-with-20180727-errata.pdf differ diff --git a/v1-0-STANDARD/doc/publication/Simple_Binary_Encoding_V1.0_with_Errata_November_2020.docx b/v1-0-STANDARD/doc/publication/Simple_Binary_Encoding_V1.0_with_Errata_November_2020.docx new file mode 100644 index 0000000..5e47f77 Binary files /dev/null and b/v1-0-STANDARD/doc/publication/Simple_Binary_Encoding_V1.0_with_Errata_November_2020.docx differ diff --git a/v1-0-STANDARD/doc/publication/Simple_Binary_Encoding_V1.0_with_Errata_November_2020.pdf b/v1-0-STANDARD/doc/publication/Simple_Binary_Encoding_V1.0_with_Errata_November_2020.pdf new file mode 100644 index 0000000..75c695a Binary files /dev/null and b/v1-0-STANDARD/doc/publication/Simple_Binary_Encoding_V1.0_with_Errata_November_2020.pdf differ diff --git a/v1-0-STANDARD/doc/publication/Simple_Binary_Encoding_V1.0_with_Errata_November_2020_changetracked.docx b/v1-0-STANDARD/doc/publication/Simple_Binary_Encoding_V1.0_with_Errata_November_2020_changetracked.docx new file mode 100644 index 0000000..8c38066 Binary files /dev/null and b/v1-0-STANDARD/doc/publication/Simple_Binary_Encoding_V1.0_with_Errata_November_2020_changetracked.docx differ diff --git a/v1-0-STANDARD/doc/publication/Simple_Binary_Encoding_V1.0_with_Errata_November_2020_changetracked.pdf b/v1-0-STANDARD/doc/publication/Simple_Binary_Encoding_V1.0_with_Errata_November_2020_changetracked.pdf new file mode 100644 index 0000000..382fb31 Binary files /dev/null and b/v1-0-STANDARD/doc/publication/Simple_Binary_Encoding_V1.0_with_Errata_November_2020_changetracked.pdf differ diff --git a/v2-0-RC1/doc/publication/Simple-Binary-Encoding-Technical-Specification-v2-RC1.pdf b/v2-0-RC1/doc/publication/Simple-Binary-Encoding-Technical-Specification-v2-RC1.pdf new file mode 100644 index 0000000..e9722de Binary files /dev/null and b/v2-0-RC1/doc/publication/Simple-Binary-Encoding-Technical-Specification-v2-RC1.pdf differ diff --git a/v2-0-RC2/doc/02FieldEncoding.md b/v2-0-RC2/doc/02FieldEncoding.md index e88e4e0..3c2b8c4 100644 --- a/v2-0-RC2/doc/02FieldEncoding.md +++ b/v2-0-RC2/doc/02FieldEncoding.md @@ -11,16 +11,13 @@ and message schema but are introduced here as an overview. ### Semantic data type -The FIX semantic data type of a field tells a data domain interpreted at the application layer, for example, whether it is numeric or character data, or whether it represents a time or price. Simple Binary Encoding represents most of -the semantic data types that FIX protocol has defined across all -encodings. In field specifications, FIX data type is declared with -attribute `semanticType`. +The FIX semantic data type of a field tells a data domain interpreted at the application layer, for example, whether it is numeric or character data, or whether it represents a time or price. Simple Binary Encoding represents most of the semantic data types that FIX protocol has defined across all encodings. In field specifications, FIX data type is declared with attribute `semanticType`. See the "Data type summary" below for a listing of FIX types with the usual mapping to SBE encodings. Implementations should not restrict a semantic type to a specific encoding. Message designers may wish to imply a conversion or specialized interpretation at the application layer. ### Encoding -Encoding tells how a data element is encoded on the wire. Encoding belongs strictly to the presentation layer. It is context-free and carries no business semantics. +Encoding tells how a data element is encoded on the wire. Encoding belongs strictly to the presentation layer. It is context-free and carries no business semantics. An encoding maps a FIX data type to either a simple, primitive data type, such as a 32 bit signed integer, or to a composite type. A @@ -187,11 +184,11 @@ overridden by a message schema. Required and optional fields of the same primitive type have the same data range. The null value must not be set for a required field. - Schema attribute | int8 | uint8 | int16 | uint16 | int32 | uint32 | int64 | uint64 | -|------------------|-----:|------:|-------:|-------:|--------------------:|-------------------:|--------------------:|-------------------:| -| minValue | –127 | 0 | –32767 | 0 | –231 + 1 | 0 | –263 + 1 | 0 | -| maxValue | 127 | 254 | 32767 | 65534 | 231 – 1 | 232 – 2 | 263 – 1 | 264 – 2 | -| nullValue | –128 | 255 | –32768 | 65535 | –231 | 232 – 1 | –263 | 264 – 1 | +|Schema attribute | int8 | uint8 | int16 | uint16 | int32 | uint32 | int64 | uint64 | +|------------------|-----:|------:|-------:|-------:|-----------:|----------:|-----------:|----------:| +| minValue | –127 | 0 | –32767 | 0 | –2^31^ + 1 | 0 | –2^63^ + 1 | 0 | +| maxValue | 127 | 254 | 32767 | 65534 | 2^31^ – 1 | 2^32^ – 2 | 2^63^ – 1 | 2^64^ – 2 | +| nullValue | –128 | 255 | –32768 | 65535 | –2^31^ | 2^32^ – 1 | –2^63^ | 2^64^ – 1 | ### Byte order @@ -266,7 +263,7 @@ Wire format of uint16 value decimal 10000, hexadecimal 2710. `1027` -Wire format of uint32 null value 232 - 1 +Wire format of uint32 null value 2^32^ - 1 `ffffffff` @@ -323,18 +320,18 @@ The default data ranges and null indicator are listed below for each decimal encoding. A message schema may optionally specify a more restricted range of valid -values for a field. +values for a field. For all optional decimal fields, a special mantissa value is used to indicate that a field value is null. For floating-point decimals, the exponent should also be set to its null indicator. -| Schema attribute | decimal | decimal64 | decimal32 | -|------------------|------------------------------------------:|------------------------------------------:|------------------------------------------:| -| exponent range | –128 to 127 | –128 to 127 | –128 to 127 | -| mantissa range | –263 + 1 to 263 – 1 | –263 + 1 to 263 – 1 | –231 + 1 to 231 – 1 | -| minValue | (–263 + 1) \* 10127 | (–263 + 1) \* 10127 | (–231 + 1) \* 10127 | -| maxValue | (263 – 1) \* 10127 | (–263 – 1) \* 10127 | (231 – 1) \* 10127 | -| nullValue | mantissa=–263, exponent=–128 | mantissa =–263 | mantissa =–231 | +| Schema attribute | decimal | decimal64 | decimal32 | +|------------------|-------------------------------:|------------------------:|------------------------:| +| exponent range | –128 to 127 | –128 to 127 | –128 to 127 | +| mantissa range | –2^63^ + 1 to 2^63^ – 1 | –2^63^ + 1 to 2^63^ – 1 | –2^31^ + 1 to 2^31^ – 1 | +| minValue | (–2^63^ + 1) \* 10^127^ | (–2^63^ + 1) \* 10^127^ | (–2^31^ + 1) \* 10^127^ | +| maxValue | (2^63^ – 1) \* 10^127^ | (–2^63^ – 1) \* 10^127^ | (2^31^ – 1) \* 10^127^ | +| nullValue | mantissa=–2^63^, exponent=–128 | mantissa =–2^63^ | mantissa =–2^31^ | ### Encoding specifications for decimal types @@ -501,7 +498,7 @@ discussion of enum fields. #### Range attributes for char fields -Character fields are constrained to single-byte characters sets. The recommended encoding is ISO/IEC 8859-1:1998 Latin alphabet No. 1. +Character fields are constrained to single-byte characters sets. The recommended encoding is ISO/IEC 8859-1:1998 Latin alphabet No. 1. However, other 8-bit encodings may be specified in a message schema. The value of characterEncoding attribute should be a preferred character set name registered with Internet Assigned Numbers Authority (IANA). @@ -561,7 +558,7 @@ primitiveType="char" and a length attribute is required. Range attributes minValue and maxValue do not apply to fixed-length character arrays. -Character arrays are constrained to single-byte characters sets with the same character ranges as a single-character field. The recommended encoding is ISO/IEC 8859-1:1998 Latin alphabet No. 1. +Character arrays are constrained to single-byte characters sets with the same character ranges as a single-character field. The recommended encoding is ISO/IEC 8859-1:1998 Latin alphabet No. 1. Other 8-bit encodings may be specified in a message schema with the characterEncoding attribute. The value of characterEncoding should be a preferred character set name registered with IANA. @@ -598,7 +595,7 @@ A character array constant specification. As for a non-constant value, if the co ### Variable-length string encoding -Variable-length string encoding is used for variable length +Variable-length string encoding is used for variable length strings or character data with a multi-byte character set (like FIX EncodedText field). A length member conveys the size of the string that follows in octets, which may be different than the number of characters. @@ -622,7 +619,7 @@ for length. | Schema attribute | length uint8 | length uint16 | |------------------|----------------:|----------------:| -| minValue | 0 | 0 | +| minValue | 0 | 0 | | maxValue | 254 | 65534 | If the Length element has minValue and maxValue attributes, it specifies diff --git a/v2-0-RC2/doc/04MessageSchema.md b/v2-0-RC2/doc/04MessageSchema.md index 5717f1f..cabea31 100644 --- a/v2-0-RC2/doc/04MessageSchema.md +++ b/v2-0-RC2/doc/04MessageSchema.md @@ -367,7 +367,7 @@ The `name` attribute of the `` uniquely identifies it. | sinceVersion | Documents the version of a schema in which a choice was added | nonNegativeInteger | default = 0 | | | deprecated | Documents the version of a schema in which a choice was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | -#### `< choice >` element content +#### `` element content The element is required to carry a value, which is an unsigned integer representing a zero-based index to a bit within a bitset. Zero is the diff --git a/v2-0-RC2/doc/FIXDisclaimerTechStd.md b/v2-0-RC2/doc/FIXDisclaimerTechStd.md new file mode 100644 index 0000000..8bdbfdd --- /dev/null +++ b/v2-0-RC2/doc/FIXDisclaimerTechStd.md @@ -0,0 +1,27 @@ +::: {custom-style=Disclaimer} +DISCLAIMER +::: + +THE INFORMATION CONTAINED HEREIN AND THE FINANCIAL INFORMATION EXCHANGE PROTOCOL (COLLECTIVELY, THE "FIX PROTOCOL") ARE PROVIDED "AS IS" AND NO PERSON OR ENTITY ASSOCIATED WITH THE FIX PROTOCOL MAKES ANY REPRESENTATION OR WARRANTY, EXPRESS OR IMPLIED, AS TO THE FIX PROTOCOL (OR THE RESULTS TO BE OBTAINED BY THE USE THEREOF) OR ANY OTHER MATTER AND EACH SUCH PERSON AND ENTITY SPECIFICALLY DISCLAIMS ANY WARRANTY OF ORIGINALITY, ACCURACY, COMPLETENESS, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SUCH PERSONS AND ENTITIES DO NOT WARRANT THAT THE FIX PROTOCOL WILL CONFORM TO ANY DESCRIPTION THEREOF OR BE FREE OF ERRORS. THE ENTIRE RISK OF ANY USE OF THE FIX PROTOCOL IS ASSUMED BY THE USER. + +NO PERSON OR ENTITY ASSOCIATED WITH THE FIX PROTOCOL SHALL HAVE ANY LIABILITY FOR DAMAGES OF ANY KIND ARISING IN ANY MANNER OUT OF OR IN CONNECTION WITH ANY USER'S USE OF (OR ANY INABILITY TO USE) THE FIX PROTOCOL, WHETHER DIRECT, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL (INCLUDING, WITHOUT LIMITATION, LOSS OF DATA, LOSS OF USE, CLAIMS OF THIRD PARTIES OR LOST PROFITS OR REVENUES OR OTHER ECONOMIC LOSS), WHETHER IN TORT (INCLUDING NEGLIGENCE AND STRICT LIABILITY), CONTRACT OR OTHERWISE, WHETHER OR NOT ANY SUCH PERSON OR ENTITY HAS BEEN ADVISED OF, OR OTHERWISE MIGHT HAVE ANTICIPATED THE POSSIBILITY OF, SUCH DAMAGES. + +**DRAFT OR NOT RATIFIED PROPOSALS** (REFER TO PROPOSAL STATUS AND/OR SUBMISSION STATUS ON COVER PAGE) ARE PROVIDED "AS IS" TO INTERESTED +PARTIES FOR DISCUSSION ONLY. PARTIES THAT CHOOSE TO IMPLEMENT THIS DRAFT PROPOSAL DO SO AT THEIR OWN RISK. IT IS A DRAFT DOCUMENT AND MAY BE +UPDATED, REPLACED, OR MADE OBSOLETE BY OTHER DOCUMENTS AT ANY TIME. THE FIX GLOBAL TECHNICAL COMMITTEE WILL NOT ALLOW EARLY IMPLEMENTATION TO +CONSTRAIN ITS ABILITY TO MAKE CHANGES TO THIS SPECIFICATION PRIOR TO FINAL RELEASE. IT IS INAPPROPRIATE TO USE FIX WORKING DRAFTS AS +REFERENCE MATERIAL OR TO CITE THEM AS OTHER THAN “WORKS IN PROGRESS”. THE FIX GLOBAL TECHNICAL COMMITTEE WILL ISSUE, UPON COMPLETION OF REVIEW +AND RATIFICATION, AN OFFICIAL STATUS ("APPROVED") OF/FOR THE PROPOSAL AND A RELEASE NUMBER. + +No proprietary or ownership interest of any kind is granted with respect to the FIX Protocol (or any rights therein), except as expressly set out in FIX Protocol Limited's Copyright and Acceptable Use Policy. + +© Copyright 2015-2019 FIX Protocol Limited, all rights reserved + +\ + + + +FIX Technical Standard Specifications by [FIX Protocol Ltd.](https://www.fixtradingcommunity.org/) are licensed under a [Creative Commons Attribution-NoDerivatives 4.0 International License](http://creativecommons.org/licenses/by-nd/4.0/). Based on a work at [https://github.com/FIXTradingCommunity/](https://github.com/FIXTradingCommunity/). + + +1. diff --git a/v2-0-RC2/doc/FIX_TechStd_Style_MASTER.docx b/v2-0-RC2/doc/FIX_TechStd_Style_MASTER.docx new file mode 100644 index 0000000..48a429c Binary files /dev/null and b/v2-0-RC2/doc/FIX_TechStd_Style_MASTER.docx differ diff --git a/v2-0-RC2/doc/SBE.sh b/v2-0-RC2/doc/SBE.sh new file mode 100755 index 0000000..27073c3 --- /dev/null +++ b/v2-0-RC2/doc/SBE.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +echo Compilation started... +# Script is expected to start running in the folder where it is located (together with the source files) +SOURCE="$PWD" +# There is only one disclaimer and style docx file for all FIX Technical Standards and it is stored with the FIX Session Layer +# Repository has local copies with the specific names and dates of the standard +DISCLAIMER="FIXDisclaimerTechStd.md" +STYLE="FIX_TechStd_Style_MASTER.docx" +TARGET="$SOURCE/target" +YAML="$SOURCE/SBE.yaml" +FILES="01Introduction.md 02FieldEncoding.md 03MessageStructure.md 04MessageSchema.md 05SchemaExtensionMechanism.md 06UsageGuidelines.md 07Examples.md" +WPFOLDER="/wp-content/uploads/2020/03/" + +# Create document version with disclaimer +pandoc "$DISCLAIMER" $FILES -o "$TARGET/docx/Simple-Binary-Encoding-v2-RC2.docx" --reference-doc="$STYLE" --metadata-file="$YAML" --toc --toc-depth=4 +echo SBE document version created + +# Create base online version without disclaimer +pandoc $FILES -o "$TARGET/debug/SBEONLINE.html" -s --metadata-file="$YAML" --toc --toc-depth=2 + +# Create separate online versions for production and test website by including appropriate link prefixes +sed 's,img src="media/,img src="https://www.fixtrading.org'$WPFOLDER',g' "$TARGET/debug/SBEONLINE.html" > "$TARGET/html/SBEONLINE_PROD.html" +sed s/www.fixtrading.org/www.technical-fixprotocol.org/ "$TARGET/html/SBEONLINE_PROD.html" > "$TARGET/html/SBEONLINE_TEST.html" +echo SBE ONLINE version created for PROD and TEST + +echo Compilation ended! diff --git a/v2-0-RC2/doc/SBE.yaml b/v2-0-RC2/doc/SBE.yaml new file mode 100644 index 0000000..6ae2af5 --- /dev/null +++ b/v2-0-RC2/doc/SBE.yaml @@ -0,0 +1,15 @@ +--- +title: Simple Binary Encoding (SBE) +subtitle: Technical Specification +author: +- "Version 2.0 -- Release Candidate 2 -- August 13, 2019" +- "\x0D" +- "THIS DOCUMENT IS A RELEASE CANDIDATE FOR A PROPOSED FIX TECHNICAL STANDARD. A RELEASE" +- "CANDIDATE HAS BEEN APPROVED BY THE GLOBAL TECHNICAL COMMITTEE AS AN INITIAL STEP IN" +- "CREATING A NEW FIX TECHNICAL STANDARD. POTENTIAL ADOPTERS ARE STRONGLY ENCOURAGED TO" +- "BEGIN WORKING WITH THE RELEASE CANDIDATE AND TO PROVIDE FEEDBACK TO THE GLOBAL" +- "TECHNICAL COMMITTEE AND THE WORKING GROUP THAT SUBMITTED THE PROPOSAL. THE" +- "FEEDBACK TO THE RELEASE CANDIDATE WILL DETERMINE IF ANOTHER REVISION AND RELEASE" +- "CANDIDATE IS NECESSARY OR IF THE RELEASE CANDIDATE CAN BE PROMOTED TO BECOME A FIX" +- "TECHNICAL STANDARD DRAFT." +--- diff --git a/v2-0-RC2/doc/publication/Simple-Binary-Encoding-v2-RC2.pdf b/v2-0-RC2/doc/publication/Simple-Binary-Encoding-v2-RC2.pdf new file mode 100644 index 0000000..79023cc Binary files /dev/null and b/v2-0-RC2/doc/publication/Simple-Binary-Encoding-v2-RC2.pdf differ diff --git a/v1-0-STANDARD/doc/00Contents.md b/v2-0-RC3/doc/00Contents.md similarity index 100% rename from v1-0-STANDARD/doc/00Contents.md rename to v2-0-RC3/doc/00Contents.md diff --git a/v2-0-RC3/doc/00Title.md b/v2-0-RC3/doc/00Title.md new file mode 100644 index 0000000..a2bb07d --- /dev/null +++ b/v2-0-RC3/doc/00Title.md @@ -0,0 +1,20 @@ + + +FIX Simple Binary Encoding +========================== + +## Technical Specification + +Version 2.0 Release Candidate 3 + +**THIS DOCUMENT IS A RELEASE CANDIDATE FOR A PROPOSED FIX TECHNICAL +STANDARD. A RELEASE CANDIDATE HAS BEEN APPROVED BY THE GLOBAL TECHNICAL +COMMITTEE AS AN INITIAL STEP IN CREATING A NEW FIX TECHNICAL STANDARD. +POTENTIAL ADOPTERS ARE STRONGLY ENCOURAGED TO BEGIN WORKING WITH THE +RELEASE CANDIDATE AND TO PROVIDE FEEDBACK TO THE GLOBAL TECHNICAL +COMMITTEE AND THE WORKING GROUP THAT SUBMITTED THE PROPOSAL. THE +FEEDBACK TO THE RELEASE CANDIDATE WILL DETERMINE IF ANOTHER REVISION AND +RELEASE CANDIDATE IS NECESSARY OR IF THE RELEASE CANDIDATE CAN BE +PROMOTED TO BECOME A FIX TECHNICAL STANDARD DRAFT.** + +**© Copyright 2015-2019 FIX Protocol Limited** diff --git a/v2-0-RC3/doc/01Introduction.md b/v2-0-RC3/doc/01Introduction.md new file mode 100644 index 0000000..40f28d5 --- /dev/null +++ b/v2-0-RC3/doc/01Introduction.md @@ -0,0 +1,189 @@ +# Introduction + +FIX Simple Binary Encoding (SBE) targets high performance trading +systems. It is optimized for low latency of encoding and decoding while +keeping bandwidth utilization reasonably small. For compatibility, it is +intended to represent all FIX semantics. + +This encoding specification describes the wire protocol for messages. +Thus, it provides a standard for interoperability between communicating +parties. Users are free to implement the standard in a way that best +suits their needs. Implementers may use the most appropriate techniques and idioms of programming languages to access data off the wire and manipulate it in applications. + +The encoding standard is complimentary to other FIX standards for +session protocol and application level behavior. + +## Binary type system + +In order to support traditional FIX semantics, all the documented field +types are supported. However, instead of printable character +representations of tag-value encoding, the type system binds to native +binary data types, and defines derived types as needed. + +The binary type system has been enhanced in these ways: + +- Provides a means to specify precision of decimal numbers and + timestamps, as well as valid ranges of numbers. + +- Differentiates fixed-length character arrays from variable-length + strings. Allows a way to specify the minimum and maximum length of + strings that an application can accept. + +- Provides a consistent system of enumerations, Boolean switches and + multiple-choice fields. + +## Design principles + +The message design strives for direct data access without complex +transformations or conditional logic. This is achieved by: + +- Usage of native binary data types and simple types derived from + native binaries, such as prices and timestamps. + +- Preference for fixed positions and fixed length fields, supporting + direct access to data and avoiding the need for management of heaps + of variable-length elements which must be sequentially processed. + +## Message schema + +This standard describes how fields are encoded and the general structure +of messages. The content of a message type is specified by a message +schema. A message schema tells which fields belong to a message and +their location within a message. Additionally, the metadata describes +valid value ranges and information that need not be sent on the wire, +such as constant values. + +Message schemas may be based on standard FIX message specifications or +may be customized as needed by agreement between counterparties. + +## Glossary + +**Character set** - A mapping between a sequence of octets and a sequence of characters. + +**Data type** - A field type with its associated encoding attributes, +including backing primitive types and valid values or range. Some types +have additional attributes, e.g. epoch of a date. + +**Encoding** - a message format for interchange. The term is commonly used +to mean the conversion of one data format to another, such as text to +binary. However, Simple Binary Encoding strives to use native binary +data types in order to make conversion unnecessary, or at least trivial. +Encoding also refers to the act of formatting a message, as opposed to +decoding. + +**Message schema** - metadata that specifies messages and their data +types and identifiers. Message schemas may be disseminated out of band. +For Simple Binary Encoding, message schemas are expressed as an XML +document that conforms to an XML schema that is published as part of +this standard. + +**Message template** - metadata that specifies the fields that belong to +one particular message type. A message template is contained by a +message schema. + +**Session protocol** - a protocol concerned with the reliable delivery of +messages over a transport. FIX protocol makes a distinction between +session protocol and the encoding of a message payload, as described by +this document. See the [specifications section](https://www.fixtrading.org/standards/) of the FIX protocol web site +for supported protocols. The original FIX session protocol is known as +FIXT. + +**XML schema** - defines the elements and attributes that may appear in an +XML document. The SBE message schema is defined in W3C (XSD) schema +language since it is the most widely adopted format for XML schemas. + +## Documentation + +This document explains: + +- The binary type system for field encoding + +- Message structure, including field arrangement, repeating groups, + and relationship to a message header that may be provided by a + session protocol. + +- The Simple Binary Encoding message schema. + +### Specification terms + +These key words in this document are to be interpreted as described in +[Internet Engineering Task Force RFC2119](http://www.apps.ietf.org/rfc/rfc2119.html). These terms indicate +an absolute requirement for implementations of the standard: "**must**", +or "**required**". + +This term indicates an absolute prohibition: "**must not**". + +These terms indicate that a feature is allowed by the standard but not +required: "**may**", "**optional**". An implementation that does not +provide an optional feature must be prepared to interoperate with one +that does. + +These terms give guidance, recommendation or best practices: +"**should**" or "**recommended**". A recommended choice among +alternatives is described as "**preferred**". + +These terms give guidance that a practice is not recommended: "**should not**" +or "**not recommended**". + +### Document format + +In this document, these formats are used for technical specifications +and data examples. + +This is a sample encoding specification + +```xml + +``` + +This is sample data as it would be transmitted on the wire + +`10270000` + +## References + +### Related FIX Standards + +[Simple Open Framing Header](https://www.fixtrading.org/standards/fix-sofh/) +FIX Protocol, Limited. Version 1.0 Draft Standard + +[FIX Latest](https://www.fixtrading.org/online-specification/) +Normative specification of the application layer of the FIX Protocol. + +### Dependencies on other standards + +SBE is dependent on several industry standards. Implementations must +conform to these standards to interoperate. Therefore, they are +normative for SBE. + +[IEEE 754-2008](http://ieeexplore.ieee.org/servlet/opac?punumber=4610933) A +Standard for Binary Floating-Point Arithmetic + +[IETF RFC 2978](https://tools.ietf.org/html/rfc2978) +IANA Charset Registration Procedures. See [Character Sets](https://www.iana.org/assignments/character-sets/character-sets.xml) + +[ISO 639-1:2002](http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=22109) +Codes for the representation of names of languages - Part 1: Alpha-2 +code + +[ISO 3166-1:2013](http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=63545) +Codes for the representation of names of countries and their +subdivisions - Part 1: Country codes + +[ISO 4217:2015](https://www.iso.org/standard/64758.html) +Codes for the representation of currencies and funds + +[ISO 8601:2004](http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=40874) +Data elements and interchange formats - Information interchange - +Representation of dates and times + +[ISO/IEC 8859-1:1998](https://www.iso.org/standard/28245.html) +8-bit single-byte coded graphic character sets -- Part 1: Latin alphabet No. 1 + +[ISO 10383:2012](http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=61067) +Securities and related financial instruments - Codes for exchanges and +market identification (MIC) + +*W3C XML Schema version 1.0* [Part 1](https://www.w3.org/TR/xmlschema-1/) [Part 2](https://www.w3.org/TR/xmlschema-2/) + +[W3C XML Inclusions (XInclude) Version 1.0](https://www.w3.org/TR/xinclude/) diff --git a/v2-0-RC3/doc/02FieldEncoding.md b/v2-0-RC3/doc/02FieldEncoding.md new file mode 100644 index 0000000..ddcebd1 --- /dev/null +++ b/v2-0-RC3/doc/02FieldEncoding.md @@ -0,0 +1,1317 @@ +# Field Encoding + +## Field aspects + +A field is a unit of data contained by a FIX message. Every field has +the following aspects: semantic data type, encoding, and metadata. They +will be specified in more detail in the sections on data type encoding +and message schema but are introduced here as an overview. + +### Semantic data type + +The FIX semantic data type of a field tells a data domain interpreted at the application layer, for example, whether it is numeric or character data, or whether it represents a time or price. Simple Binary Encoding represents most of +the semantic data types that FIX protocol has defined across all +encodings. In field specifications, FIX data type is declared with +attribute `semanticType`. + +See the section [*Data type summary*](#data-type-summary) below for a listing of FIX types with the usual mapping to SBE encodings. Implementations should not restrict a semantic type to a specific encoding. Message designers may wish to imply a conversion or specialized interpretation at the application layer. + +### Encoding + +Encoding tells how a data element is encoded on the wire. Encoding belongs strictly to the presentation layer. It is context-free and carries no business semantics. + +An encoding maps a FIX data type to either a simple, primitive +data type, such as a 32 bit signed integer, or to a composite type. A +composite type is composed of two or more simple primitive types. For +example, the FIX data type Price is encoded as a decimal, a composite +type containing a mantissa and an exponent. Note that many fields may +share a data type and an encoding. The sections that follow explain the +valid encodings for each data type. + +### Metadata + +Field metadata, part of a message schema, describes a field to +application developers. Elements of field metadata are: + +- Field ID, also known as FIX tag, is a unique identifier of a field + for semantic purposes. For example, tag 55 identifies the Symbol + field of an instrument. + +- Field name, as it is known in FIX specifications + +- The FIX semantic data type and encoding type that it maps to + +- Valid values or data range accepted + +- Documentation + +Metadata is normally *not* sent on the wire with Simple Binary Encoding +messages. It is necessary to possess the message schema that was used to +encode a message in order to decode it. In other words, Simple Binary +Encoding messages are not self-describing. Rather, message schemas are +typically exchanged out-of-band between counterparties. + +See section [*Message Schema*](#message-schema-1) below for a detailed message schema specification. + +### Field presence + +By default, fields are assumed to be required in a message. However, +fields may be specified as optional. To indicate that a value is not +set, a special null indicator value is sent on the wire. The null value +varies according to data type and encoding. Global defaults for null +value may be overridden in a message schema by explicitly specifying the +value that indicates nullness. + +Alternatively, fields may be specified as constant. In which case, the +data is not sent on the wire, but may be treated as constants by +applications. + +### Default value + +Default value handling is not specified by the encoding layer. A null +value of an optional field does not necessarily imply that a default +value should be applied. Rather, default handling is left to application +layer specifications. + +## Data type summary + +FIX semantic types are typically mapped to binary field encodings as follows. See +sections below for more detail about each type. + +Schema attributes may restrict the range of valid values for a field. +See section [*Common field schema attributes*](#common-field-schema-attributes) below. + +| FIX semantic type | Binary type | Section | Description | +|----------------------------------|-------------------------------------------------------------------------------------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| int | Integer encoding | [Integer encoding](#integer-encoding) | An integer number | +| Length | Integer encoding | [Integer encoding](#integer-encoding) | Field length in octets. Value must be non-negative. | +| TagNum | Integer encoding | [Integer encoding](#integer-encoding) | A field's tag number. Value must be positive. | +| SeqNum | Integer encoding | [Integer encoding](#integer-encoding) | A field representing a message sequence number. Value must be positive | +| NumInGroup | Group dimension encoding | [Group dimension encoding](../03MessageStructure.md#group-dimension-encoding) | A counter representing the number of entries in a repeating group. Value must be positive. | +| DayOfMonth | Integer encoding | [Integer encoding](#integer-encoding) | A field representing a day during a particular month (values 1 to 31). | +| Qty | Decimal encoding | [Decimal encoding](#decimal-encoding) | A number representing quantity of a security, such as shares. The encoding may constrain values to integers, if desired. | +| float | Float or Decimal | [Float encoding](#float-encoding) [Decimal encoding](#decimal-encoding) | A real number with binary representation of specified precision. Alternatively, Decimal encoding is preferred for exact decimal numbers. | +| Price | Decimal encoding | [Decimal encoding](#decimal-encoding) | A decimal number representing a price | +| PriceOffset | Decimal encoding | [Decimal encoding](#decimal-encoding) | A decimal number representing a price offset, which can be mathematically added to a Price. | +| Amt | Decimal encoding | [Decimal encoding](#decimal-encoding) | A field typically representing a Price times a Qty. | +| Percentage | Decimal encoding | [Decimal encoding](#decimal-encoding) | A field representing a percentage (e.g. 0.05 represents 5% and 0.9525 represents 95.25%). | +| char | Character | [Character encoding](#character) | Single-byte character value. Can include any alphanumeric character or punctuation. All char fields are case sensitive (i.e. m != M). | +| String | Fixed-length character array | [Fixed-length character](#fixed-length-character-array) | A fixed-length character array of single-byte encoding | +| String | Variable-length data encoding | [Variable-length string](#variable-length-string-encoding) | Alpha-numeric free format strings can include any character or punctuation. All String fields are case sensitive (i.e. morstatt != Morstatt). | +| String—EncodedText | String encoding | [Variable-length string](#variable-length-string-encoding) | A string. The character encoding may be specified by a schema attribute. | +| XMLData | String encoding | [Variable-length string](#variable-length-string-encoding) | Variable-length XML. Must be paired with a Length field. | +| data | Fixed-length data | [Fixed-length data](#fixed-length-data) | Fixed-length non-character data | +| data | Variable-length data encoding | [Variable-length data](#variable-length-data-encoding) | Variable-length data. Must be paired with a Length field. | +| Country | Fixed-length character array; size = 2 or a subset of values may use Enumeration encoding | [Fixed-length character](#fixed-length-character-array) | ISO 3166-1:2013 Country code | +| Currency | Fixed-length character array; size = 3 or a subset of values may use Enumeration encoding | [Fixed-length character](#fixed-length-character-array) | ISO 4217:2015 Currency code (3 character) | +| Exchange | Fixed-length character array; size = 4 or a subset of values may use Enumeration encoding | [Fixed-length character](#fixed-length-character-array) | ISO 10383:2012 Market Identifier Code (MIC) | +| Language | Fixed-length character array; size = 2 or a subset of values may use Enumeration encoding | [Fixed-length character](#fixed-length-character-array) | National language - uses ISO 639-1:2002 standard | +| Implicit enumeration—char or int | Enumeration encoding | [Enumeration encoding](#enumeration-encoding) | A single choice of alternative values | +| Boolean | Boolean encoding | [Boolean encoding](#boolean-encoding) | Values true or false | +| MultipleCharValue | Multi-value choice encoding | [Multi-value choice encoding](#multi-value-choice-encoding) | Multiple choice of a set of values | +| MultipleStringValue | Multi-value choice encoding. String choices must be mapped to int values. | [Multi-value choice encoding](#multi-value-choice-encoding) | Multiple choice of a set of values | +| MonthYear | MonthYear encoding | [MonthYear encoding](#monthyear-encoding) | A flexible date format that must include month and year at least, but may also include day or week. | +| UTCTimestamp | Date and time encoding | [Date and time encoding](#date-and-time-encoding) | Time/date combination represented in UTC (Universal Time Coordinated, also known as "GMT") | +| UTCTimeOnly | Date and time encoding | [Date and time encoding](#date-and-time-encoding) | Time-only represented in UTC (Universal Time Coordinated, also known as "GMT") | +| UTCDateOnly | Date and time encoding | [Date and time encoding](#date-and-time-encoding) | Date represented in UTC (Universal Time Coordinated, also known as "GMT") | +| LocalMktDate | Local date encoding | [Date and time encoding](#date-and-time-encoding) | Local date (as oppose to UTC) | +| TZTimeOnly | TZTimeOnly | [TZTimeOnly encoding](#tztimeonly-encoding) | Time of day | +| TZTimestamp | TZTimestamp | [TZTimestamp encoding](#tztimestamp-encoding) | Time/date combination representing local time with an offset to UTC to allow identification of local time and timezone offset of that time. The representation is based on ISO 8601:2004 | + +The FIX semantic types listed above are spelled and capitalized exactly as +they are in the FIX repository from which official FIX documents and +references are derived. + +## Common field schema attributes + +Schema attributes alter the range of valid values for a field. +Attributes are optional unless specified otherwise. + + +| Schema attribute | Description | +|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| presence=required | The field must always be set. This is the default presence. Mutually exclusive with nullValue. | +| presence=constant | The field has a constant value that need not be transmitted on the wire. Mutually exclusive with nullValue, minValue, and maxValue attributes. | +| presence=optional | The field need not be populated. A special null value indicates that a field is not set. The presence attribute may be specified on either on a field or its encoding. | +| nullValue | A special value that indicates that an optional value is not set. See encodings below for default nullValue for each type. Mutually exclusive with presence=required and constant. | +| minValue | The lowest valid value of a range. Applies to scalar data types, but not to String or data types. | +| maxValue | The highest valid value of a range (inclusive unless specified otherwise). Applies to scalar data types, but not to String or data types. | +| semanticType | Tells the semantic interpretation of a field in the FIX data type taxonomy. | + +### Non-FIX types + +Encodings may be added to SBE messages that do not correspond to listed +FIX data types. In that case, the fields that use the encoding will not have a `semanticType` attribute. + +## Integer encoding + +Integer encodings should be used for cardinal or ordinal number fields. +Signed integers are encoded in a two's complement binary format. + +### Primitive type encodings + +Numeric data types may be specified by range and signed or unsigned +attribute. Integer types are intended to convey common platform +primitive data types as they reside in memory. An integer type should be +selected to hold the maximum range of values that a field is expected to +hold. + +| Primitive type | Description | Length (octets) | +|----------------|---------------------------------------|----------------:| +| int8 | Signed byte | 1 | +| uint8 | Unsigned byte / single-byte character | 1 | +| int16 | 16-bit signed integer | 2 | +| uint16 | 16-bit unsigned integer | 2 | +| int32 | 32-bit signed integer | 4 | +| uint32 | 32-bit unsigned integer | 4 | +| int64 | 64-bit signed integer | 8 | +| uint64 | 64-bit unsigned integer | 8 | + +### Range attributes for integer fields + +The default data ranges and null indicator are listed below for each +integer encoding. + +A message schema may optionally specify a more restricted range of valid +values for a field. + +For optional fields, a special null value is used to indicate that a +field value is not set. The default null indicator may also be +overridden by a message schema. + +Required and optional fields of the same primitive type have the same +data range. The null value must not be set for a required field. + +|Schema attribute | int8 | uint8 | int16 | uint16 | int32 | uint32 | int64 | uint64 | +|------------------|-----:|------:|-------:|-------:|-----------:|----------:|-----------:|----------:| +| minValue | –127 | 0 | –32767 | 0 | –2^31^ + 1 | 0 | –2^63^ + 1 | 0 | +| maxValue | 127 | 254 | 32767 | 65534 | 2^31^ – 1 | 2^32^ – 2 | 2^63^ – 1 | 2^64^ – 2 | +| nullValue | –128 | 255 | –32768 | 65535 | –2^31^ | 2^32^ – 1 | –2^63^ | 2^64^ – 1 | + +### Byte order + +The byte order of integer fields, and for derived types that use integer +components, is specified globally in a message schema. Little-Endian +order is the default encoding, meaning that the least significant byte +is serialized first on the wire. + +See section [*Message Schema*](#message-schema-1) for specification of message schema attributes, +including byteOrder. Message schema designers should specify the byte +order most appropriate to their system architecture and that of their +counterparties. + +### Integer encoding specifications + +By nature, integers map to simple encodings. These are valid encoding +specifications for each of the integer primitive types. + +```xml + + + + + + + + +``` + +### Examples of integer fields + +Examples show example schemas and encoded bytes on the wire as +hexadecimal digits in Little-Endian byte order. + +Example integer field specification + +```xml + +``` + +Value on the wire - uint32 value decimal 10,000, hexadecimal 2710. + +`10270000` + +Optional field with a valid range 0-6 + +```xml + + +``` + +Wire format of uint8 value decimal 3. + +`03` + +Sequence number field with integer encoding + +```xml + +``` + +Wire format of uint64 value decimal 100,000,000,000, hexadecimal +174876E800. + +`00e8764817000000` + +Wire format of uint16 value decimal 10000, hexadecimal 2710. + +`1027` + +Wire format of uint32 null value 2^32^ - 1 + +`ffffffff` + +## Decimal encoding + +Decimal encodings should be used for prices and related monetary data +types like PriceOffset and Amt. + +FIX specifies Qty as a float type to support fractional quantities. +However, decimal encoding may be constrained to integer values if that +is appropriate to the application or market. + +### Composite encodings + +Prices are encoded as a scaled decimal, consisting of a signed integer +mantissa and signed exponent. For example, a mantissa of 123456 and +exponent of -4 represents the decimal number 12.3456. + +#### Mantissa + +Mantissa represents the significant digits of a decimal number. Mantissa +is a commonly used term in computing, but it is properly known in +mathematics as significand or coefficient. + +#### Exponent + +Exponent represents scale of a decimal number as a power of 10. + +#### Floating point and fixed point encodings + +A floating-point decimal transmits the exponent on the wire while a +fixed-point decimal specifies a fixed exponent in a message schema. A +constant negative exponent specifies a number of assumed decimal places +to the right of the decimal point. + +Implementations should support both 32 bit and 64 bit mantissa. The +usage depends on the data range that must be represented for a +particular application. It is expected that an 8 bit exponent should be +sufficient for all FIX uses. + +| Encoding type | Description | Backing primitives | Length (octets) | +|---------------|------------------------|--------------------|----------------:| +| decimal | Floating-point decimal | Composite: int64 mantissa, int8 exponent | 9 | +| decimal64 | Fixed-point decimal | int64 mantissa, constant exponent | 8 | +| decimal32 | Fixed-point decimal | int32 mantissa, constant exponent | 4 | + +Optionally, implementations may support any other signed integer types +for mantissa and exponent. + +### Range attributes for decimal fields + +The default data ranges and null indicator are listed below for each +decimal encoding. + +A message schema may optionally specify a more restricted range of valid +values for a field. + +For all optional decimal fields, a special mantissa value is +used to indicate that a field value is null. For floating-point decimals, the exponent should also be set to its null indicator. + +| Schema attribute | decimal | decimal64 | decimal32 | +|------------------|-------------------------------:|------------------------:|------------------------:| +| exponent range | –128 to 127 | –128 to 127 | –128 to 127 | +| mantissa range | –2^63^ + 1 to 2^63^ – 1 | –2^63^ + 1 to 2^63^ – 1 | –2^31^ + 1 to 2^31^ – 1 | +| minValue | (–2^63^ + 1) \* 10^127^ | (–2^63^ + 1) \* 10^127^ | (–2^31^ + 1) \* 10^127^ | +| maxValue | (2^63^ – 1) \* 10^127^ | (2^63^ – 1) \* 10^127^ | (2^31^ – 1) \* 10^127^ | +| nullValue | mantissa=–2^63^, exponent=–128 | mantissa =–2^63^ | mantissa =–2^31^ | + + +### Encoding specifications for decimal types + +Decimal encodings are composite types, consisting of two members, named +mantissa and exponent. They must be listed in that order in the composite type. The exponent may either be serialized on the wire +or may be set to constant. A constant exponent is a way to specify an +assumed number of decimal places. + +Decimal encoding specifications that an implementation must support + +```xml + + + + + + + + -2 + + + + + -2 + +``` + +### Composite encoding padding + +When both mantissa and exponent are sent on the wire for a decimal, the +elements are packed by default. However, byte alignment may be +controlled by specifying offset of the exponent within the composite +encoding. See section [*Message Schema*](#message-schema-1) below. + +### Examples of decimal fields + +Examples show encoded bytes on the wire as hexadecimal digits, +little-endian. + +FIX Qty data type is a float type, but a decimal may be constrained to +integer values by setting exponent to zero. + +```xml + + + 0 + +``` + +A field uses the encoding and adds semanticType. + +```xml + +``` + +Wire format of decimal 123.45 with 2 significant decimal places. + +`3930000000000000fe` + +Wire format of null floating-point decimal. + +`ffffffffffffffffff` + +Wire format of decimal64 123.45 with 2 significant decimal places. +Schema attribute exponent = -2 + +`3930000000000000` + +Wire format of decimal32 123.45 with 2 significant decimal places. +Schema attribute exponent = -2 + +`39300000` + +## Float encoding + +Binary floating point encodings are compatible with IEEE Standard for +Floating-Point Arithmetic (IEEE 754-2008). They should be used for +floating point numeric fields that do not represent prices or monetary +amounts. Examples include interest rates, volatility and dimensionless +quantities such as ratios. On the other hand, decimal prices should be +encoded as decimals; see section [*Decimal encoding*](#decimal-encoding) above. + +### Primitive types + +Both single and double precision encodings are supported as primitive +data types. See the IEEE 754-2008 standard for ranges and details of the +encodings. + +| Primitive type | Description | IEEE 754-2008 format | Length (octets) | +|----------------|---------------------------------|----------------------|----------------:| +| float | Single precision floating point | binary32 | 4 | +| double | Double precision floating point | binary64 | 8 | + +### Null values + +For both float and double precision encodings, null value of an optional +field is represented by the Not-a-Number format (NaN) of the standard +encoding. Technically, it indicated by the so-called quiet NaN. + +### Byte order + +Like integer encodings, floating point encodings follow the byte order +specified by message schema. See section [*Message Schema*](#message-schema-1) for specification of +message schema attributes, including byteOrder. + +### Float encoding specifications + +These are valid encoding specifications for each of the floating point +primitive types. + +```xml + + +``` + +Designers should determine whether a field of FIX data type float should be represented by a binary floating point number or an exact decimal number. If it is the latter, then see "Decimal encoding" above. + +### Examples of floating point fields + +Examples show encoded bytes on the wire as hexadecimal digits, +little-endian. + +A single precision ratio + +```xml + + + +``` + +Wire format of float 255.678 + +`91ad7f43` + +Wire format of double 255.678 + +`04560e2db2f56f40` + +## String encodings + +Character data may either be of fixed size or variable size. In Simple +Binary Encoding, fixed-length fields are recommended in order to support +direct access to data. Variable-length encoding should be reserved for +character strings that cannot be constrained to a specific size. It may +also be used for multi-byte encodings. + +### Character + +Character fields hold a single character of a single-byte character set. They are most commonly used +for fields with character code enumerations. See section [*Enumeration encoding*](#enumeration-encoding) below for +discussion of enum fields. + +| FIX data type | Description | Backing primitive | Length (octet) | +|---------------|--------------------|-------------------|---------------:| +| char | A single character | char | 1 | + +#### Range attributes for char fields + +Character fields are constrained to single-byte characters sets. The recommended encoding is ISO/IEC 8859-1:1998 Latin alphabet No. 1. +However, other 8-bit encodings may be specified in a message schema. The value of characterEncoding attribute should be a preferred +character set name registered with Internet Assigned Numbers Authority (IANA). + +Latin alphabet No. 1 reserves two ranges for control codes defined by ISO/IEC 6429:1992 control character sets C0 and C1. + +The implicit nullValue is the NUL control character (code 0). + +| Schema attribute | char | +|------------------|--------| +| minValue | hex 20 | +| maxValue | hex ff | +| nullValue | 0 | + +The range hexidecimal 7f-9f is a reserved for control character set C1. + +#### Encoding of char type + +This is the standard encoding for char type. Note that the length attribute defaults to 1, producing a single character rather than a character array. + +```xml + +``` + +A character may be specified with a different 8-bit encoding. + +```xml + +``` + +A field may be specified with a constant character value. +```xml +P +``` + +Wire format of char encoding of "A" (value 65, hexadecimal 41) + +`41` + +### Fixed-length character array + +Character arrays are allocated a fixed space in a message, supporting +direct access to fields. A fixed size character array is distinguished +from a variable length string by the presence of a length schema +attribute or a constant attribute. + +| FIX data type | Description | Backing primitives | Length (octets) | Required schema attribute | +|---------------|-----------------|-----------------------------------------------------------------------------------------------------------------------------|-------------------------------|--------------------------------------------------------------------| +| String | character array | Array of char of specified length, padded by NUL character if a string is shorter than the length specified for a field. | Specified by length attribute | length | + +A length attribute set to zero indicates variable length. See section [*Variable-length string*](#variable-length-string-encoding). + +#### Encoding specifications for fixed-length character array + +A fixed-length character array encoding must specify +primitiveType="char" and a length attribute is required. + +Range attributes minValue and maxValue do not apply to fixed-length +character arrays. + +Character arrays are constrained to single-byte characters sets with the same character ranges as a single-character field. The recommended encoding is ISO/IEC 8859-1:1998 Latin alphabet No. 1. + +Other 8-bit encodings may be specified in a message schema with the characterEncoding attribute. The value of characterEncoding should be a preferred +character set name registered with IANA. + +#### Examples of fixed-length character arrays + +A typical string encoding specification + +```xml + + + +``` + +A character array with an explicit character set, Latin alphabet No. 1. + +```xml + +``` + +Wire format of a character array in character and hexadecimal formats + +M S F T + +`4d5346540000` + +A character array constant specification. As for a non-constant value, if the constant is shorter than the specified length, it should be padded with NUL characters to fill the fixed-length array. + +```xml + + +XEUR +``` + +### Variable-length string encoding + +Variable-length string encoding is used for variable length +strings or character data with a multi-byte character set (like FIX EncodedText field). A +length member conveys the size of the string that follows in octets, which may be different than the number of characters. + +On the wire, length immediately precedes the data. + +The length member may not be null, but may be set to zero for an empty +string. In that case, no space is reserved for the data. No distinction +is made at an encoding layer between an empty string and a null string. +Semantics of an empty variable-length string should be specified at an +application layer. + +| FIX data type | Description | Backing primitives | Length (octets) | +|---------------|---------------------------------------|----------------------------------------------------------------------------------------------------------------------------|-----------------| +| Length | The length of variable data in octets | primitiveType="uint8" or "uint16" May not hold null value. | 1 or 2 | +| data | Raw data | Array of octet of size specified in associated Length field. The data field itself should be specified as variable length. primitiveType="uint8" length="0" indicates variable length | variable | + +Optionally, implementations may support any other unsigned integer types +for length. + +### Range attributes for string Length + +| Schema attribute | length uint8 | length uint16 | +|------------------|----------------:|----------------:| +| minValue | 0 | 0 | +| maxValue | 254 | 65534 | + +If the Length element has minValue and maxValue attributes, it specifies +the minimum and maximum *length* of the variable-length data. + +Range attributes minValue , maxValue, and nullValue do not apply to the +data element. + +If a field is required, both the Length and data fields must be set to a +"required" attribute. + +### Encoding specifications for variable-length string + +Variable length string is encoded as a composite type, consisting of a +length member and varData member. In the composite specification, they must be listed with those names and in that order. The length attribute of the varData +member is set to zero in the XML message schema as special value to +indicate that the character data is of variable length. + +To map an SBE data field specification to traditional FIX, the field ID +of a data field is used. Its associated length is implicitly contained +by the composite type rather than specified as a separate field. + +Encoding specification for variable length data up to 65535 octets + +```xml + + + + + + +``` + +The characterEncoding attribute tells which variable-sized encoding is +used if the data field represents encoded text. UTF-8 is the recommended +encoding, but there is no default in the XML schema + +### Example of a variable-length string field + +Example shows encoded bytes on the wire. + +Wire format of variable-length String in character and hexadecimal +formats, preceded by uint16 length of 4 octets in little-endian byte +order + +M S F T + +`04004d534654` + +## Data encodings + +Raw data is opaque to SBE. In other words, it is not constrained by any +value range or structure known to the messaging layer other than length. +Data fields simply convey arrays of octets. + +Data may either be of fixed-length or variable-length. In Simple Binary +Encoding, fixed-length data encoding may be used for data of +predetermined length, even though it does not represent a FIX data type. +Variable-length encoding should be reserved for raw data when its length +is not known until run-time. + +### Fixed-length data + +Data arrays are allocated as a fixed space in a message, supporting +direct access to fields. A fixed size array is distinguished from a +variable length data by the presence of a length schema attribute rather +than sending length on the wire. + +| FIX data type | Description | Backing primitives | Length (octets) | Required schema attribute | +|---------------|-------------|-------------------------------------|-------------------------------|---------------------------| +| data | octet array | Array of uint8 of specified length. | Specified by length attribute | length | + +#### Encoding specifications for fixed-length data + +A fixed-length octet array encoding should specify primitiveType="uint8" +and a length attribute is required. + +Data range attributes minValue and maxValue do not apply. + +Since raw data is not constrained to a character set, characterEncoding +attribute should not be specified. + +#### Example of fixed-length data encoding + +A fixed-length data encoding specification for a binary user ID + +```xml + + + +``` + +### Variable-length data encoding + +Variable-length data is used for variable length non-character data +(such as RawData). A length member conveys the size of the data that follows. +On the wire, length immediately precedes the data. + +The length member may not be null, but it may be set to zero. In that +case, no space is reserved for the data. Semantics of an empty +variable-length data element should be specified at an application +layer. + +| FIX data type | Description | Backing primitives | Length (octets) | +|---------------|---------------------------------------|----------------------------------------------------------------------------------------------------------------------------|-----------------| +| Length | The length of variable data in octets | primitiveType="uint8" or "uint16" May not hold null value. | 1 or 2 | +| data | Raw data | Array of octet of size specified in associated Length member. The varData member should be specified as variable length. primitiveType="uint8" | variable + +Optionally, implementations may support any other unsigned integer types +for length. + +### Range attributes for variable-length data Length + +| Schema attribute | length uint8 | length uint16 | data | +|------------------|-------:|-------:|------| +| minValue | 0 | 0 | N/A | +| maxValue | 254 | 65534 | N/A | + +If the Length field has minValue and maxValue attributes, it specifies +the minimum and maximum *length* of the variable-length data. Data range +attributes minValue , maxValue, and nullValue do not apply to a data +field. + +If a field is required, both the Length and data fields must be set to a +"required" attribute. + +### Encoding specifications for variable-length data + +Variable length data is encoded as composite type, consisting of a +length member and varData member. They must be listed with those names and in that order in the composite specification. + +To map an SBE data field specification to traditional FIX, the field ID +of a data field is used. Its associated length is implicitly contained +by the composite type rather than specified as a separate field. + +Encoding specification for variable length data up to 65535 octets + +```xml + + + + + + +``` + +### Example of a data field + +Example shows encoded bytes on the wire. + +Wire format of data in character and hexadecimal formats, preceded by +uint16 length of 4 octets in little-endian byte order + +M S F T + +`04004d534654` + +## MonthYear encoding + +MonthYear encoding contains four members representing respectively +year, month, and optionally day or week. A field of this type is not +constrained to one date format. One message may contain only year and +month while another contains year, month and day in the same field, for +example. + +Values are distinguished by position in the field. Year and month must +always be populated for a non-null field. Day and week are set to +special value indicating null if not present. If Year is set to the null +value, then the entire field is considered null. + +| Member | Primitive type | Length (octets) | Null value | +|----------------------------------|----------------|----------------:|-----------:| +| Year | uint16 | 2 | 65535 | +| Month (1-12) | uint8 | 1 | — | +| Day of the month(1-31) optional | uint8 | 1 | 255 | +| Week of the month (1-5) optional | uint8 | 1 | 255 | + + +### Composite encoding padding + +The four members of MonthYear are packed at an octet level by default. +However, byte alignment may be controlled by specifying offset of the +elements within the composite encoding. See section [*Element offset within a composite type*](#element-offset-within-a-composite-type) below. + +### Encoding specifications for MonthYear + +MonthYear data type is based on a composite encoding that carries its +required and optional elements. The members must listed with the names and in the order shown. + +The standard encoding specification for MonthYear + +```xml + + + + + + +``` + +Example MonthYear field specification + +```xml + +``` + +Wire format of MonthYear 2014 June week 3 as hexadecimal + +`de0706ff03` + +## Date and time encoding + +Dates and times represent Coordinated Universal Time (UTC). This is the +preferred date/time format, except where regulations require local time +with time zone to be reported (see time zone encoding below). + +### Epoch + +Each time type has an epoch, or start of a time period to count values. +For timestamp and date, the standard epoch is the UNIX epoch, midnight +January 1, 1970 UTC. + +A time-only value may be thought of as a time with an epoch of midnight +of the current day. Like current time, the epoch is also referenced as +UTC. + +### Time unit + +Time unit tells the precision at which times can be collected. Time unit +may be serialized on the wire if timestamps are of mixed precision. On +the other hand, if all timestamps have the same precision, then time +unit may be set to a constant in the message schema. Then it need not be +sent on the wire. + +| FIX data type | Description | Backing primitives | Length (octets) | Schema attributes | +|---------------|--------------------------------------------------------------------------|--------------------|----------------:|------------------------| +| UTCTimestamp | UTC date/time Default: nanoseconds since Unix epoch Range Jan. 1, 1970 - July 21, 2554 | uint64 time | 8 | epoch=”unix” (default) | | | | +| | timeUnit = second or millisecond or microsecond or nanosecond May be constant | uint8 unit | 1 | | +| UTCTimeOnly | UTC time of day only Default: nanoseconds since midnight today | uint64 time | 8 | | +| | timeUnit = second or millisecond or microsecond or nanosecond May be constant | uint8 unit | 1 | | +| UTCDateOnly | UTC calendar date Default: days since Unix epoch. Range: Jan. 1, 1970 - June 7, 2149 | uint16 | 2 | epoch=”unix” (default) | + + +### Encoding specifications for date and time + +Time specifications use an enumeration of time units. See section [*Enumeration encoding*](#enumeration-encoding) below for a fuller explanation of enumerations. + +Enumeration of time units: + +```xml + + 0 + 3 + 6 + 9 + +``` +Composite type members must listed with the names and in the order shown. + +Timestamp with variable time units: + +```xml + + + + +``` + +Timestamp with constant time unit: + +```xml + + + + +``` + +Time only with variable time units: + +```xml + + + + +``` + +Time only with constant time unit: + +```xml + + + + +``` + +Date only specification: + +```xml + +``` + +### Examples of date/time fields + +**timestamp** 14:17:22 Friday, October 4, 2024 UTC (20,000 days and 14 +hours, 17 minutes and 22 seconds since the UNIX epoch) with default +schema attributes + +```xml + + + + +``` + +Wire format of UTCTimestamp with constant time unit in little-Endian +byte order + +`004047baa145fb17` + +**time** 10:24:39.123456000 (37,479 seconds and 123456000 nanoseconds +since midnight UTC) with default schema attributes + +```xml + + + + +``` + +Wire format of UTCTimeOnly + +`0010d74916220000` + +**date** Friday, October 4, 2024 (20,000 days since UNIX epoch) with +default schema attributes + +```xml + +``` + +Wire format of UTCDateOnly + +`204e` + +## Local date encoding + +Local date is encoded the same as UTCDateOnly, but it represents local +time at the market instead of UTC time. + +| FIX data type | Description | Backing primitives | Length (octets) | Schema attributes | +|---------------|-------------------------------------------------------------------------------|--------------------|----------------:|------------------------------------| +| LocalMktDate | Local calendar date Default: days since Unix epoch. Range: Jan. 1, 1970 - June 7, 2149 local time | uint16 | 2 | epoch=”unix” (default) + +The standard encoding specification for LocalMktDate + +```xml + +``` + +## Local time encoding + +Time with time zone encoding should only be used when required by market +regulations. Otherwise, use UTC time encoding (see above). + +Time zone is represented as an offset from UTC in the ISO 8601:2004 +format ±hhmm. + +### TZTimestamp encoding + +A binary UTCTimestamp followed by a number representing the time zone +indicator as defined in ISO 8601:2004. + +| FIX data type | Description | Backing primitives | Length (octets) | Schema attributes | +|---------------|--------------------------------------------------------------------------|--------------------|----------------:|------------------------------------| +| TZTimestamp | date/time with timezone Default: nanoseconds since Unix epoch Range Jan. 1, 1970 - July 21, 2554 | uint64 | 8 | epoch=”unix” (default) Represents Jan. 1, 1970 local time | +| | timeUnit = second or millisecond or microsecond or nanosecond May be constant | uint8 | 1 | | +| | Time zone hour offset | int8 | 1 | None | +| | Time zone minute offset | uint8 | 1 | None | + +### Composite encoding padding + +The members of TZTimestamp are packed at an octet level by default. +However, byte alignment may be controlled by specifying offset of the +elements within the composite encoding. See section [*Element offset within a composite type*](#element-offset-within-a-composite-type) below. + +The members must be listed with the names and in the order shown. + +Standard TZTimestamp encoding specification + +```xml + + + + + + + +``` + +Wire format of TZTimestamp 8:30 17 September 2013 with Chicago time zone +offset (-6:00) + +`0050d489fea22413fa00` + +### TZTimeOnly encoding + +A binary UTCTimeOnly followed by a number representing the time zone +indicator as defined in ISO 8601:2004. + +The time zone hour offset tells the number of hours different to UTC +time. The time zone minute tells the number of minutes different to UTC. +The sign telling ahead or behind UTC is on the hour member. + +| FIX data type | Description | Backing primitives | Length (octets) | Schema attributes | +|---------------|------------------------------------------------------------|--------------------|----------------:|-------------------| +| TZTimeOnly | Time of day only with time zone Default: nanoseconds since midnight today, local time | uint64 | 8 | None | +| | timeUnit = second or millisecond or microsecond or nanosecond May be constant | uint8 | 1 | None | +| | Time zone hour offset | int8 | 1 | None | +| | Time zone minute offset | uint8 | 1 | None | + +### Composite encoding padding + +The members of TZTimeOnly are packed at an octet level by default. +However, byte alignment may be controlled by specifying offset of the +elements within the composite encoding. See section [*Element offset within a composite type*](#element-offset-within-a-composite-type) below. + +Standard TZTimeOnly encoding specification + +```xml + + + + + + + +``` + +Wire format of TZTimeOnly 8:30 with Chicago time zone offset (-6:00) + +`006c5ebe76000000fa00` + +## Enumeration encoding + +An enumeration conveys a single choice of mutually exclusive valid +values. + +### Primitive type encodings + +An unsigned integer or character primitive type is selected to contain +the number of choices. Implementations must support char and uint8 +types. They may additionally support other unsigned integer types to +allow more choices. + +| Primitive type | Description | Length (octets) | Maximum number of choices | +|----------------|------------------------|----------------:|--------------------------:| +| char | character | 1 | 95 | +| uint8 | 8-bit unsigned integer | 1 | 255 | + +### Value encoding + +If a field is of FIX data type char, then its valid values are +restricted to single-byte printable characters. See section [*Character encoding*](#character) above. + +If the field is of FIX data type int, then a primitive integer data type +should be selected that can contain the number of choices. For most +cases, an 8 bit integer will be sufficient, allowing 255 possible +values. + +Enumerations of other data types, such as String valid values specified +in FIX, should be mapped to an integer wire format in SBE. + +### Encoding specification of enumeration + +In a message schema, the choices are specified a `` members +of an ``. An `` specification must contain at least one +``. + +The name and value of a validValue element must be unique within an +enumeration. + +An `` element must have an encodingType attribute to specify the +type of its values. Two formats of encodingType are acceptable: + +- In-line style: the value of encodingType is its primitive data type. + +- Reference style: the value of encodingType is the name of a `` + element that specifies the wire format. + +The length of a `` associated to an enumeration must be 1. That +is, enumerations should only be backed by scalar types, not arrays. + +### Enumeration examples + +These examples use a char field for enumerated code values. + +Example enum lists acceptable values and gives the underlying encoding, +which in this case is char (in-line style) + +```xml + + 1 + 2 + 5 + 6 + + +``` + +Reference to type: This specification is equivalent to the one above. + +```xml + + + + +``` + +Side field specification references the enumeration type + +```xml + +``` + +Wire format of Side "Buy" code as hexadecimal + +`01` + +### Constant field of an enumeration value + +A constant field may be specified as a value of an enumeration. The +attribute valueRef is a cross-reference to validValue entry by symbolic +name. + +Example of a char field using a constant enum value + +```xml + + B + C + D + + + +``` + +### Boolean encoding + +A Boolean field is a special enumeration with predefined valid values: +true and false. Like a standard enumeration, an optional Boolean field +may have nullValue that indicates that the field is null (or not +applicable). + +Standard encoding specifications for required and optional Boolean +fields + +```xml + + 0 + 1 + +``` + +Example optional Boolean field + +```xml + + + +``` + +Wire format of true value as hexadecimal + +`01` + +Wire format of false value as hexadecimal + +`00` + +Wire format of null Boolean (or N/A) value as hexadecimal + +`ff` + +## Multi-value choice encoding + +A multi-value field conveys a choice of zero or more non-exclusive valid values. + +### Primitive type encodings + +The binary encoding uses a bitset (a fixed-size sequence of bits, also +known as bitmap, bit array or bit vector) to represent up to 64 possible +choices. The encoding is backed by an unsigned integer. The smallest +unsigned primitive type should be selected that can contain the number +of valid choices. + +| Primitive type | Description | Length (octets) | Maximum number of choices | +|----------------|-------------------------|----------------:|--------------------------:| +| uint8 | 8-bit unsigned integer | 1 | 8 | +| uint16 | 16-bit unsigned integer | 2 | 16 | +| uint32 | 32-bit unsigned integer | 4 | 32 | +| uint64 | 64-bit unsigned integer | 8 | 64 | + +Like other integer-backed encodings, multi-value encodings follow the +byte order specified by message schema when serializing to the wire. See +section [*Message Schema*](#message-schema) for specification of message schema attributes, including +byteOrder. + +### Value encoding + +Each choice is assigned a bit of the primitive integer encoding, +starting with the least significant bit. For each choice the value is +selected or not, depending on whether it corresponding bit is set or +cleared. + +Any remaining unassigned bits in an octet should be cleared. + +There is no explicit null value for multi-value choice encoding other +than to set all bits off when no choices are selected. + +### Encoding specification of multi-value choice + +In a message schema, the choices are specified as `` members of +an `` element. Choices are assigned values as an ordinal of bits in +the bit set. The first Choice "0" is assigned the least significant bit; +choice "1" is the second bit, and so forth. + +The name and value (bit position) must be unique for element of a set. + +A `` element must have an encodingType attribute to specify the +wire format of its values. Two formats of encodingType are recognized : + +- In-line style: the value of encodingType is its primitive data type. + +- Reference style: the value of encodingType is the name of a `` + element that specifies the wire format. + +The length of a `` associated to an bitset must be 1. That is, +bitsets should not be specified as arrays. + +### Multi-value example + +Example of a multi-value choice (was MultipleCharValue in tag-value encoding) Encoding type is +in-line style. + +```xml + + 0 + 1 + 2 + +``` + +Reference to type. This is equivalent to the example above. + +```xml + + + + + +``` + +A field using the multi-choice encoding + +```xml + +``` + +Wire format of choices "Bankrupt" + "Pending delisting" (first and +second bits set) + +`03` + +## Field value validation + +These validations apply to message field values. + +If a value violation is detected on a received message, the message +should be rejected back to the counterparty in a way appropriate to the +session protocol. + +| Error condition | Error description | +|-------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------| +| Field value less than minValue | The encoded value falls below the specified valid range. | +| Field value greater than maxValue | The encoded value exceeds the specified valid range. | +| Null value set for required field | The null value of a data type is invalid for a required field. | +| String contains invalid characters | A character or character array contains controls characters or a string contains an invalid sequence if a different characterEncoding is specified. | +| Required members not populated in MonthYear | Year and month must be populated with non-null values, and the month must be in the range 1-12. | +| UTCTimeOnly exceeds day range | The value must not exceed the number of time units in a day, e.g. greater than 86400 seconds. | +| TZTimestamp and TZTimeOnly has missing or invalid time zone | The time zone hour and minute offset members must correspond to an actual time zone recognized by international standards. | +| Value must match valid value of an enumeration field | A value is invalid if it does not match one of the explicitly listed valid values. | diff --git a/v2-0-RC3/doc/03MessageStructure.md b/v2-0-RC3/doc/03MessageStructure.md new file mode 100644 index 0000000..3479da9 --- /dev/null +++ b/v2-0-RC3/doc/03MessageStructure.md @@ -0,0 +1,546 @@ +# Message Structure + +## Message Framing + +SBE messages have no defined message delimiter. SBE makes it possible to walk the elements of a message to determine its limit, even when the message has been extended. Nevertheless, since internal framing depends on a correct starting point and not encountering malformed messages, it may be desirable to use an external framing protocol when used with transports that do not preserve message boundaries, such as when they are transmitted on a streaming +session protocol or when persisting messages in storage. + +### Simple Open Framing Header + +FIX Protocol Ltd. offers the Simple Open Framing Header standard for +framing messages encoded with binary wire formats, such as Simple Binary +Encoding. + +The framing header provides two features: + +- An overall message size including headers to support framing + +- An identifier of the encoding used in the message payload. This + supports selecting the correct decoder in the case where multiple + message encodings are used on a session. It also aids tooling such + as protocol analyzers to identify message protocols contained in + network packets. + +While the Simple Open Framing Header specification is normative, the +following is an interpretation of that standard as an SBE encoding. Note +that the framing standard specifies that the framing header will always +be encoded in big-endian byte order, also known as network byte order. + +Simple Open Framing Header as an SBE composite encoding (big-endian) + +```xml + + + + +``` + +The values of encodingType used to indicate SBE payloads are currently +defined as: + +| Encoding | encodingType value | +|-------------------------------|--------------------| +| SBE version 1.0 big-endian | 0x5BE0 | +| SBE version 1.0 little-endian | 0xEB50 | + +The Simple Open Framing Header specification also lists values for other +wire formats. + +## SBE Message Encoding Header + +The purpose of the message encoding header is to tell which message +template was used to encode the message and to give information about +the size of the message body to aid in decoding, even when a message +template has been extended in a later version. See section [*Schema Extension Mechanism*](#schema-extension-mechanism) below for +details. + +The fields of the SBE message header are: + +- **Block length of the message root** - the total space reserved for + the root level of the message not counting any repeating groups or + variable-length fields. + +- **Template ID** - identifier of the message template + +- **Schema ID** - identifier of the message schema that contains the + template + +- **Schema version** - the version of the message schema in which the + message is defined + +- **Group count** - the number of repeating groups in the root level of the message + +- **Variable-length field count** - the number of variable-length fields in the root level of the message + +Block length is specified in a message schema, but it is also serialized +on the wire. By default, block length is set to the sum of the sizes of +body fields in the message. However, it may be increased to force +padding at the end of block. See section [*Padding*](#padding-at-end-of-a-message-or-group). + +### Message header schema + +The header fields precede the message body of every message in a fixed +position as shown below. Each of these fields must be encoded as an +unsigned integer type. The encoding must carry the name "messageHeader". + +The message header is encoded in the same byte order as the message +body, as specified in a message schema. See section [*Message Schema*](#message-schema). + +Recommended message header encoding + +```xml + + + + + + + + +``` + +The recommended header encoding is 12 octets. + +| Element | Description | Primitive type | Length (octets) | Offset | +|-------------|-------------------|----------------|----------------:|-------:| +| blockLength | Root block length | uint16 | 2 | 0 | +| templateId | Template ID | uint16 | 2 | 2 | +| schemaId | Schema ID | uint16 | 2 | 4 | +| version | Schema Version | uint16 | 2 | 6 | +| numGroups |Number of repeating groups | uint16 | 2 | 8 | +| numVarDataFields | Number of variable-length fields | uint16 | 2 | 10 | + +Optionally, implementations may support any other unsigned integer types +for blockLength. + +### Root block length + +The total space reserved for the root level of the message not counting +any repeating groups or variable-length fields. (Repeating groups have +their own block length; see section [*Group block length*](#group-block-length) below. Length of a +variable-length Data field is given by its corresponding Length field; +see section [*Variable-length string*](#variable-length-string-encoding).) Block length only represents message body +fields; it does not include the length of the message header itself, +which is a fixed size. + +The block size must be at least the sum of lengths of all fields at the +root level of the message, and that is its default value. However, it +may be set larger to reserve more space to effect alignment of blocks. +This is specified by setting the blockLength attribute in a message +schema. + +### Template ID + +The identifier of a message type in a message schema. See section [*Message Schema*](#message-schema) +for schema attributes of a message. + +### Schema ID + +The identifier of a message schema. See section [*Message Schema*](#message-schema) for schema +attributes. + +### Schema version + +The version number of the message schema that was used to encode a +message. See section [*Message Schema*](#message-schema) for schema attributes. + +### Number of repeating groups + +A count of repeating groups at the root level of the message. The count does not include nested repeating groups. + +### Number of variable-length fields + +A count of the variable-length fields at the root level of the message. The count does not include variable-length fields within repeating groups. + + +## Message Body + +The message body conveys the business information of the message. + +### Data only on the wire + +In SBE, fields of a message occupy proximate space without delimiters or +metadata, such as tags. + +### Direct access + +Access to data is positional, guided by a message schema that specifies +a message type. + +Data fields in the message body correspond to message schema fields; +they are arranged in the same sequence. The first data field has the +type and size specified by the first message schema field, the second +data field is described by the second message schema field, and so +forth. Since a message decoder follows the field descriptions in the +schema for position, it is not necessary to send field tags on the wire. + +In the simplest case, a message is flat record with a fixed length. +Based on the sequence of field data types, the offset to a given data +field is constant for a message type. This offset may be computed in +advance, based on a message schema. Decoding a field consists of +accessing the data at this fixed location. + +### Field position and padding + +#### No padding by default + +By default, there is no padding between fields. In other words, a field +value is packed against values of its preceding and following fields. No +consideration is given to byte boundary alignment. + +By default, the position of a field in a message is determined by the +sum of the sizes of prior fields, as they are defined by the message +schema. + +```xml + + + + +``` + +| Field | Size | Offset | +|----------|-----:|-------:| +| ClOrdID | 14 | 0 | +| Side | 1 | 14 | +| OrderQty | 4 | 15 | +| Symbol | 8 | 19 | + +#### Field offset specified by message schema + +If a message designer wishes to introduce padding or control byte +boundary alignment or map to an existing data structure, field offset +may optionally be specified in a message schema. Field offset is the +number of octets from the start of the message body or group to the +first octet of the field. Offset is a zero-based index. + +If specified, field offset must be greater than or equal to the sum of +the sizes of prior fields. In other words, an offset is invalid if it +would cause fields to overlap. + +Extra octets specified for padding should never be interpreted as +business data. They should be filled with binary zeros. + +The offset attribute is mutually exclusive with alignment; see below. + +Example of fields with specified offsets + +```xml + + + + +``` + +| Field | Size | Padding preceding field | Offset | +|----------|------|------------------------:|-------:| +| ClOrdID | 14 | 0 | 0 | +| Side | 1 | 0 | 14 | +| OrderQty | 4 | 1 | 16 | +| Symbol | 8 | 0 | 20 | + +#### Field byte alignment +As an alternative to specifying a field's offset from the start of a block, its byte alignment may be specified. If specified, the start of a field should reside at an offset from the start of the buffer that is the next multiple of the alignment attribute. If the offset without alignment would not be a multiple of the alignment attribute, then the buffer is padded with octets to that multiple. The padding should be set to binary zeroes. + +The alignment attribute is mutually exclusive with offset. + +If neither offset nor alignment attributes are set, then a field is positioned at the next available octet in a buffer without padding. + +Computation of padding and effective offset is as follows, where effective-offset is the resulting position in the buffer: + +``` +padding = (alignment - (unaligned-offset modulo alignment)) modulo alignment +effective-offset = unaligned-offset + padding +``` + +Example of fields with alignment that is equivalent to the offset example above: + +```xml + + + + +``` + +#### Padding at end of a message or group + +In order to force messages or groups to align on byte boundaries or map +to an existing data structure, they may optionally be specified to +occupy a certain space with a blockLength attribute in the message +schema. The extra space is padded at the end of the message or group. If +specified, blockLength must be greater than or equal to the sum of the +sizes of all fields in the message or group. + +The blockLength attribute applies only to the portion of message that +contains fix-length fields; it does not apply to variable-length data +elements of a message. + +Extra octets specified for padding should be filled with binary zeros. + +Example of blockLength specification for 24 octets + +```xml + +``` + +## Repeating Groups + +A repeating group is a message structure that contains a variable number +of entries. Each entry contains fields specified by a message schema. + +The order and data types of the fields are the same for each entry in a +group. That is, the entries are homogeneous. Position of a given +field within any entry is fixed, with the exception of variable-length +fields. + +A message may have no groups or an unlimited number of repeating groups +specified in its schema. + +### Schema specification of a group + +A repeating group is defined in a message schema by adding a `` +element to a message template. An unlimited number of `` elements +may be added to a group, but a group must contain at least one field. + +Example repeating group encoding specification + +```xml + + + + + +``` + +### Group block length + +The blockLength part of a group dimension represents total space reserved +for each group entry, not counting any nested repeating groups or variable-length +fields. (Length of a variable-length Data field is given by its corresponding +Length field.) Block length only represents message body fields; it does not +include the length of the group dimension itself, which is a fixed size. + +### Byte alignment of a group entry + +If byte alignment of a repeating group is specified, the start of the first field of each entry should reside at an offset from the start of the buffer that is the next multiple of the alignment attribute. If the offset without alignment would not be a multiple of the alignment attribute, then the buffer is padded with octets to that multiple. The padding should be set to binary zeroes. + +If byte alignment is not specified for a group, then no padding is introduced to align entries. + +### Padding at end of a group entry + +By default, the space reserved for an entry is the sum of a group’s +field lengths, as defined by a message schema, without regard to byte +alignment. + +The space reserved for an entry may optionally be increased to effect +alignment of entries or to plan for future growth. This is specified by +adding the group attribute blockLength to reserve a specified number of +octets per entry. If specified, the extra space is padded at the end of +each entry and should be set to zeroes by encoders. The blockLength +value does not include the group dimensions itself. + +Note that padding will only result in deterministic alignment if the +repeating group contains no variable-length fields. Therefore, the alignment attribute is a more direct solution to that need. + +### Entry counter + +Each group is associated with a required counter field of semantic data +type NumInGroup to tell how many entries are contained by a message. The +value of the counter is a non-negative integer. See section [*Encoding of repeating group dimensions*](#encoding-of-repeating-group-dimensions) below +for encoding of that counter. + +### Empty group + +The space reserved for all entries of a group is the product of the +space reserved for each entry times the value of the associated +NumInGroup counter. If the counter field is set to zero, then no entries +are sent in the message, and no space is reserved for entries. The group +dimensions including the zero-value counter is still transmitted, +however. + +### Multiple repeating groups + +A message may contain multiple repeating groups at the same level. + +Example of encoding specification with multiple repeating groups + +```xml + + + + + + + + +``` + +### Nested repeating group specification + +Repeating groups may be nested to an arbitrary depth. That is, a +`` in a message schema may contain one or more `` child +elements, each associated with their own counter fields. + +The encoding specification of nested repeating groups is in the same +format as groups at the root level of a message in a recursive +procedure. + +Example of nested repeating group specification + +```xml + + + + + + + + + + + +``` + +### Nested repeating group wire format + +Nested repeating groups are encoded on the wire by a depth-first walk of +the data hierarchy. For example, all inner entries under the first outer +entry must be encoded before encoding outer entry 2. (This is the same +element order as FIX tag=value encoding.) + +On decoding, nested repeating groups do no support direct access to +fields. It is necessary to walk all elements in sequence to discover the +number of entries in each repeating group. + +### Empty group means nested group is empty + +If a group contains nested repeating groups, then a NumInGroup counter +of zero implies that both that group and its child groups are empty. In +that case, no NumInGroup is encoded on the wire for the child groups. + +### Group dimension encoding + +Every repeating group must be immediately preceded on the wire by its +dimensions. The two dimensions are the count of entries in a repeating +group and the space reserved for each entry of the group. + +#### Range of group entry count + +Implementations should support uint8 and uint16 types for repeating +group entry counts. Optionally, implementations may support any other +unsigned integer types. + +By default, the minimum number of entries is zero, and the maximum number is the largest value of the primitiveType of the counter. + +| Primitive type | Description | Length (octets) | Maximum number of entries | +|----------------|-------------------------|----------------:|--------------------------:| +| uint8 | 8-bit unsigned integer | 1 | 255 | +| uint16 | 16-bit unsigned integer | 2 | 65535 | + +The number of entries may be restricted to a specific range; see "Restricting repeating group entries" below. + +#### Encoding of repeating group dimensions + +Conventionally in FIX, a NumInGroup field conveys the number of entries +in a repeating group. In SBE, the encoding conveys two dimensions: the +number of entries and the length of each entry in number octets. +Therefore, the encoding is a composite of those two elements. Block +length and entry count subfields must be encoded as unsigned integer +types. + +By default, the name of the group dimension encoding is +groupSizeEncoding. This name may be overridden by setting the +dimensionType attribute of a `` element. + +Recommended encoding of repeating group dimensions + +```xml + + + + + + +``` + +#### Block length + +The total space reserved for the fixed-length fields of this repeating group, not counting +any repeating groups or variable-length fields. + +#### Number of entries + +The number of entries in this repeating group, called NumInGroup in FIX. + +#### Number of repeating groups + +A count nested repeating groups in this repeating group. + +#### Number of variable-length fields + +A count of the variable-length fields in this repeating group. + +Wire format of NumInGroup with block length 55 octets by 3 entries, containing one nested group and two variable-length fields. + +`3700030001000200` + +#### Restricting repeating group entries + +The occurrences of a repeating group may be restricted to a specific range by modifying the numInGroup member of the group dimension encoding. The minValue attribute controls the minimum number of entries, overriding the default of zero, and the maxValue attribute restricts the maximum entry count to something less than the maximum corresponding to its primitiveType. Either or both attributes may be specified. + +Example of a restricted group encoding + +```xml + +``` + +## Sequence of message body elements + +### Root level elements + +To maximize deterministic field positions, message schemas must be +specified with this sequence of message body elements: + +1. Fixed-length fields that reside at the root level of the message + (that is, not members of repeating groups), including any of the + following, in the order specified by the message schema:: + + a. Fixed-length scalar fields, such as integers + + b. Fixed-length character arrays + + c. Fixed-length composite types, such as MonthYear + +2. Repeating groups, if any. + +3. Data fields, including raw data and variable-length strings, if any. + +### Repeating group elements + +Repeating group entries are recursively organized in the same fashion as +the root level: fixed-length fields, then nested repeating groups, and +finally, variable-length data fields. + +## Message structure validation + +Aside from message schema validations (see section [*Schema validation*](#schema-validation)), these +validations apply to message structure. + +If a message structure violation is detected on a received message, the +message should be rejected back to the counterparty in a way appropriate +to the session protocol. + +| Error condition | Error description | +|-------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Wrong message size in header | A message size value smaller than the actual message may cause a message to be truncated. | +| Wrong or unknown template ID in header | A mismatch of message schema would likely render a message unintelligible or cause fields to be misinterpreted. | +| Fixed-length field after repeating group or variable-length field | All fixed-length fields in the root of a message or in a repeating group entry must be listed before any (nested) repeating group or variable-length field. | +| Repeating group after variable-length field | All repeating groups at the root level or in a nested repeating group must be listed before any variable length field at the same level. | diff --git a/v2-0-RC3/doc/04MessageSchema.md b/v2-0-RC3/doc/04MessageSchema.md new file mode 100644 index 0000000..c091fba --- /dev/null +++ b/v2-0-RC3/doc/04MessageSchema.md @@ -0,0 +1,626 @@ +# Message Schema + +## XML schema for SBE message schemas + +See [SBE XSD](../resources/sbe-2.0rc3.xsd) for the normative XML Schema Definition (XSD) for SBE. + +The SBE schema is defined with W3C XML Schema Definition Language (XSD) version 1.0. (XSD version 1.1 was standardized. +However, since it is not supported by all XML processors, the SBE XSD is constrained to features of version 1.0.) + +### XInclude usage + +Certain elements of the SBE message schema support inclusion from a separate XML file. The result of the XInclude mechanism +is a single XML infoset, so the schema description below applies whether a single file is used or multiple files are assembled. + + +## XML namespace + +The Simple Binary Encoding XML schema is identified by this URL [*tentative*]: + +```xml +xmlns:sbe=http://fixprotocol.io/2017/sbe +``` + +Conventionally, the URI of the XML schema is aliased by the prefix +"sbe". + +*Caution:* Users should treat the SBE XML namespace as a URI (unique identifier), +not as a URL (physical resource locator). Firms should not depend on +access to the FIX Trading Community web site to validate XML schemas at +run-time + +## Name convention + +All symbolic names in a message schema are restricted to alphanumeric +characters plus underscore without spaces. This is the same restriction +applied to all names in FIX specifications. + +### Capitalization + +The value of a field's `semanticType` attribute is a FIX data type. In +this document, FIX types are capitalized exactly as in the FIX +repository, from which all official FIX documentation and references are +derived. Since the capitalization is somewhat inconsistent, however, it +is recommended that matching of type names should be case insensitive in +schema parsers. + +## Root element + +The root element of the XML document is ``. + +### `` attributes + +The root element provides basic identification of a schema. + +The `byteOrder` attribute controls the byte order of integer encodings +within the schema. It is a global setting for all specified messages and +their encodings. + +| Schema attribute | Description | XML type | Usage | Valid values | +|------------------|--------------------------------------------------------------------------------------------------|--------------------|------------------------|------------------------------------------------------------------------------| +| package | Name or category of a schema | string | optional | Should be unique between counterparties but no naming convention is imposed. | +| id | Unique identifier of a schema | unsignedInt | | Should be unique between counterparties | +| version | Version of this schema | nonnegativeInteger | | Initial version is zero and is incremented for each version | +| semanticVersion | Version of FIX semantics | string | optional | FIX versions, such as “FIX.5.0\_SP2” | +| byteOrder | Byte order of encoding | token | default = littleEndian | littleEndian bigEndian | +| description | Documentation of the schema | string | optional | | +| headerType | Name of the encoding type of the message header, which is the same for all messages in a schema. | string | default= messageHeader | An encoding with this name must be contained by ``. | + + +### Schema versioning + +Changes to a message schema may be tracked by its `version` attribute. A +version of a schema is a snapshot in time. All elements in a given +generation of the schema share the same version number. That is, +elements are not versioned individually. By convention, the initial +version of a schema is version zero, and subsequent changes increment +the version number. + +The `package` attribute should remain constant between versions, if it is +supplied. + +## Data encodings + +### Encoding sets + +A `` element contains a set of data encodings used by messages within a schema. A message schema may have multiple +instances of ``, if desired, to organize them by categories. Each `` element may have an associated `package` name. + +**`` element attribute** + +| Schema attribute | Description | XML type | Usage | Valid values | +|------------------|--------------------------------------------------------------------------------------------------|--------------------|------------------------|------------------------------------------------------------------------------| +| package | Overrides package of messageSchema | string | optional | Should be unique between counterparties but no naming convention is imposed. | + +The `` element has attribute `xml:base` to support inclusion from a separate XML file using the XInclude mechanism. +Thus, common encoding types may be shared across multiple SBE message schemas. + + +Within each set, an unbound number of encodings will be listed in any +sequence: + +- Element `` defines a simple encoding + +- Element `` defines a composite encoding + +- Element `` defines an enumeration + +- Element `` defines a multi-value choice bitset encoding + +### Encoding name + +The namespace for encoding names is global across all encodings included +in a schema, including simple, composite and enumeration types. That is, +the name must be unique among all encoding instances. + +All symbolic names should be alphanumeric without spaces. + + +#### Importing encodings + +A suggested usage is to import common encodings that are used across +message schemas as one set while defining custom encodings that are +particular to a schema in another set. + +Example of XML include usage to import common encoding types + +```xml + + +``` + +### Simple encodings + +A simple encoding is backed by either a scalar type or an array of +scalars, such as a character array. One or more simple encodings may be +defined, each specified by a `` element. + +The `` XML element is also used for a scalar or array member of a composite encoding; see below. + +#### `` element content + +If the element has a value, it is used to indicate a special value of +the encoding. + +##### Constant value + +The element value represents a constant if attribute +`presence="constant"`. In this case, the value is required. + +#### `` attributes + + +| `` attribute | Description | XML type | Usage | Valid values | +|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|-----------------------------------|----------------------------------------------------------------------------------------| +| name | Name of encoding | symbolicName\_t | required | Must be unique among all encoding types in a schema. | +| description | Documentation of the type | string | optional | | +| presence | Presence of this element within a composite type | token | | required optional constant | +| length | Number of elements of the primitive data type | nonnegativeInteger | default = 1 | Value “0” represents variable length. | +| offset | If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | See section [*Element offset within a composite type*](#element-offset-within-a-composite-type) below | +| primitiveType | The primitive data type that backs the encoding | token | required | char int8 int16 int32 int64 uint8 uint16 uint32 uint64 float double | +| sinceVersion | Documents the version of a schema in which a type was added. Not valid on a member of a composite type. | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. | +| deprecated | Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. Not valid on a member of a composite type. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | + + +Simple type examples + +```xml + + +``` + +### Composite encodings + +Composite encoding types are composed of two or more simple types. + +#### `` attributes + +| `` attribute | Description | XML type | Usage | Valid values | +|--------------------|----------------------------------------------------------------------------------------------------------------|--------------------|-------------|------------------------------------------------------------------| +| name | Name of encoding | symbolicName\_t | required | Must be unique among all encoding types. | +| offset | The offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | | +| description | Documentation of the type | string | optional | | +| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. | +| deprecated | Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | + +#### Composite type elements + +A `` composite encoding element may be composed of any +combination of types, including `` simple encoding, `` +enumeration, `` bitset, and nested composite type. The elements +that compose a composite type carry the same XML attributes as +stand-alone types. + +Composite type example + +In this example, a Price is encoded as 32 bit integer mantissa and a +constant exponent, which is not sent on the wire. + +```xml + + + -4 + +``` + +#### Element offset within a composite type + +If a message designer wishes to control byte boundary alignment or map +to an existing data structure, element offset may optionally be +specified on a simple type, enum or bitset within a composite type. Offset is the number +of octets from the start of the composite; it is a zero-based index. + +If specified, offset must be greater than or equal to the sum of the +sizes of prior elements. In other words, an offset is invalid if it +would cause elements to overlap. + +#### Null value of a composite type + +For a composite type, nullness is indicated by the value of its first +element. For example, if a price field is optional, a null value in its +mantissa element indicates that the price is null. + +### Reference to reusable types + +A composite type often has its elements defined in-line within the `` XML element as shown in the example above. Alternatively, a common type may be defined once on its own, and then referred to by name with the composite type using a `` element. + +#### `` attributes + +| `` attribute | Description | XML type | Usage | Valid values | +|--------------------|----------------------------------------------------------------------------------------------------------------|--------------------|-------------|------------------------------------------------------------------| +| name | Usage of the type in this composite | symbolicName\_t | required | | +| type | Name of referenced encoding | symbolicName\_t | required | Must match a defined type, enum or set or composite name attribute. | +| description | Documentation of how the referenced type is used | string | optional | | +| offset | The offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | | + + +#### Type reference examples + +**Reference to an enum** + +In this example, a futuresPrice is encoded as 64 bit integer mantissa, 8 bit exponent, and a reused enum type. + +```xml + + 0 + 1 + + + + + + + +``` + +**Reference to a composite type** + +In this example, a nested composite is formed by using a reference to another composite type. It supports the expresson of a monetary amount with its currency, such as USD150.45. Note that a reference may carry an offset within the composite encoding that contains it. + +```xml + + + + + + + + + +``` + +### Enumeration encodings + +An enumeration explicitly lists the valid values of a data domain. Any +number of fields may share the same enumeration. + +#### `` element + +Each enumeration is represented by an `` element. It contains any +number of `` elements. + +The `encodingType` attribute refers to a simple encoding of scalar type. +The encoding of an enumeration may be char or any unsigned integer type. + +| `` attribute | Description | XML type | Usage | Valid values | +|--------------------|----------------------------------------------------------------------------------------------------------------|--------------------|-------------|-----------------------------------------------------------------------------------| +| name | Name of encoding | symbolicName\_t | required | Must be unique among all encoding types. | +| description | Documentation of the type | string | optional | | +| encodingType | Name of a simple encoding type | symbolicName\_t | required | Must match the name attribute of a scalar `` element *or* a primitive type: char uint8 uint16 uint32 uint64 | +| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. | +| deprecated | Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | +| offset | If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | + +#### `` element attributes + +The name attribute of the `` uniquely identifies it. + +| `` attribute | Description | XML type | Usage | Valid values | +|--------------------|-----------------------------------------------------------------------------------------------------------------|--------------------|-------------|------------------------------------------------------------------| +| name | Symbolic name of value | symbolicName\_t | required | Must be unique among valid values in the enumeration. | +| description | Documentation of the value | string | optional | | +| sinceVersion | Documents the version of a schema in which a value was added | nonNegativeInteger | default = 0 | | +| deprecated | Documents the version of a schema in which a value was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | + +#### `` element content + +The element is required to carry a value, which is the valid value as a +string. The string value in XML must be convertible to the data type of +the encoding, such as an integer. + +`` and `` elements + +Enumeration example (not all valid values listed) + +This enumeration is encoded as an 8 bit unsigned integer value. Others +are encoded as char codes. + +```xml + + + + 1 + 2 + 3 + 4 + +``` + +### Multi-value choice encodings (bitset) + +An enumeration explicitly lists the valid values of a data domain. Any +number of fields may share the same set of choices. + +#### `` element + +Each multi-value choice is represented by a `` element. It may +contain a number of `` elements up to the number of bits in the +primitive encoding type. The largest number possible is 64 choices in a +uint64 encoding. + +The `encodingType` attribute refers to a simple encoding of scalar type. +The encoding of a bitset should be an unsigned integer type. + +| `` attribute | Description | XML type | Usage | Valid values | +|-------------------|----------------------------------------------------------------------------------------------------------------|--------------------|-------------|-----------------------------------------------------------------------------------| +| name | Name of encoding | symbolicName\_t | required | Must be unique among all encoding types. | +| description | Documentation of the type | string | optional | | +| encodingType | Name of a simple encoding type | string | required | Must match the name attribute of a scalar `` element *or* a primitive type: uint8 uint16 uint32 uint64 | +| sinceVersion | Documents the version of a schema in which a type was added | nonnegativeInteger | default = 0 | Must be less than or equal to the version of the message schema. | +| deprecated | Documents the version of a schema in which a type was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. +| offset | If a member of a composite type, tells the offset from the beginning of the composite. By default, the offset is the sum of preceding element sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | + +#### `` element attributes + +The `name` attribute of the `` uniquely identifies it. + +| `` attribute | Description | XML type | Usage | Valid values | +|----------------------|------------------------------------------------------------------------------------------------------------------|--------------------|-------------|------------------------------------------------------------------| +| name | Symbolic name of value | symbolicName\_t | required | Must be unique among choices in the set. | +| description | Documentation of the value | string | optional | | +| sinceVersion | Documents the version of a schema in which a choice was added | nonNegativeInteger | default = 0 | | +| deprecated | Documents the version of a schema in which a choice was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | + +#### `< choice >` element content + +The element is required to carry a value, which is an unsigned integer +representing a zero-based index to a bit within a bitset. Zero is the +least significant bit. + +`` and `` XML elements + +Multi-value choice example, The choice is encoded as a bitset. + +```xml + + + + 0 + 1 + 2 + +``` + +## Message templates + +A `` element contains a set of message templates. A message schema may have multiple +instances of ``, if desired, to organize them by categories. Each `` element may have an associated `package` name. + +**`` element attribute** + +| Schema attribute | Description | XML type | Usage | Valid values | +|------------------|--------------------------------------------------------------------------------------------------|--------------------|------------------------|------------------------------------------------------------------------------| +| package | Overrides package of messageSchema | string | optional | Should be unique between counterparties but no naming convention is imposed. | + +The `` element has attribute `xml:base` to support inclusion from a separate XML file using the XInclude mechanism. +Thus, common message templates may be shared across multiple SBE message schemas. + +To define a message type, add a `` element to ``. + +The `name` and `id` attributes of `` are required. The first is a display name for +a message, while the latter is a unique numeric identifier, commonly +called template ID. + +### Byte alignment + +By default, a message starts at the first available byte of buffer. However, if desired, it may be aligned to a boundary by specifying the `alignment` attribute to improve performance on certain platforms. If specified, the start of the message should reside in the buffer at the next multiple of the alignment attribute. For example, if `alignment=4` then the message should start at the next address that is a multiple of 4. + +### Reserved space + +By default, message size is the sum of its field lengths. However, a +larger size may be reserved by setting blockLength, either to allow for +future growth or for desired byte alignment. If so, the extra reserved +space should be filled with zeros by message encoders. + +### Message members + +A `` element contains its field definitions in three +categories, which must appear in this sequence: + +1. Element `` defines a fixed-length field + +2. Element `` defines a repeating group + +3. Element `` defines a variable-length field, such as raw data + +The number of members of each type is unbound. + +### Member order + +The order that fields are listed in the message schema governs the order +that they are encoded on the wire. + +### `` element attributes + +| `` attribute | Description | XML type | Usage | Valid values | +|-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------|--------------------|-------------|--------------------------------------------------------------------------| +| name | Name of a message | symbolicName\_t | required | Must be unique among all messages in a schema | +| id | Unique message template identifier | unsignedInt | required | Must be unique within a schema | +| description | Documentation | string | optional | | +| blockLength | Reserved size in number of octets for root level of message body | unsignedInt | optional | If specified, must be greater than or equal to the sum of field lengths. | +| semanticType | Documents value of FIX MsgType for a message | token | optional | Listed in FIX specifications | +| sinceVersion | Documents the version of a schema in which a message was added | nonNegativeInteger | default = 0 | | +| deprecated | Documents the version of a schema in which a message was deprecated. It should no longer be sent but is documented for back-compatibility. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | +| alignment | Controls byte alignment of the start of a message in its buffer| positiveInteger | optional | | + +Note that there need not be a one-to-one relationship between message +template (identified by `id` attribute) and `semanticType` attribute. You +might design multiple templates for the same FIX MsgType to optimize +different scenarios. + +Example `` element + +```xml + +``` + +Field attributes +-------------------------------------------------------------------------------------------------------------- + +Fields are added to a `` element as child elements. See section [*Field Encoding*](#field-encoding) above for a listing of all field types. + +These are the common attributes of all field types. + + +| Schema attribute | Description | XML type | Usage | Valid values | +|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------|------------------------------------|-------------------------------------------------------------------------------------------------------| +| name | Name of a field | symbolicName\_t | required | Name and id must uniquely identify a field type within a message schema. | +| id | Unique field identifier (FIX tag) | unsignedShort | required | | +| description | Documentation | string | optional | | +| type | Encoding type name, one of simple type, composite type or enumeration. | string | required | Must match the name attribute of a simple ``, `` encoding type, `` or ``. | +| offset | Offset to the start of the field within a message or repeating group entry. By default, the offset is the sum of preceding field sizes, but it may be increased to effect byte alignment. | unsignedInt | optional | Must be greater than or equal to the sum of preceding field sizes. Mutually exclusive with alignment | +| alignment | Controls byte alignment of the start of a field in its buffer| positiveInteger | optional | Mutually exclusive with offset | +| presence | Field presence | enumeration | Default = required | required = field value is required; not tested for null. optional = field value may be null. constant = constant value not sent on wire. | +| valueRef | Constant value of a field as a valid value of an enumeration | qualifiedName\_t | optional Valid only if presence= ”constant” | If provided, the qualified name must match the name attribute of a `` within an `` | +| sinceVersion | The version of a message schema in which this field was added. | InonnegativeInteger | default=0 | Must not be greater than version attribute of `` element. | +| deprecated | Documents the version of a schema in which a field was deprecated. It should no longer be used in new messages. | nonnegativeInteger | optional | Must be less than or equal to the version of the message schema. | + + +Example field schemas + +Field that uses a composite encoding + +```xml + + + 0\ + + + +``` + +## Repeating group schema + +A `` has the same attributes as a `` element since they +both inherit attributes from the blockType XML type. A group has the +same child members as a message, and they must appear in the same order: + +1. Element `` defines a fixed-length field + +2. Element `` defines a repeating group. Groups may be nested to + any level. + +3. Element `` defines a variable-length field, such as raw data + +The number of members of each type is unbound. + + +| `` attribute | Description | XML type | Usage | Valid values | +|---------------------|-----------------------------------|-----------------|-----------------------------|--------------------------------------------------------------------------| +| name | Name of a group | symbolicName\_t | required | Name and id must uniquely identify a group type within a message schema. | +| id | Unique group identifier | unsignedShort | required | | +| description | Documentation | string | optional | | +| dimensionType | Dimensions of the repeating group | symbolicName\_t | default = groupSizeEncoding | If specified, must be greater than or equal to the sum of field lengths. | +| alignment | Controls byte alignment of the start of each group instance in its buffer| positiveInteger | optional | | +`` element inherits attributes of blockType. See `` +above. + +*Example group schema with default dimension encoding* + +```xml + + + + + + + + + + + +``` + +## Schema validation + +The first level of schema validation is enforced by XML schema +validation tools to make sure that a schema is well-formed according to +XSD schema rules. Well-formed XML is necessary but insufficient to prove +that a schema is correct according to FIX Simple Binary Encoding rules. + +Additional conditions that render a schema invalid include the +following. + +| Error condition | Error description | +|----------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Missing field encoding | A field or `` references a type name that is undefined. | +| Missing message header encoding | Missing encoding type for headerType specified in ``. Default name is “messageHeader”. | +| Duplicate encoding name | An encoding name is non-unique, rendering a reference ambiguous. | +| nullValue specified for non-null encoding | Attribute nullValue is inconsistent with presence=required or constant | +| Attributes nullValue, minValue or maxValue of wrong data range | The specified values must be convertible to a scalar value consistent with the encoding. For example, if the primitive type is uint8, then the value must be in the range 0 through 255. | +| semanticType mismatch | If the attribute is specified on both a field and the encoding that it references, the values must be identical. | +| presence mismatch | If the attribute is specified on both a field and the encoding that it references, the values must be identical. | +| Missing constant value | If presence=constant is specified for a field or encoding, the element value must contain the constant value. | +| Missing validValue content | A `` element is required to carry its value. | +| Incompatible offset and blockLength | A field offset greater than message or group blockLength is invalid | +| Duplicate ID or name of field or group | Attributes id and name must uniquely identify a type within a message schema. This applies to fields and groups. To be clear, the same field or group ID may be used in multiple messages, but each instance must represent the same type. Each of those instances must match on both id and name attributes. | + +### Message with a repeating group + +```xml + + + + + + + + + + + +``` + +### Message with raw data fields + +```xml + + + + + + + + + + + + + + +``` + +## Reserved element names + +### Composite types + +| Encoding type name (default names) | +|------------------------------------| +| messageHeader | +| groupSizeEncoding | + +### Composite type elements + +| Type name | Composite type | +|----------------|-----------------------------| +| blockLength | messageHeader and groupSize | +| day | MonthYear | +| exponent | decimal | +| length | variable-length data | +| mantissa | decimal | +| month | MonthYear | +| numInGroup | groupSize | +| templateId | messageHeader | +| time | timestamp, TZ time | +| timezoneHour | TZ time | +| timezoneMinute | TZ time | +| unit | timestamp, TZ time | +| varData | variable-length data | +| version | messageHeader | +| week | MonthYear | +| year | MonthYear | diff --git a/v2-0-RC3/doc/05SchemaExtensionMechanism.md b/v2-0-RC3/doc/05SchemaExtensionMechanism.md new file mode 100644 index 0000000..775f27b --- /dev/null +++ b/v2-0-RC3/doc/05SchemaExtensionMechanism.md @@ -0,0 +1,189 @@ +# Schema Extension Mechanism + +## Objective + +It is not always practical to update all message publishers and +consumers simultaneously. Within certain constraints, messages +and repeating groups can be extended in a controlled way. Consumers using an +older version of a schema should be compatible if interpretation of +added fields or messages is not required for business processing. + +Message templates and repeating groups may be extended with new fields. However, the extension mechanism does not support extension of composite types that back existing fields. + +This specification only details compatibility at the presentation layer. It does not relieve application developers of any responsibility for carefully planning a migration strategy and for handling exceptions at the application layer. + +### Constraints + +Compatibility is only ensured under these conditions: + +- Fields may be added to either the root of a message or to a + repeating group, but in each case, they must be appended to end of a + block. + +- Existing fields cannot change data type or move within a message. + +- Message and repeating group byte alignment may not change. + +- A repeating group may be added after existing groups at the root level or nested within another repeating group. + +- A variable-length data field may be added after existing variable-length data at the root level or within a repeating group. + +- Message header encoding cannot change. + +- In general, metadata changes such as name or description corrections do not break compatibility so long as +wire format does not change. + +Changes that break those constraints require consumers to update to the +current schema used by publishers. An message template that has changed in an incompatible way must be assinged a new template "id" attribute. + +## Message schema features for extension + +### Schema version + +The `` root element contains a version number attribute. +By default, version is zero, the initial version of a message schema. +Each time a message schema is changed, the version number is +incremented. + +Version applies to the schema as a whole, not to individual elements. +Version is sent in the message header so the consumer can determine +which version of the message schema was used to encode the message. + +See section [*`` attributes*](#messageschema-attributes) above for schema attributes. + +### Since version + +When a new field, enumeration value, group or message is added to a message schema, the +extension may be documented by adding a sinceVersion attribute to the +element. The sinceVersion attribute tells in which schema version the +element was added. This attribute remains the same for that element for +the lifetime of the schema. This attribute is for documentation purposes +only, it is not sent on the wire. + +Over time, multiple extensions may be added to a message schema. New +fields must be appended following earlier extensions. By documenting +when each element was added, it possible to verify that extensions were +appended in proper order. + +### Block length + +The length of the root level of the message may optionally be documented +on a `` element in the schema using the blockLength attribute. +See section [*`` element attributes*](#message-element-attributes) above for message attributes. If not set in the +schema, block length of the message root is the sum of its field +lengths. Whether it is set in the schema or not, the block length is +sent on the wire to consumers. + +Likewise, a repeating group has a blockLength attribute to tell how much +space is reserved for group entries, and the value is sent on the wire. +It is encoded in the schema as part of the NumInGroup field encoding. +See section [*Encoding of repeating group dimensions*](#encoding-of-repeating-group-dimensions) above. + +### Deprecated elements + +A message schema may document obsolete elements, such as messages, +fields, and valid values of enumerations with deprecated attribute. +Updated applications should not publish deprecated messages or values, +but declarations may remain in the message schema during a staged +migration to replacement message layouts. + +## Wire format features for extension + +### Block size + +The length of the root level of the message is sent on the wire in the +SBE message header. See section [*Root block length*](#root-block-length) above. Therefore, if new fields +were appended in a later version of the schema, the consumer would still +know how many octets to consume to find the next message element, such +as repeating group or variable-length Data field. Without the current +schema version, the consumer cannot interpret the new fields, but it +does not break parsing of earlier fields. + +Likewise, block size of a repeating group is conveyed in the NumInGroup +encoding. + +### Number of repeating groups and variable data + +Message headers and repeating group dimensions carry a count of the number of repeating groups and a count of variable-length data fields on the wire. This supports a walk by a decoder of all the elements of a message, even when the decoder was built with an older version of a schema. As for added fixed-length fields, new repeating groups cannot be interpreted by the decoder, but it still can process the ones it knows, and it can correctly reach the end of a message. + +## Compatibility strategy + +*This suggested strategy is non-normative.* + +A message decoder compares the schema version in a received message header to the version that the decoder was built with. + +If the *received version is equal to the decoder's version*, then all fields known to the decoder may be parsed, and no further analysis is required. + +If the *received version is greater than the decoder's version* (that is, the producer's encoder is newer than the consumer's decoder), then all fields known to the decoder may be parsed but it will be unable to parse added fields. + +Also, an old decoder may encounter unexpected enumeration values. The application layer determines whether an unexpected value is a fatal error. Probably so for a required field since the business meaning is unknown, but it may choose to allow an unknown value of an optional field to pass through. For example, if OrdType value J="Market If Touched" is added to a schema, and the consumer does not recognize it, then the application returns an order rejection with reason "order type not supported", even if it does not know what "J" represents. Note that this is not strictly a versioning problem, however. This exception handling is indistinguishable from the case where "J" was never added to the enum but was simply sent in error. + +If the *received version is less than the decoder's version* (that is, the producer's encoder is older than the consumer's decoder), then only the fields of the older version may be parsed. This information is available through metadata as "sinceVersion" attribute of a field. If sinceVersion is greater than received schema version, then the field is not available. How a decoder signals an application that a field is unavailable is an implementation detail. One strategy is for an application to provide a default value for unavailable fields. + +## Message schema extension example + +Initial version of a message schema + +```xml + + + + + + + + + + +``` + +Second version - a new message is added + +```xml + + + + + + + + + + + + + + + + +``` + +Third version - a field is added + +```xml + + + + + + + + + + + + + + + + + +``` diff --git a/v2-0-RC3/doc/06UsageGuidelines.md b/v2-0-RC3/doc/06UsageGuidelines.md new file mode 100644 index 0000000..055844a --- /dev/null +++ b/v2-0-RC3/doc/06UsageGuidelines.md @@ -0,0 +1,28 @@ +# Usage Guidelines + +## Identifier encodings + +FIX specifies request and entity identifiers as String type. Common +practice is to specify an identifier field as fixed-length character of +a certain size. + +Optionally, a message schema may restrict such identifiers to numeric +encodings. + +Example of an identifier field with character encoding + +```xml + + + + ``` + +Example of an identifier field with numeric encoding + +```xml + + + +``` diff --git a/v2-0-RC3/doc/07Examples.md b/v2-0-RC3/doc/07Examples.md new file mode 100644 index 0000000..12a72eb --- /dev/null +++ b/v2-0-RC3/doc/07Examples.md @@ -0,0 +1,293 @@ +# Examples + +The example messages are preceded by Simple Open Framing Header. Note +that SOFH encoding is always big-endian, regardless of the byte order of +the SBE message body. See that FIX standard for details. + +Not all FIX enumeration values are listed in the samples. + +## SBE Message Schema +```xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -3 + + + + 0 + + + + + + + 0 + 3 + 6 + 9 + + + 0 + 1 + 2 + 4 + 6 + + + 0 + 3 + 4 + 5 + 6 + 8 + A + F + + + 0 + 1 + 2 + 3 + 4 + 6 + 8 + A + E + + + 1 + 2 + 3 + 4 + + + 1 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## Flat, fixed-length message + +This is an example of a simple, flat order message without repeating +groups or variable-length data. + +**Notes on the message schema** + +In this case, there is a lot of verbiage for one message, but in +practice, a schema would define a set of messages. The same encodings +within the `` element would be used for a whole collection of +messages. For example, a price encoding need only be defined once but +can be used in any number of messages in a schema. Many of the +attributes, such as description, offset, and semanticType, are optional +but are shown here for a full illustration. + +All character fields in the message are fixed-length. Values may be +shorter than the specified field length, but not longer. Since all +fields are fixed-length, they are always in a fixed position, supporting +direct access to data. + +An enumeration gives the valid values of a field. Both enumerations in +the example use character encoding, but note that some enumerations in +FIX are of integer type. + +There are two decimal encodings. The one used for quantity sets the +exponent to constant zero. In effect there is no fractional part and +only the mantissa is sent on the wire, acting as an integer. However, +FIX defines Qty as a float type since certain asset classes may use +fractional shares. + +The other decimal encoding is used for prices. The exponent is +constant -3. In essence, each price is transmitted as an integer on the +wire with assumed three decimal places. Each of the prices in the +message is conditionally required. If OrdType=Limit, then Price field +required. If OrdType=Stop then StopPx is required. Otherwise, if +OrdType=Market, then neither price is required. Therefore, the price +takes an optional encoding. To indicate that it is null, a special value +is sent on the wire. See the table in section [*Range attributes for integer fields*](#range-attributes-for-integer-fields) above for the null +value of the int64 mantissa. + +In this example, all fields are packed without special byte alignment. +Performance testing may prove better results with a different +arrangement of the fields or adjustments to field offsets. However, +those sorts of optimizations are platform dependent. + +### Wire format of an order message + +Hexadecimal and ASCII representations (little-endian byte order): +``` +00 00 00 48 eb 50 36 00 63 00 5b 00 00 00 00 00 : H P6 c [ +00 00 4f 52 44 30 30 30 30 31 41 43 43 54 30 31 : ORD00001ACCT01 +00 00 47 45 4d 34 00 00 00 00 31 c0 1a 31 96 2a : GEM4 1 1 * +5e b0 15 07 00 00 00 32 1a 85 01 00 00 00 00 00 :^ 2 +00 00 00 00 00 00 00 80 : +``` +### Interpretation +|Wire format|Field ID|Name|Offset|Length|Interpreted value| +|-----------|-------:|----|-----:|-----:|-----------------| +| `00000048` | | SOFH message length | 0 | 4 | 72 | +| `eb50` | | SOFH encoding | 4 | 2 | SBE little-endian | +| `3600` | | SBE root block length | 0 | 2 | 54 | +| `6300` | | SBE template ID | 2 | 2 | 99 | +| `5b00` | | SBE schema ID | 4 | 2 | 91 | +| `0000` | | SBE schema version | 6 | 2 | 0 | +| `0000` | | No. of groups | 8 | 2 | 0 | +| `0000` | | No. of var data | 10 | 2 | 0 | +| `4f52443030303031` | 11 | ClOrdId | 0 | 8 | ORD00001 | +| `4143435430310000` | 1 | Account | 8 | 8 | ACCT01 | +| `47454d3400000000` | 55 | Symbol | 16 | 8 | GEM4 | +| `31` | 54 | Side | 24 | 1 | Buy | +| `c01a31962a5eb015` | 60 | TransactTime | 25 | 8 | 2019-07-11T13:43:27.699Z | +| `07000000` | 38 | OrderQty | 33 | 4 | 7 | +| `32` | 40 | OrdType | 37 | 1 | Limit | +| `1a85010000000000` | 44 | Price | 38 | 8 | 99.610 | +| `0000000000000080` | 99 | StopPx | 46 | 8 | null | + +## Message with a repeating group + +This is an example of a message with a repeating group. + +**Notes on the message schema** + +The message contains a MonthYear field. It is encoded as a composite +type with year, month, day and week subfields. + +This message layout contains a repeating group containing a collection +of partial fills for an execution report. The `` XML tag enclosed +the fields within a group entry. The dimensions of the repeating group +are encoding as a composite type called groupSizeEncoding. + +### Wire format of an execution message + +Hexadecimal and ASCII representations (little-endian byte order): +``` +00 00 00 5c eb 50 2a 00 62 00 5b 00 00 00 01 00 : \ P* b [ +00 00 4f 30 30 30 30 30 30 31 45 58 45 43 30 30 : O0000001EXEC00 +30 30 46 31 47 45 4d 34 00 00 00 00 de 07 06 ff :00F1GEM4 +ff 31 01 00 00 00 06 00 00 00 75 3e 0c 00 02 00 : 1 u> +00 00 00 00 1a 85 01 00 00 00 00 00 02 00 00 00 : +24 85 01 00 00 00 00 00 04 00 00 00 :$ +``` +### Interpretation +Offset is from beginning of block. + +|Wire format|Field ID|Name|Offset|Length|Interpreted value| +|-----------|-------:|----|-----:|-----:|-----------------| +| `0000005c` | | SOFH message length | 0 | 4 | 92 | +| `eb50` | | SOFH encoding | 4 | 2 | SBE little-endian | +| `2a00` | | SBE root block length | 0 | 2 | 42 | +| `6200` | | SBE template ID | 2 | 2 | 98 | +| `5b00` | | SBE schema ID | 4 | 2 | 91 | +| `0000` | | SBE schema version | 6 | 2 | 0 | +| `0100` | | No. of groups | 8 | 2 | 1 | +| `0000` | | No. of var data | 10 | 2 | 0 | +| `4f30303030303031` | 37 | OrderID | 8 | 8 | O0000001 | +| `4558454330303030` | 17 | ExecID | 8 | 8 | EXEC0000 | +| `31` | 39 | OrdStatus | 1 | 1 | PartiallyFilled | +| `47454d3400000000` | 55 | Symbol | 18 | 8 | GEM4 | +| `de0706ffff` | 200 | MaturityMonthYear | 26 | 5 | year=2014 month=6 | +| `31` | 54 | Side | 1 | 1 | Buy | +| `01000000` | 151 | LeavesQty | 32 | 4 | 1 | +| `06000000` | 14 | CumQty | 36 | 4 | 6 | +| `753e` | 75 | TradeDate | 40 | 2 | 2013-10-11 | +| `0c00` | | Group block length | 0 | 2 | 12 | +| `0200` | | NumInGroup | 4 | 2 | 2 | +| `0000` | | No. of groups | 4 | 2 | 0 | +| `0000` | | No. of var data | 6 | 2 | 0 | +| `1a85010000000000` | 1364 | FillPx | 0 | 8 | 99.610 | +| `02000000` | 1365 | FillQty | 8 | 4 | 2 | +| `2485010000000000` | 1364 | FillPx | 0 | 8 | 99.620 | +| `04000000` | 1365 | FillQty | 8 | 4 | 4 | + +## Message with a variable-length field + +### Wire format of a business reject message + +``` +00 00 00 44 eb 50 09 00 61 00 5b 00 00 00 00 00 : D P a [ +01 00 4f 52 44 30 30 30 30 31 06 27 00 4e 6f 74 : ORD00001 ' Not +20 61 75 74 68 6f 72 69 7a 65 64 20 74 6f 20 74 : authorized to t +72 61 64 65 20 74 68 61 74 20 69 6e 73 74 72 75 :rade that instru +6d 65 6e 74 :ment +``` +### Interpretation +|Wire format|Field ID|Name|Offset|Length|Interpreted value| +|-----------|-------:|----|-----:|-----:|-----------------| +| `00000044` | | SOFH message length | 0 | 4 | 68 | +| `eb50` | | SOFH encoding | 4 | 2 | SBE little-endian | +| `0900` | | SBE root block length | 0 | 2 | 9 | +| `6100` | | SBE template ID | 2 | 2 | 97 | +| `5b00` | | SBE schema ID | 4 | 2 | 91 | +| `0000` | | SBE schema version | 6 | 2 | 0 | +| `0000` | | No. of groups | 8 | 2 | 0 | +| `0100` | | No. of var data | 10 | 2 | 1 | +| `4f52443030303031` | 379 | BusinessRejectRefID | 0 | 8 | ORD00001 | +| `06` | 380 | BusinessRejectReason | 8 | 1 | NotAuthorized | +| `4e6f74206175...` | 58 | Text | 0 | 39 | Not authorized to trade that instrument | diff --git a/v2-0-RC3/doc/08ReleaseNotes.md b/v2-0-RC3/doc/08ReleaseNotes.md new file mode 100644 index 0000000..6ee787d --- /dev/null +++ b/v2-0-RC3/doc/08ReleaseNotes.md @@ -0,0 +1,46 @@ +# Release Notes + +These are the changes made since SBE version 1.0. + + See [issues](https://github.com/FIXTradingCommunity/fix-simple-binary-encoding/issues) and [pull requests](https://github.com/FIXTradingCommunity/fix-simple-binary-encoding/pulls) in GitHub for details and changes. + +## SBE version 2.0 Release Candidate 2 + +These issues were resolved and accepted for version 2.0 Release Candidate 2. + +| Issue | Description | +|------:|----------------------------------------------------------------| +| 94 | XInclude does not work because of missing xml:base attribute allowance | +| 95 | Single-byte character set | +| 96 | Package override on type | +| 99 | Revert to XML Schema version 1.0 | +| 101 | update examples section for v2.0RC2 | +| 106 | Version number in SBE.XSD file name | + +## SBE version 2.0 Release Candidate 1 + +These issues were resolved and accepted for version 2.0 Release Candidate 1. + +| Issue | Description | +|------:|----------------------------------------------------------------| +| 26 | Adding new variable length field in a repeating group | +| 31 | Presence attribute belongs to a field | +| 35 | Field attributes | +| 36 | Document cross-references | +| 37 | Extend message with repeating groups and vardata | +| 39 | sinceVersion on nested types within a composite | +| 40 | Clarification on constant char encodings | +| 44 | Remove deprecated attributes | +| 45 | Update examples for changed headers | +| 48 | Member names for data encoding type | +| 51 | Semantic type with Decimal encoding | +| 59 | refType is missing semanticAttributes | +| 62 | Decimal representation for optional mantissa with non-constant exponent | +| 64 | Support for easy constant value setting in fields | +| 65 | Alignment of var data and repeating groups | +| 87 | update examples for version 2.0 | + + +### Compatibility + +Version 2.0 is not back-compatible with SBE version 1.0, either in wire format or XML schema. diff --git a/v2-0-RC3/doc/FIXDisclaimerTechStd.md b/v2-0-RC3/doc/FIXDisclaimerTechStd.md new file mode 100644 index 0000000..8645413 --- /dev/null +++ b/v2-0-RC3/doc/FIXDisclaimerTechStd.md @@ -0,0 +1,27 @@ +::: {custom-style=Disclaimer} +DISCLAIMER +::: + +THE INFORMATION CONTAINED HEREIN AND THE FINANCIAL INFORMATION EXCHANGE PROTOCOL (COLLECTIVELY, THE "FIX PROTOCOL") ARE PROVIDED "AS IS" AND NO PERSON OR ENTITY ASSOCIATED WITH THE FIX PROTOCOL MAKES ANY REPRESENTATION OR WARRANTY, EXPRESS OR IMPLIED, AS TO THE FIX PROTOCOL (OR THE RESULTS TO BE OBTAINED BY THE USE THEREOF) OR ANY OTHER MATTER AND EACH SUCH PERSON AND ENTITY SPECIFICALLY DISCLAIMS ANY WARRANTY OF ORIGINALITY, ACCURACY, COMPLETENESS, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SUCH PERSONS AND ENTITIES DO NOT WARRANT THAT THE FIX PROTOCOL WILL CONFORM TO ANY DESCRIPTION THEREOF OR BE FREE OF ERRORS. THE ENTIRE RISK OF ANY USE OF THE FIX PROTOCOL IS ASSUMED BY THE USER. + +NO PERSON OR ENTITY ASSOCIATED WITH THE FIX PROTOCOL SHALL HAVE ANY LIABILITY FOR DAMAGES OF ANY KIND ARISING IN ANY MANNER OUT OF OR IN CONNECTION WITH ANY USER'S USE OF (OR ANY INABILITY TO USE) THE FIX PROTOCOL, WHETHER DIRECT, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL (INCLUDING, WITHOUT LIMITATION, LOSS OF DATA, LOSS OF USE, CLAIMS OF THIRD PARTIES OR LOST PROFITS OR REVENUES OR OTHER ECONOMIC LOSS), WHETHER IN TORT (INCLUDING NEGLIGENCE AND STRICT LIABILITY), CONTRACT OR OTHERWISE, WHETHER OR NOT ANY SUCH PERSON OR ENTITY HAS BEEN ADVISED OF, OR OTHERWISE MIGHT HAVE ANTICIPATED THE POSSIBILITY OF, SUCH DAMAGES. + +**DRAFT OR NOT RATIFIED PROPOSALS** (REFER TO PROPOSAL STATUS AND/OR SUBMISSION STATUS ON COVER PAGE) ARE PROVIDED "AS IS" TO INTERESTED +PARTIES FOR DISCUSSION ONLY. PARTIES THAT CHOOSE TO IMPLEMENT THIS DRAFT PROPOSAL DO SO AT THEIR OWN RISK. IT IS A DRAFT DOCUMENT AND MAY BE +UPDATED, REPLACED, OR MADE OBSOLETE BY OTHER DOCUMENTS AT ANY TIME. THE FIX GLOBAL TECHNICAL COMMITTEE WILL NOT ALLOW EARLY IMPLEMENTATION TO +CONSTRAIN ITS ABILITY TO MAKE CHANGES TO THIS SPECIFICATION PRIOR TO FINAL RELEASE. IT IS INAPPROPRIATE TO USE FIX WORKING DRAFTS AS +REFERENCE MATERIAL OR TO CITE THEM AS OTHER THAN “WORKS IN PROGRESS”. THE FIX GLOBAL TECHNICAL COMMITTEE WILL ISSUE, UPON COMPLETION OF REVIEW +AND RATIFICATION, AN OFFICIAL STATUS ("APPROVED") OF/FOR THE PROPOSAL AND A RELEASE NUMBER. + +No proprietary or ownership interest of any kind is granted with respect to the FIX Protocol (or any rights therein), except as expressly set out in FIX Protocol Limited's Copyright and Acceptable Use Policy. + +© Copyright 2015-2020 FIX Protocol Limited, all rights reserved + +\ + + + +FIX Technical Standard Specifications by [FIX Protocol Ltd.](https://www.fixtradingcommunity.org/) are licensed under a [Creative Commons Attribution-NoDerivatives 4.0 International License](http://creativecommons.org/licenses/by-nd/4.0/). Based on a work at [https://github.com/FIXTradingCommunity/](https://github.com/FIXTradingCommunity/). + + +1. diff --git a/v2-0-RC3/doc/FIX_TechStd_Style_MASTER.docx b/v2-0-RC3/doc/FIX_TechStd_Style_MASTER.docx new file mode 100644 index 0000000..06daa53 Binary files /dev/null and b/v2-0-RC3/doc/FIX_TechStd_Style_MASTER.docx differ diff --git a/v2-0-RC3/doc/SBE.sh b/v2-0-RC3/doc/SBE.sh new file mode 100755 index 0000000..bac68c5 --- /dev/null +++ b/v2-0-RC3/doc/SBE.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +echo Compilation started... +# Script is expected to start running in the folder where it is located (together with the source files) +SOURCE="$PWD" +# There is only one disclaimer and style docx file for all FIX Technical Standards and it is stored with the FIX Session Layer +# Repository has local copies with the specific names and dates of the standard +DISCLAIMER="FIXDisclaimerTechStd.md" +STYLE="FIX_TechStd_Style_MASTER.docx" +TARGET="$SOURCE/target" +YAML="$SOURCE/SBE.yaml" +FILES="01Introduction.md 02FieldEncoding.md 03MessageStructure.md 04MessageSchema.md 05SchemaExtensionMechanism.md 06UsageGuidelines.md 07Examples.md" +WPFOLDER="/wp-content/uploads/2020/03/" + +# Create document version with disclaimer +pandoc "$DISCLAIMER" $FILES -o "$TARGET/docx/Simple-Binary-Encoding-v2-RC3.docx" --reference-doc="$STYLE" --metadata-file="$YAML" --toc --toc-depth=4 +echo SBE document version created + +# Create base online version without disclaimer +pandoc $FILES -o "$TARGET/debug/SBEONLINE.html" -s --metadata-file="$YAML" --toc --toc-depth=2 + +# Create separate online versions for production and test website by including appropriate link prefixes +sed 's,img src="media/,img src="https://www.fixtrading.org'$WPFOLDER',g' "$TARGET/debug/SBEONLINE.html" > "$TARGET/html/SBEONLINE_PROD.html" +sed s/www.fixtrading.org/www.technical-fixprotocol.org/ "$TARGET/html/SBEONLINE_PROD.html" > "$TARGET/html/SBEONLINE_TEST.html" +echo SBE ONLINE version created for PROD and TEST + +echo Compilation ended! diff --git a/v2-0-RC3/doc/SBE.yaml b/v2-0-RC3/doc/SBE.yaml new file mode 100644 index 0000000..1231084 --- /dev/null +++ b/v2-0-RC3/doc/SBE.yaml @@ -0,0 +1,15 @@ +--- +title: Simple Binary Encoding (SBE) +subtitle: Technical Specification +author: +- "Version 2.0 -- Release Candidate 3 -- XXXX xx, 20xx" +- "\x0D" +- "THIS DOCUMENT IS A RELEASE CANDIDATE FOR A PROPOSED FIX TECHNICAL STANDARD. A RELEASE" +- "CANDIDATE HAS BEEN APPROVED BY THE GLOBAL TECHNICAL COMMITTEE AS AN INITIAL STEP IN" +- "CREATING A NEW FIX TECHNICAL STANDARD. POTENTIAL ADOPTERS ARE STRONGLY ENCOURAGED TO" +- "BEGIN WORKING WITH THE RELEASE CANDIDATE AND TO PROVIDE FEEDBACK TO THE GLOBAL" +- "TECHNICAL COMMITTEE AND THE WORKING GROUP THAT SUBMITTED THE PROPOSAL. THE" +- "FEEDBACK TO THE RELEASE CANDIDATE WILL DETERMINE IF ANOTHER REVISION AND RELEASE" +- "CANDIDATE IS NECESSARY OR IF THE RELEASE CANDIDATE CAN BE PROMOTED TO BECOME A FIX" +- "TECHNICAL STANDARD DRAFT." +--- diff --git a/v2-0-RC3/doc/media/image1.jpeg b/v2-0-RC3/doc/media/image1.jpeg new file mode 100644 index 0000000..22cc891 Binary files /dev/null and b/v2-0-RC3/doc/media/image1.jpeg differ diff --git a/v2-0-RC3/resources/xml/examples.xml b/v2-0-RC3/resources/xml/examples.xml new file mode 100644 index 0000000..667ded8 --- /dev/null +++ b/v2-0-RC3/resources/xml/examples.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -3 + + + + 0 + + + + + + + 0 + 3 + 6 + 9 + + + 0 + 1 + 2 + 4 + 6 + + + 0 + 3 + 4 + 5 + 6 + 8 + A + F + + + 0 + 1 + 2 + 3 + 4 + 6 + 8 + A + E + + + 1 + 2 + 3 + 4 + + + 1 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/v2-0-RC3/resources/xml/messages-include.xml b/v2-0-RC3/resources/xml/messages-include.xml new file mode 100644 index 0000000..15c6783 --- /dev/null +++ b/v2-0-RC3/resources/xml/messages-include.xml @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/v2-0-RC3/resources/xml/types-include.xml b/v2-0-RC3/resources/xml/types-include.xml new file mode 100644 index 0000000..da18df2 --- /dev/null +++ b/v2-0-RC3/resources/xml/types-include.xml @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/v2-0-RC3/resources/xsd/sbe-2.0rc3.xsd b/v2-0-RC3/resources/xsd/sbe-2.0rc3.xsd new file mode 100644 index 0000000..e02cf7e --- /dev/null +++ b/v2-0-RC3/resources/xsd/sbe-2.0rc3.xsd @@ -0,0 +1,457 @@ + + + + + Message schema for FIX Simple Binary Encoding + *Namespace is tentative.* + Version: 2.0 RC2 + © Copyright 2014-2019 FIX Protocol Limited + License: Creative Commons Attribution-NoDerivatives 4.0 International Public License + + + + + + + + Root of XML document, holds all message templates + and their elements + + + + + + + + + + + Unique ID of a message schema + + + + + + The version of a message schema. Initial version is 0. + + + + + + Application layer specification version, such as + FIX version 'FIX.5.0SP2' + + + + + + + + + + + + + + + + Name of the encoding type of the message header, + which is the same for all messages in a schema. The name has a + default, but an encoding of that name must be present under a + 'types' element. + + + + + + + + + + + + A message type, also known as a message template + + + + + + + + Overrides the messageSchema package + + + + + + + + + + More than one set of types may be provided. + Names must be unique across all encoding + types. + Encoding types may appear in any order. + + + + + + + + + + + + + Overrides the messageSchema package + + + + + + + + + + Base type of message and repeating group entry + + + + + + Fixed-length fields + + + + + + Variable-length fields + + + + + + + Unique ID of a message template + + + + + + Space reserved for root level of message or repeating group, not + including nested groups or variable-length data elements. + + + + + + + + + + + A repeating group contains an array of entries + + + + + + + + + + + + Simple wire encoding consisting of a primitive type + or array of primitives + + + + + + + + + + + + + + + A simple type used as a member of a composite type + + + + + + + + + + + + + + + + A wire encoding composed of multiple parts + + + + + + + + + + + + + + + + + + An enumeration of valid values + + + + + + + + + + + + + + + Valid value as a string + + + + + + + + + + + + + + A reference to any existing encoding type (simple type, enum or set) + to reuse as a member of a composite type + + + + + + + How the referenced type is used + + + + + + + + A multi value choice (encoded as a bitset) + + + + + + + + + + + + + + + A choice within a multi value set. Value is the + position within a bitset (zero-based index). + + + + + + + + + + + + + + A field of a message of a specified dataType + + + + + + + Must match the name of an encoding contained by + 'types' element + + + + + + + + + + + + + + + + + + + + + + + + + + Byte alignment of the start of a block (message root or repeating group instance). + + + + + + + + Offset from start of a composite type or block + as a zero-based index. + + + + + + Byte alignment of the start of a block (message root or repeating group instance). + + + + + + + + + + + The value must always be populated + + + + + + Value may be set to nullValue for its data type + + + + + + Value does not vary so it need not be + serialized on the wire + + + + + + + + + Override of default null indicator for the data + type in SBE specification, as a string. + + + + + + Lower bound of a range + + + + + Upper bound of a range + + + + + A constant value as valid value of an enum + in the form enum-name.valid-value-name. Only valid if presence='constant'. + + + + + + + + + + + A value of a single-byte character set + + + + + + + + + + + + + + + + + + + Character set or Unicode encoding scheme + + + + + + + Application layer class. Maps a field to a FIX data type or a template to a FIX message. + + + + + + + + + Schema versioning supports message extension + + + + + + The schema version in which an element was added + + + + + + + The version of the schema in which an element was deprecated. It is retained + for back compatibility but should no longer be used by updated applications. + It may be removed in a later version. + + + + +
Technical Specification
Version 1.0 with Errata – Technical Standard – July 27, 2018
THIS DOCUMENT IS THE FINAL VERSION OF A FIX TECHNICAL STANDARD. THIS VERSION HAS BEEN
APPROVED BY THE GLOBAL TECHNICAL COMMITTEE AS THE FINAL STEP IN CREATING A NEW FIX
TECHNICAL STANDARD OR A NEW VERSION OF AN EXISTING FIX TECHNICAL STANDARD. POTENTIAL
ADOPTERS ARE STRONGLY ENCOURAGED TO USE ONLY THE FINAL VERSION. EXISTING ADOPTERS ARE
STRONGLY ENCOURAGED TO UPGRADE TO THE FINAL VERSION.
FIX Simple Binary Encoding (SBE) targets high performance trading systems. It is optimized for low latency of encoding and decoding while keeping bandwidth utilization reasonably small. For compatibility, it is intended to represent all FIX semantics.
This encoding specification describes the wire protocol for messages. Thus, it provides a standard for interoperability between communicating parties. Users are free to implement the standard in a way that best suits their needs.
The encoding standard is complimentary to other FIX standards for session protocol and application level behavior.
The Technical Specification is split into the following sections:
In order to support traditional FIX semantics, all the documented field types are supported. However, instead of printable character representations of tag-value encoding, the type system binds to native binary data types, and defines derived types as needed.
The binary type system has been enhanced in these ways:
Provides a means to specify precision of decimal numbers and timestamps, as well as valid ranges of numbers.
Differentiates fixed-length character arrays from variable-length strings. Allows a way to specify the minimum and maximum length of strings that an application can accept.
Provides a consistent system of enumerations, Boolean switches and multiple-choice fields.
The message design strives for direct data access without complex transformations or conditional logic. This is achieved by:
Usage of native binary data types and simple types derived from native binaries, such as prices and timestamps.
Preference for fixed positions and fixed length fields, supporting direct access to data and avoiding the need for management of heaps of variable-length elements which must be sequentially processed.
This standard describes how fields are encoded and the general structure of messages. The content of a message type is specified by a message schema. A message schema tells which fields belong to a message and their location within a message. Additionally, the metadata describes valid value ranges and information that need not be sent on the wire, such as constant values.
Message schemas may be based on standard FIX message specifications, or may be customized as needed by agreement between counterparties.
Data type - A field type with its associated encoding attributes, including backing primitive types and valid values or range. Some types have additional attributes, e.g. epoch of a date.
Encoding - a message format for interchange. The term is commonly used to mean the conversion of one data format to another, such as text to binary. However, Simple Binary Encoding strives to use native binary data types in order to make conversion unnecessary, or at least trivial. Encoding also refers to the act of formatting a message, as opposed to decoding.
Message schema - metadata that specifies messages and their data types and identifiers. Message schemas may be disseminated out of band. For Simple Binary Encoding, message schemas are expressed as an XML document that conforms to an XML schema that is published as part of this standard.
Message template - metadata that specifies the fields that belong to one particular message type. A message template is contained by a message schema.
Session protocol - a protocol concerned with the reliable delivery of messages over a transport. FIX protocol makes a distinction between session protocol and the encoding of a message payload, as described by this document. See the specifications section of FIX protocol web site for supported protocols. The original FIX session protocol is known as FIXT.
XML schema - defines the elements and attributes that may appear in an XML document. The SBE message schema is defined in W3C (XSD) schema language since it is the most widely adopted format for XML schemas.
This document explains:
The binary type system for field encoding
Message structure, including field arrangement, repeating groups, and relationship to a message header that may be provided by a session protocol.
The Simple Binary Encoding message schema.
These key words in this document are to be interpreted as described in Internet Engineering Task Force RFC2119. These terms indicate an absolute requirement for implementations of the standard: “must”, or “required”.
This term indicates an absolute prohibition: “must not”.
These terms indicate that a feature is allowed by the standard but not required: “may”, “optional”. An implementation that does not provide an optional feature must be prepared to interoperate with one that does.
These terms give guidance, recommendation or best practices: “should” or “recommended”. A recommended choice among alternatives is described as “preferred”.
These terms give guidance that a practice is not recommended: “should not” or “not recommended”.
In this document, these formats are used for technical specifications and data examples.
This is a sample encoding specification
<type name="short" primitiveType="int16" semanticType="int" />
This is sample data as it would be transmitted on the wire
10270000
Simple Open Framing Header, FIX Protocol, Limited. Version 1.0 Draft Standard specification has been published at http://www.fixtradingcommunity.org/
For FIX semantics, see the current FIX message specification, which is currently FIX 5.0 Service Pack 2 with Extension Packs.
SBE is dependent on several industry standards. Implementations must conform to these standards to interoperate. Therefore, they are normative for SBE.
IEEE 754-2008 A Standard for Binary Floating-Point Arithmetic
ISO 639-1:2002 Codes for the representation of names of languages - Part 1: Alpha-2 code
ISO 3166-1:2013 Codes for the representation of names of countries and their subdivisions - Part 1: Country codes
ISO 4217:2015 Codes for the representation of currencies and funds
ISO 8601:2004 Data elements and interchange formats - Information interchange - Representation of dates and times
ISO 10383:2012 Securities and related financial instruments - Codes for exchanges and market identification (MIC)
XML 1.1 schema standards are located here W3C XML Schema
A field is a unit of data contained by a FIX message. Every field has the following aspects: semantic data type, encoding, and metadata. They will be specified in more detail in the sections on data type encoding and message schema but are introduced here as an overview.
The FIX semantic data type of a field tells a data domain in a broad sense, for example, whether it is numeric or character data, or whether it represents a time or price. Simple Binary Encoding represents all of the semantic data types that FIX protocol has defined across all encodings. In message specifications, FIX data type is declared with attribute semanticType. See the section 2.2 below for a listing of those FIX types.
Encoding tells how a field of a specific data type is encoded on the wire. An encoding maps a FIX data type to either a simple, primitive data type, such as a 32 bit signed integer, or to a composite type. A composite type is composed of two or more simple primitive types. For example, the FIX data type Price is encoded as a decimal, a composite type containing a mantissa and an exponent. Note that many fields may share a data type and an encoding. The sections that follow explain the valid encodings for each data type.
Field metadata, part of a message schema, describes a field to application developers. Elements of field metadata are:
Field ID, also known as FIX tag, is a unique identifier of a field for semantic purposes. For example, tag 55 identifies the Symbol field of an instrument.
Field name, as it is known in FIX specifications
The FIX semantic data type and encoding type that it maps to
Valid values or data range accepted
Documentation
Metadata is normally not sent on the wire with Simple Binary Encoding messages. It is necessary to possess the message schema that was used to encode a message in order to decode it. In other words, Simple Binary Encoding messages are not self-describing. Rather, message schemas are typically exchanged out-of-band between counterparties.
See section 4 below for a detailed message schema specification.
By default, fields are assumed to be required in a message. However, fields may be specified as optional. To indicate that a value is not set, a special null indicator value is sent on the wire. The null value varies according to data type and encoding. Global defaults for null value may be overridden in a message schema by explicitly specifying the value that indicates nullness.
Alternatively, fields may be specified as constant. In which case, the data is not sent on the wire, but may be treated as constants by applications.
Default value handling is not specified by the encoding layer. A null value of an optional field does not necessarily imply that a default value should be applied. Rather, default handling is left to application layer specifications.
FIX semantic types are mapped to binary field encodings as follows. See sections below for more detail about each type.
Schema attributes may restrict the range of valid values for a field. See Common field schema attributes below.
The FIX semantic types listed above are spelled and capitalized exactly as they are in the FIX repository from which official FIX documents and references are derived.
Schema attributes alter the range of valid values for a field. Attributes are optional unless specified otherwise.
The attributes listed above apply to a field element or its encoding (wire format). Any attributes specified on an encoding are inherited by fields that use that encoding.
Encodings may be added to SBE messages that do not correspond to listed FIX data types. In that case, the encoding and fields that use the encoding will not have a semanticType attribute.
Integer encodings should be used for cardinal or ordinal number fields. Signed integers are encoded in a two’s complement binary format.
Numeric data types may be specified by range and signed or unsigned attribute. Integer types are intended to convey common platform primitive data types as they reside in memory. An integer type should be selected to hold the maximum range of values that a field is expected to hold.
The default data ranges and null indicator are listed below for each integer encoding.
A message schema may optionally specify a more restricted range of valid values for a field.
For optional fields, a special null value is used to indicate that a field value is not set. The default null indicator may also be overridden by a message schema.
Required and optional fields of the same primitive type have the same data range. The null value must not be set for a required field.
The byte order of integer fields, and for derived types that use integer components, is specified globally in a message schema. Little-Endian order is the default encoding, meaning that the least significant byte is serialized first on the wire.
See section 4.3.1 for specification of message schema attributes, including byteOrder. Message schema designers should specify the byte order most appropriate to their system architecture and that of their counterparties.
By nature, integers map to simple encodings. These are valid encoding specifications for each of the integer primitive types.
<type name="int8" primitiveType="int8" /> +<type name="int16" primitiveType="int16" /> +<type name="int32" primitiveType="int32" /> +<type name="int64" primitiveType="int64" /> +<type name="uint8" primitiveType="uint8" /> +<type name="uint16" primitiveType="uint16" /> +<type name="uint32" primitiveType="uint32" /> +<type name="uint64" primitiveType="uint64" />
Examples show example schemas and encoded bytes on the wire as hexadecimal digits in Little-Endian byte order.
Example integer field specification
<field type="uint32" name="ListSeqNo" id="67" semanticType="int" + description="Order number within the list" />
Value on the wire - uint32 value decimal 10,000, hexadecimal 2710.
Optional field with a valid range 0-6
<type name="range06" primitiveType="uint8" maxValue="6" + presence="optional" nullValue="255" /> +<field type="range06" name="MaxPriceLevels" id="1090" + semanticType="int"/>
Wire format of uint8 value decimal 3.
03
Sequence number field with integer encoding
<field type="uint64" name="MsgSeqNum" id="34" + semanticType="SeqNum" />
Wire format of uint64 value decimal 100,000,000,000, hexadecimal 174876E800.
00e8764817000000
Wire format of uint16 value decimal 10000, hexadecimal 2710.
1027
Wire format of uint32 null value 232 - 1
ffffffff
Decimal encodings should be used for prices and related monetary data types like PriceOffset and Amt.
FIX specifies Qty as a float type to support fractional quantities. However, decimal encoding may be constrained to integer values if that is appropriate to the application or market.
Prices are encoded as a scaled decimal, consisting of a signed integer mantissa and signed exponent. For example, a mantissa of 123456 and exponent of -4 represents the decimal number 12.3456.
Mantissa represents the significant digits of a decimal number. Mantissa is a commonly used term in computing, but it is properly known in mathematics as significand or coefficient.
Exponent represents scale of a decimal number as a power of 10.
A floating-point decimal transmits the exponent on the wire while a fixed-point decimal specifies a fixed exponent in a message schema. A constant negative exponent specifies a number of assumed decimal places to the right of the decimal point.
Implementations should support both 32 bit and 64 bit mantissa. The usage depends on the data range that must be represented for a particular application. It is expected that an 8 bit exponent should be sufficient for all FIX uses.
Optionally, implementations may support any other signed integer types for mantissa and exponent.
The default data ranges and null indicator are listed below for each decimal encoding.
A message schema may optionally specify a more restricted range of valid values for a field. For optional fields, a special mantissa value is used to indicate that a field value is null.
Decimal encodings are composite types, consisting of two subfields, mantissa and exponent. The exponent may either be serialized on the wire or may be set to constant. A constant exponent is a way to specify an assumed number of decimal places.
Decimal encoding specifications that an implementation must support
<composite name="decimal" > + <type name="mantissa" primitiveType="int64" /> + <type name="exponent" primitiveType="int8" /> +</composite> + +<composite name="decimal32" > + <type name="mantissa" primitiveType="int32" /> + <type name="exponent" primitiveType="int8" + presence="constant">-2</type> +</composite> + +<composite name="decimal64"> + <type name="mantissa" primitiveType="int64" /> + <type name="exponent" primitiveType="int8" + presence="constant">-2</type> +</composite>
When both mantissa and exponent are sent on the wire for a decimal, the elements are packed by default. However, byte alignment may be controlled by specifying offset of the exponent within the composite encoding. See section 4.4.4.3 below.
Examples show encoded bytes on the wire as hexadecimal digits, little-endian.
FIX Qty data type is a float type, but a decimal may be constrained to integer values by setting exponent to zero.
<composite name="intQty32" semanticType="Qty"> + <type name="mantissa" primitiveType="int32" /> + <type name="exponent" primitiveType="int8" + presence="constant">0</type> +</composite>
Field inherits semanticType from encoding
<field type="intQty32" name="OrderQty" id="38" + description="Total number of shares" />
Wire format of decimal 123.45 with 2 significant decimal places.
3930000000000000fe
Wire format of decimal64 123.45 with 2 significant decimal places. Schema attribute exponent = -2
3930000000000000
Wire format of decimal32 123.45 with 2 significant decimal places. Schema attribute exponent = -2
39300000
Binary floating point encodings are compatible with IEEE Standard for Floating-Point Arithmetic (IEEE 754-2008). They should be used for floating point numeric fields that do not represent prices or monetary amounts. Examples include interest rates, volatility and dimensionless quantities such as ratios. On the other hand, decimal prices should be encoded as decimals; see section 2.5 above.
Both single and double precision encodings are supported as primitive data types. See the IEEE 754-2008 standard for ranges and details of the encodings.
For both float and double precision encodings, null value of an optional field is represented by the Not-a-Number format (NaN) of the standard encoding. Technically, it indicated by the so-called quiet NaN.
Like integer encodings, floating point encodings follow the byte order specified by message schema. See section 4.3.1 for specification of message schema attributes, including byteOrder.
These are valid encoding specifications for each of the floating point primitive types.
<type name="float" primitiveType="float" /> +<type name="double" primitiveType="double" />
A single precision ratio
<type name="ratio" primitiveType="float" /> + +<field type="ratio" name="CurrencyRatio" id="1382" + semanticType="float"/>
Wire format of float 255.678
91ad7f43
Wire format of double 255.678
04560e2db2f56f40
Character data may either be of fixed size or variable size. In Simple Binary Encoding, fixed-length fields are recommended in order to support direct access to data. Variable-length encoding should be reserved for character strings that cannot be constrained to a specific size. It may also be used for non-ASCII encoded strings.
Character fields hold a single character. They are most commonly used for field with character code enumerations. See section 2.12 below for discussion of enum fields.
Valid values of a char field are printable characters of the US-ASCII character set (codes 20 to 7E hex.) The implicit nullValue is the NUL control character (code 0).
This is the standard encoding for char type.
<type name="char" primitiveType="char" semanticType="char" />
Wire format of char encoding of “A” (ASCII value 65, hexadecimal 41)
41
Character arrays are allocated a fixed space in a message, supporting direct access to fields. A fixed size character array is distinguished from a variable length string by the presence of a length schema attribute or a constant attribute.
A length attribute set to zero indicates variable length. See section 2.7.3 below for variable-length data encoding.
A fixed-length character array encoding must specify primitiveType=“char” and a length attribute is required.
Range attributes minValue and maxValue do not apply to fixed-length character arrays.
US-ASCII is the default encoding of character arrays to conform to usual FIX values. The characterEncoding attribute may be specified to override encoding.
A typical string encoding specification
<type name="string6" primitiveType="char" semanticType="String" + length="6" /> + +<field type="string6" name="Symbol" id="55" />
Wire format of a character array in character and hexadecimal formats
M S F T
4d5346540000
A character array constant specification
<type name="EurexMarketID" semanticType="Exchange" + primitiveType="char" length="4" description="MIC code" + presence="constant">XEUR</type> + +<field type="EurexMarketID" name="MarketID" id="1301" />
Variable-length string encoding is used for variable length ASCII strings or embedded non-ASCII character data (like EncodedText field). A separate length field coveys the size of the field.
On the wire, length immediately precedes the data.
The length subfield may not be null, but may be set to zero for an empty string. In that case, no space is reserved for the data. No distinction is made at an encoding layer between an empty string and a null string. Semantics of an empty variable-length string should be specified at an application layer.
Optionally, implementations may support any other unsigned integer types for length.
If the Length element has minValue and maxValue attributes, it specifies the minimum and maximum length of the variable-length data.
Range attributes minValue , maxValue, and nullValue do not apply to the data element.
If a field is required, both the Length and data fields must be set to a “required” attribute.
Variable length string is encoded as a composite type, consisting of a length sub field and data subfield. The length attribute of the varData element is set to zero in the XML message schema as special value to indicate that the character data is of variable length.
To map an SBE data field specification to traditional FIX, the field ID of a data field is used. Its associated length is implicitly contained by the composite type rather than specified as a separate field.
Encoding specification for variable length data up to 65535 octets
<composite name="varString" description="Variable-length string"> + <type name="length" primitiveType="uint16" semanticType="Length"/> + <type name="data" length="0" primitiveType="uint8" + semanticType="data" characterEncoding="UTF-16"/> +</composite> + +<data name="SecurityDesc" id="107" type="varString"/>
The characterEncoding attribute tells which variable-sized encoding is used if the data field represents encoded text. UTF-8 is the recommended encoding, but there is no default in the XML schema
Example shows encoded bytes on the wire.
Wire format of variable-length String in character and hexadecimal formats, preceded by uint16 length of 4 octets in little-endian byte order
04004d534654
Raw data is opaque to SBE. In other words, it is not constrained by any value range or structure known to the messaging layer other than length. Data fields simply convey arrays of octets.
Data may either be of fixed-length or variable-length. In Simple Binary Encoding, fixed-length data encoding may be used for data of predetermined length, even though it does not represent a FIX data type. Variable-length encoding should be reserved for raw data when its length is not known until run-time.
Data arrays are allocated as a fixed space in a message, supporting direct access to fields. A fixed size array is distinguished from a variable length data by the presence of a length schema attribute rather than sending length on the wire.
A fixed-length octet array encoding should specify primitiveType=“uint8” and a length attribute is required.
Data range attributes minValue and maxValue do not apply.
Since raw data is not constrained to a character set, characterEncoding attribute should not be specified.
A fixed-length data encoding specification for a binary user ID
<type name="uuid" primitiveType="uint8" length="16" description="RFC 4122 compliant UUID"/> + +<field type="uuid" name="Username" id="553" />
Variable-length data is used for variable length non-character data (such as RawData). A separate length field conveys the size of the field. On the wire, length immediately precedes the data.
The length subfield may not be null, but it may be set to zero. In that case, no space is reserved for the data. Semantics of an empty variable-length data element should be specified at an application layer.
If the Length field has minValue and maxValue attributes, it specifies the minimum and maximum length of the variable-length data. Data range attributes minValue , maxValue, and nullValue do not apply to a data field.
Variable length data is encoded as composite type, consisting of a length sub field and data subfield.
<composite name="DATA" description="Variable-length data"> + <type name="length" primitiveType="uint16" semanticType="Length"/> + <type name="data" length="0" primitiveType="uint8" semanticType="data" /> +</composite> + +<data name="RawData" id="96" type="DATA"/>
Wire format of data in character and hexadecimal formats, preceded by uint16 length of 4 octets in little-endian byte order
MonthYear encoding contains four subfields representing respectively year, month, and optionally day or week. A field of this type is not constrained to one date format. One message may contain only year and month while another contains year, month and day in the same field, for example.
Values are distinguished by position in the field. Year and month must always be populated for a non-null field. Day and week are set to special value indicating null if not present. If Year is set to the null value, then the entire field is considered null.
The four subfields of MonthYear are packed at an octet level by default. However, byte alignment may be controlled by specifying offset of the elements within the composite encoding. See section 4.4.4.3 below.
MonthYear data type is based on a composite encoding that carries its required and optional elements.
The standard encoding specification for MonthYear
<composite name="monthYear" semanticType="MonthYear"> + <type name="year" primitiveType="uint16" presence="optional" + nullValue="65536" /> + <type name="month" primitiveType="uint8" minValue="1" maxValue="12" /> + <type name="day" primitiveType="uint8" minValue="1" maxValue="31" + presence="optional" nullValue="255" /> + <type name="week" description="week of month" primitiveType="uint8" + minValue="1" maxValue="5" presence="optional" nullValue="255" /> +</composite>
Example MonthYear field specification
Wire format of MonthYear 2014 June week 3 as hexadecimal
de0706ff03
Dates and times represent Coordinated Universal Time (UTC). This is the preferred date/time format, except where regulations require local time with time zone to be reported (see time zone encoding below).
Each time type has an epoch, or start of a time period to count values. For timestamp and date, the standard epoch is the UNIX epoch, midnight January 1, 1970 UTC.
A time-only value may be thought of as a time with an epoch of midnight of the current day. Like current time, the epoch is also referenced as UTC.
Time unit tells the precision at which times can be collected. Time unit may be serialized on the wire if timestamps are of mixed precision. On the other hand, if all timestamps have the same precision, then time unit may be set to a constant in the message schema. Then it need not be sent on the wire.
Time specifications use an enumeration of time units. See section 2.13 below for a fuller explanation of enumerations.
Enumeration of time units:
<enum name="TimeUnit" encodingType="uint8"> + <validValue name="second">0</validValue> + <validValue name="millisecond">3</validValue> + <validValue name="microsecond">6</validValue> + <validValue name="nanosecond">9</validValue> +</enum>
Timestamp with variable time units:
<composite name="UTCTimestamp" description="UTC timestamp with precision on the wire" semanticType="UTCTimestamp" > + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" /> +</composite>
Timestamp with constant time unit:
<composite name="UTCTimestampNanos" description="UTC timestamp with nanosecond precision" semanticType="UTCTimestamp" > + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" presence="constant" valueRef="TimeUnit.nanosecond" /> +</composite>
Time only with variable time units:
<composite name="UTCTime" description="Time of day with precision on the wire" semanticType="UTCTimeOnly" > + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" /> +</composite>
Time only with constant time unit:
<composite name="UTCTimeNanos" description="Time of day with millisecond precision" semanticType="UTCTimeOnly" > + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" presence="constant" valueRef="TimeUnit.millisecond" /> +</composite>
Date only specification:
<type name="date" primitiveType="uint16" semanticType="UTCDateOnly" />
timestamp 14:17:22 Friday, October 4, 2024 UTC (20,000 days and 14 hours, 17 minutes and 22 seconds since the UNIX epoch) with default schema attributes
<composite name="UTCTimestampNanos" description="UTC timestamp with nanosecond precision" semanticType="UTCTimestamp" > +<type name="time" primitiveType="uint64" /> +<type name="unit" primitiveType="uint8" presence="constant" valueRef="TimeUnit.nanosecond" /> +</composite>
Wire format of UTCTimestamp with constant time unit in little-Endian byte order
4047baa145fb17
time 10:24:39.123456000 (37,479 seconds and 123456000 nanoseconds since midnight UTC) with default schema attributes
<composite name="UTCTimeOnlyNanos" description="UTC time of day with nanosecond precision" semanticType="UTCTimeOnly" > + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" presence="constant" valueRef="TimeUnit.nanosecond" /> +</composite>
Wire format of UTCTimeOnly
10d74916220000
date Friday, October 4, 2024 (20,000 days since UNIX epoch) with default schema attributes
Wire format of UTCDateOnly
204e
Local date is encoded the same as UTCDateOnly, but it represents local time at the market instead of UTC time.
The standard encoding specification for LocalMktDate
<type name="localMktDate" primitiveType="uint16" semanticType="LocalMktDate" />
Time with time zone encoding should only be used when required by market regulations. Otherwise, use UTC time encoding (see above).
Time zone is represented as an offset from UTC in the ISO 8601:2004 format ±hhmm.
A binary UTCTimestamp followed by a number representing the time zone indicator as defined in ISO 8601:2004.
The subfields of TZTimestamp are packed at an octet level by default. However, byte alignment may be controlled by specifying offset of the elements within the composite encoding. See section 4.4.4.3 below.
Standard TZTimestamp encoding specification
<composite name="tzTimestamp" semanticType="TZTimestamp"> + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" /> + <!-- Sign of timezone offset is on hour subfield --> + <type name="timezoneHour" primitiveType="int8" minValue="-12" maxValue="14" /> + <type name="timezoneMinute" primitiveType="uint8" maxValue="59" /> +</composite>
Wire format of TZTimestamp 8:30 17 September 2013 with Chicago time zone offset (-6:00)
0050d489fea22413fa00
A binary UTCTimeOnly followed by a number representing the time zone indicator as defined in ISO 8601:2004.
The time zone hour offset tells the number of hours different to UTC time. The time zone minute tells the number of minutes different to UTC. The sign telling ahead or behind UTC is on the hour subfield.
The subfields of TZTimeOnly are packed at an octet level by default. However, byte alignment may be controlled by specifying offset of the elements within the composite encoding. See section 4.4.4.3 below.
Standard TZTimeOnly encoding specification
<composite name="tzTimeOnly" semanticType="TZTimeOnly"> + <type name="time" primitiveType="uint64" /> + <type name="unit" primitiveType="uint8" /> + <!-- Sign of timezone offset is on hour subfield --> + <type name="timezoneHour" primitiveType="int8" + minValue="-12" maxValue="14" /> + <type name="timezoneMinute" primitiveType="uint8" minValue="0" + maxValue="59" /> +</composite>
Wire format of TZTimeOnly 8:30 with Chicago time zone offset (-6:00)
006c5ebe76000000fa00
An enumeration conveys a single choice of mutually exclusive valid values.
An unsigned integer or character primitive type is selected to contain the number of choices. Implementations must support char and uint8 types. They may additionally support other unsigned integer types to allow more choices.
If a field is of FIX data type char, then its valid values are restricted to US-ASCII printable characters. See section 2.7.1 above.
If the field is of FIX data type int, then a primitive integer data type should be selected that can contain the number of choices. For most cases, an 8 bit integer will be sufficient, allowing 255 possible values.
Enumerations of other data types, such as String valid values specified in FIX, should be mapped to an integer wire format in SBE.
In a message schema, the choices are specified a <validValue> members of an <enum>. An <enum> specification must contain at least one <validValue>.
<validValue>
<enum>
The name and value of a validValue element must be unique within an enumeration.
An <enum> element must have an encodingType attribute to specify the type of its values. Two formats of encodingType are acceptable:
In-line style: the value of encodingType is its primitive data type.
Reference style: the value of encodingType is the name of a <type> element that specifies the wire format.
<type>
The length of a <type> associated to an enumeration must be 1. That is, enumerations should only be backed by scalar types, not arrays.
These examples use a char field for enumerated code values.
Example enum lists acceptable values and gives the underlying encoding, which in this case is char (in-line style)
<enum name="SideEnum" encodingType="char"> + <validValue name="Buy">1</validValue> + <validValue name="Sell">2</validValue> + <validValue name="SellShort">5</validValue> + <validValue name="SellShortExempt">6</validValue> + <!-- not all FIX values shown --> +</enum>
Reference to type: This specification is equivalent to the one above.
<type name="charEnumType" primitiveType="char"/> + <enum name="SideEnum" encodingType="charEnumType"> + <!-- valid values as above --> +</enum>
Side field specification references the enumeration type
<field name="Side" type="SideEnum" id="54" />
Wire format of Side “Buy” code as hexadecimal
01
A constant field may be specified as a value of an enumeration. The attribute valueRef is a cross-reference to validValue entry by symbolic name.
Example of a char field using a constant enum value
<enum name="PartyIDSourceEnum" encodingType="char"> + <validValue name="BIC">B</validValue> + <validValue name="GeneralIdentifier">C</validValue> + <validValue name="Proprietary">D</validValue> +</enum> + +<field type="PartyIDSourceEnum" name="PartyIDSource" id="447" + description="Party ID source is fixed" presence="constant" + valueRef="PartyIDSourceEnum.GeneralIdentifier" />
A Boolean field is a special enumeration with predefined valid values: true and false. Like a standard enumeration, an optional Boolean field may have nullValue that indicates that the field is null (or not applicable).
Standard encoding specifications for required and optional Boolean fields
<enum name="booleanEnum" encodingType="uint8" semanticType="Boolean"> + <validValue name="false">0</validValue> + <validValue name="true">1</validValue> +</enum> + +<enum name="optionalBoolean" encodingType="uint8" semanticType="Boolean"> + <validValue name="false">0</validValue> + <validValue name="true">1</validValue> + <validValue name="nullValue">255</validValue> +</enum>
Example optional Boolean field
<field type="optionalBoolean" name="SolicitedFlag" id="377" />
Wire format of true value as hexadecimal
Wire format of false value as hexadecimal
00
Wire format of null Boolean (or N/A) value as hexadecimal
ff
A multi-value field conveys a choice of zero or more non-exclusive valid values.
The binary encoding uses a bitset (a fixed-size sequence of bits, also known as bitmap, bit array or bit vector) to represent up to 64 possible choices. The encoding is backed by an unsigned integer. The smallest unsigned primitive type should be selected that can contain the number of valid choices.
Like other integer-backed encodings, multi-value encodings follow the byte order specified by message schema when serializing to the wire. See section 4.3.1 for specification of message schema attributes, including byteOrder.
Each choice is assigned a bit of the primitive integer encoding, starting with the least significant bit. For each choice the value is selected or not, depending on whether it corresponding bit is set or cleared.
Any remaining unassigned bits in an octet should be cleared.
There is no explicit null value for multi-value choice encoding other than to set all bits off when no choices are selected.
In a message schema, the choices are specified as <choice> members of an <set> element. Choices are assigned values as an ordinal of bits in the bit set. The first Choice “0” is assigned the least significant bit; choice “1” is the second bit, and so forth.
<choice>
<set>
The name and value (bit position) must be unique for element of a set.
A <set> element must have an encodingType attribute to specify the wire format of its values. Two formats of encodingType are recognized :
The length of a <type> associated to an bitset must be 1. That is, bitsets should not be specified as arrays.
Example of a multi-value choice (was MultipleCharValue in tag-value encoding) Encoding type is in-line style.
<set name="FinancialStatusEnum" encodingType="uint8"> + <choice name="Bankrupt">0</choice> + <choice name="Pending delisting">1</choice> + <choice name="Restricted">2</choice> +</set>
Reference to type. This is equivalent to the example above.
<type name="u8Bitset" primitiveType="uint8"/> + +<set name="FinancialStatusEnum" encodingType="u8Bitset"> +<!--choices as above --> +</set>
A field using the multi-choice encoding
<field type="FinancialStatus" name="FinancialStatusEnum" + id="291" semanticType="MultipleCharValue"/>
Wire format of choices “Bankrupt” + “Pending delisting” (first and second bits set)
These validations apply to message field values.
If a value violation is detected on a received message, the message should be rejected back to the counterparty in a way appropriate to the session protocol.
SBE messages have no defined message delimiter. Version 2.0 of SBE makes it possible to walk the elements of a message to determine its limit, even when the message has been extended. Nevertheless, since internal framing depends on a correct starting point and not encountering malformed messages, it may be desirable to use an external framing protocol when used with transports that do not preserve message boundaries, such as when they are transmitted on a streaming session protocol or when persisting messages in storage.
FIX Protocol Ltd. offers the Simple Open Framing Header standard for framing messages encoded with binary wire formats, such as Simple Binary Encoding.
The framing header provides two features:
An overall message size including headers to support framing
An identifier of the encoding used in the message payload. This supports selecting the correct decoder in the case where multiple message encodings are used on a session. It also aids tooling such as protocol analyzers to identify message protocols contained in network packets.
While the Simple Open Framing Header specification is normative, the following is an interpretation of that standard as an SBE encoding. Note that the framing standard specifies that the framing header will always be encoded in big-endian byte order, also known as network byte order.
Simple Open Framing Header as an SBE composite encoding (big-endian)
<composite name="framingHeader"/> + <type name="messageLength" primitiveType="uint32" /> + <type name="encodingType" primitiveType="uint16" /> +</composite>
The values of encodingType used to indicate SBE payloads are currently defined as:
The Simple Open Framing Header specification also lists values for other wire formats.
The purpose of the message encoding header is to tell which message template was used to encode the message and to give information about the size of the message body to aid in decoding, even when a message template has been extended in a later version. See section 5 below for an explanation of the schema extension mechanism.
The fields of the SBE message header are:
Block length of the message root - the total space reserved for the root level of the message not counting any repeating groups or variable-length fields.
Template ID - identifier of the message template
Schema ID - identifier of the message schema that contains the template
Schema version - the version of the message schema in which the message is defined
Group count - the number of repeating groups in the root level of the message
Variable-length field count - the number of variable-length fields in the root level of the message
Block length is specified in a message schema, but it is also serialized on the wire. By default, block length is set to the sum of the sizes of body fields in the message. However, it may be increased to force padding at the end of block. See section 3.3.3.3 below.
The header fields precede the message body of every message in a fixed position as shown below. Each of these fields must be encoded as an unsigned integer type. The encoding must carry the name “messageHeader”.
The message header is encoded in the same byte order as the message body, as specified in a message schema. See section 4.3.1.
Recommended message header encoding
<composite name="messageHeader" description="Template ID 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"/> + <type name="numGroups" primitiveType="uint16" /> + <type name="numVarDataFields" primitiveType="uint16" /> +</composite>
The recommended header encoding is 12 octets.
Optionally, implementations may support any other unsigned integer types for blockLength.
The total space reserved for the root level of the message not counting any repeating groups or variable-length fields. (Repeating groups have their own block length; see section 3.4 below. Length of a variable-length Data field is given by its corresponding Length field; see section 2.7.3 above.) Block length only represents message body fields; it does not include the length of the message header itself, which is a fixed size.
The block size must be at least the sum of lengths of all fields at the root level of the message, and that is its default value. However, it may be set larger to reserve more space to effect alignment of blocks. This is specified by setting the blockLength attribute in a message schema.
The identifier of a message type in a message schema. See section 4.5.2 below for schema attributes of a message.
The identifier of a message schema. See section 4.3.1 below for schema attributes.
The version number of the message schema that was used to encode a message. See section 4.3.1 below for schema attributes.
A count of repeating groups at the root level of the message. The count does not include nested repeating groups.
A count of the variable-length fields at the root level of the message. The count does not include variable-length fields within repeating groups.
The message body conveys the business information of the message.
In SBE, fields of a message occupy proximate space without delimiters or metadata, such as tags.
Access to data is positional, guided by a message schema that specifies a message type.
Data fields in the message body correspond to message schema fields; they are arranged in the same sequence. The first data field has the type and size specified by the first message schema field, the second data field is described by the second message schema field, and so forth. Since a message decoder follows the field descriptions in the schema for position, it is not necessary to send field tags on the wire.
In the simplest case, a message is flat record with a fixed length. Based on the sequence of field data types, the offset to a given data field is constant for a message type. This offset may be computed in advance, based on a message schema. Decoding a field consists of accessing the data at this fixed location.
By default, there is no padding between fields. In other words, a field value is packed against values of its preceding and following fields. No consideration is given to byte boundary alignment.
By default, the position of a field in a message is determined by the sum of the sizes of prior fields, as they are defined by the message schema.
<field name="ClOrdID" id="11" type="string14" + semanticType="String"/> +<field name="Side" id="54" type="char" semanticType="char"/> +<field name="OrderQty" id="38" type="intQty32" + semanticType="Qty"/> +<field name="Symbol" id="55" type="string8" semanticType="String"/>
If a message designer wishes to introduce padding or control byte boundary alignment or map to an existing data structure, field offset may optionally be specified in a message schema. Field offset is the number of octets from the start of the message body or group to the first octet of the field. Offset is a zero-based index.
If specified, field offset must be greater than or equal to the sum of the sizes of prior fields. In other words, an offset is invalid if it would cause fields to overlap.
Extra octets specified for padding should never be interpreted as business data. They should be filled with binary zeros.
Example of fields with specified offsets
<field name="ClOrdID" id="11" type="string14" offset="0" + semanticType="String"/> +<field name="Side" id="54" type="char" offset="14" + semanticType="char"/> +<field name="OrderQty" id="38" type="intQty32" offset="16" + semanticType="Qty"/> +<field name="Symbol" id="55" type="string8" offset="20" + semanticType="String"/>
In order to force messages or groups to align on byte boundaries or map to an existing data structure, they may optionally be specified to occupy a certain space with a blockLength attribute in the message schema. The extra space is padded at the end of the message or group. If specified, blockLength must be greater than or equal to the sum of the sizes of all fields in the message or group.
The blockLength attribute applies only to the portion of message that contains fix-length fields; it does not apply to variable-length data elements of a message.
Extra octets specified for padding should be filled with binary zeros.
Example of blockLength specification for 24 octets
<message name="ListOrder" id="2" blockLength="24">
A repeating group is a message structure that contains a variable number of entries. Each entry contains fields specified by a message schema.
The order and data types of the fields are the same for each entry in a group. That is, the entries are homogeneous. Position of a given field within any entry is fixed, with the exception of variable-length fields.
A message may have no groups or an unlimited number of repeating groups specified in its schema.
A repeating group is defined in a message schema by adding a <group> element to a message template. An unlimited number of <field> elements may be added to a group, but a group must contain at least one field.
<group>
<field>
Example repeating group encoding specification
<group name="Parties" id="1012" blockLength="16"> + <field name="PartyID" id="448" type="string14" + semanticType="String"/> + <field name="PartyIDSource" id="447" type="char" + semanticType="char"/> + <field name="PartyRole" id="452" type="uint8" semanticType="int"/> +</group>
The blockLength part of a group dimension represents total space reserved for each group entry, not counting any nested repeating groups or variable-length fields. (Length of a variable-length Data field is given by its corresponding Length field.) Block length only represents message body fields; it does not include the length of the group dimension itself, which is a fixed size.
By default, the space reserved for an entry is the sum of a group’s field lengths, as defined by a message schema, without regard to byte alignment.
The space reserved for an entry may optionally be increased to effect alignment of entries or to plan for future growth. This is specified by adding the group attribute blockLength to reserve a specified number of octets per entry. If specified, the extra space is padded at the end of each entry and should be set to zeroes by encoders. The blockLength value does not include the group dimensions itself.
Note that padding will only result in deterministic alignment if the repeating group contains no variable-length fields.
Each group is associated with a required counter field of semantic data type NumInGroup to tell how many entries are contained by a message. The value of the counter is a non-negative integer. See “Encoding of repeating group dimensions” section below for encoding of that counter.
The space reserved for all entries of a group is the product of the space reserved for each entry times the value of the associated NumInGroup counter. If the counter field is set to zero, then no entries are sent in the message, and no space is reserved for entries. The group dimensions including the zero-value counter is still transmitted, however.
A message may contain multiple repeating groups at the same level.
Example of encoding specification with multiple repeating groups
<message name="ExecutionReport" id="8"> + <group name="ContraGrp" id="2012"> + <!-- ContraGrp group fields --> + </group> + <group name="PreAllocGrp" id="2026"> + <!-- PreAllocGrp group fields --> + </group> +</message>
Repeating groups may be nested to an arbitrary depth. That is, a <group> in a message schema may contain one or more <group> child elements, each associated with their own counter fields.
The encoding specification of nested repeating groups is in the same format as groups at the root level of a message in a recursive procedure.
Example of nested repeating group specification
<group name="ListOrdGrp" id="2030"> + <field name="ClOrdID" id="11" type="string14" semanticType="String"/> + <field name="ListSeqNo" id="67" type="uint32" semanticType="int"/> + <field name="Symbol" id="55" type="string8" semanticType="String"/> + <field name="Side" id="54" type="char" semanticType="char"/> + <field name="OrderQty" id="38" type="intQty32" semanticType="Qty"/> + <group name="Parties" id="1012"> + <field name="PartyID" id="448" type="string14" semanticType="String"/> + <field name="PartyRole" id="452" type="int" semanticType="int"/> + </group> +</group>
Nested repeating groups are encoded on the wire by a depth-first walk of the data hierarchy. For example, all inner entries under the first outer entry must be encoded before encoding outer entry 2. (This is the same element order as FIX tag=value encoding.)
On decoding, nested repeating groups do no support direct access to fields. It is necessary to walk all elements in sequence to discover the number of entries in each repeating group.
If a group contains nested repeating groups, then a NumInGroup counter of zero implies that both that group and its child groups are empty. In that case, no NumInGroup is encoded on the wire for the child groups.
Every repeating group must be immediately preceded on the wire by its dimensions. The two dimensions are the count of entries in a repeating group and the space reserved for each entry of the group.
Implementations should support uint8 and uint16 types for repeating group entry counts. Optionally, implementations may support any other unsigned integer types.
By default, the minimum number of entries is zero, and the maximum number is the largest value of the primitiveType of the counter.
The number of entries may be restricted to a specific range; see “Restricting repeating group entries” below.
Conventionally in FIX, a NumInGroup field conveys the number of entries in a repeating group. In SBE, the encoding conveys two dimensions: the number of entries and the length of each entry in number octets. Therefore, the encoding is a composite of those two elements. Block length and entry count subfields must be encoded as unsigned integer types.
By default, the name of the group dimension encoding is groupSizeEncoding. This name may be overridden by setting the dimensionType attribute of a <group> element.
Recommended encoding of repeating group dimensions
<composite name="groupSizeEncoding"> + <type name="blockLength" primitiveType="uint16"/> + <type name="numInGroup" primitiveType="uint16" semanticType="NumInGroup"/> + <type name="numGroups" primitiveType="uint16" /> + <type name="numVarDataFields" primitiveType="uint16" /> +</composite>
The total space reserved for the fixed-length fields of this repeating group, not counting any repeating groups or variable-length fields.
The number of entries in this repeating group, called NumInGroup in FIX.
A count nested repeating groups in this repeating group.
A count of the variable-length fields in this repeating group.
Wire format of NumInGroup with block length 55 octets by 3 entries, containing one nested group and two variable-length fields.
3700030001000200
The occurrences of a repeating group may be restricted to a specific range by modifying the numInGroup member of the group dimension encoding. The minValue attribute controls the minimum number of entries, overriding the default of zero, and the maxValue attribute restricts the maximum entry count to something less than the maximum corresponding to its primitiveType. Either or both attributes may be specified.
Example of a restricted group encoding
<type name="numInGroup" primitiveType="uint16" semanticType="NumInGroup" minValue="1" maxValue="10" />
To maximize deterministic field positions, message schemas must be specified with this sequence of message body elements:
Fixed-length fields that reside at the root level of the message (that is, not members of repeating groups), including any of the following, in the order specified by the message schema::
Fixed-length scalar fields, such as integers
Fixed-length character arrays
Fixed-length composite types, such as MonthYear
Repeating groups, if any.
Data fields, including raw data and variable-length strings, if any.
Repeating group entries are recursively organized in the same fashion as the root level: fixed-length fields, then nested repeating groups, and finally, variable-length data fields.
Aside from message schema validations (see section 4.8 below), these validations apply to message structure.
If a message structure violation is detected on a received message, the message should be rejected back to the counterparty in a way appropriate to the session protocol.
See sbe.xsd for the normative XML Schema Definition (XSD) for SBE.
The Simple Binary Encoding XML schema is identified by this URL [tentative]:
xmlns:sbe=http://fixprotocol.io/2017/sbe
Conventionally, the URI of the XML schema is aliased by the prefix “sbe”.
Caution: Users should treat the SBE XML namespace as a URI (unique identifier), not as a URL (physical resource locator). Firms should not depend on access to the FIX Trading Community web site to validate XML schemas at run-time
All symbolic names in a message schema are restricted to alphanumeric characters plus underscore without spaces. This is the same restriction applied to all names in FIX specifications.
The value of a field’s semanticType attribute is a FIX data type. In this document, FIX types are capitalized exactly as in the FIX repository, from which all official FIX documentation and references are derived. Since the capitalization is somewhat inconsistent, however, it is recommended that matching of type names should be case insensitive in schema parsers.
semanticType
The root element of the XML document is <messageSchema>.
<messageSchema>
The root element provides basic identification of a schema.
The byteOrder attribute controls the byte order of integer encodings within the schema. It is a global setting for all specified messages and their encodings.
byteOrder
Changes to a message schema may be tracked by its version attribute. A version of a schema is a snapshot in time. All elements in a given generation of the schema share the same version number. That is, elements are not versioned individually. By convention, the initial version of a schema is version zero, and subsequent changes increment the version number.
version
The package attribute should remain constant between versions, if it is supplied.
package
The <types> element contains one or more sets of data encodings used for messages within the schema.
<types>
Within each set, an unbound number of encodings will be listed in any sequence:
Element <type> defines a simple encoding
Element <composite> defines a composite encoding
<composite>
Element <enum> defines an enumeration
Element <set> defines a multi-value choice bitset encoding
The namespace for encoding names is global across all encodings included in a schema, including simple, composite and enumeration types. That is, the name must be unique among all encoding instances.
All symbolic names should be alphanumeric without spaces.
A suggested usage is to import common encodings that are used across message schemas as one set while defining custom encodings that are particular to a schema in another set.
Example of XML include usage to import common encoding types
<!-- included XML contains a <types> element --> +<xi:include href="sbe-builtins.xml"/>
A simple encoding is backed by either a scalar type or an array of scalars, such as a character array. One or more simple encodings may be defined, each specified by a <type> element.
If the element has a value, it is used to indicate a special value of the encoding.
The element value represents a constant if attribute presence="constant". In this case, the value is conditionally required.
presence="constant"
The attribute semanticType must be specified on either a field or on its corresponding type encoding. It need not be specified in both places, but if it is, the two values must match.
Simple type examples
<type name="FLOAT" primitiveType="double" + semanticType="float"/> +<type name="TIMESTAMP" primitiveType="uint64" + semanticType="UTCTimestamp"/> +<type name="GeneralIdentifier" primitiveType="char" + description="Identifies class or source + of the PartyID" presence="constant">C</type>
Composite encoding types are composed of two or more simple types.
A <composite> composite encoding element may be composed of any combination of types, including <type> simple encoding, <enum> enumeration, <set> bitset, and nested composite type. The elements that compose a composite type carry the same XML attributes as stand-alone types.
Composite type example
In this example, a Price is encoded as 32 bit integer mantissa and a constant exponent, which is not sent on the wire.
<composite name="decimal32" semanticType="Price"> + <type name="mantissa" primitiveType="int32" /> + <type name="exponent" primitiveType="int8" + presence="constant">-4</type> +</composite>
If a message designer wishes to control byte boundary alignment or map to an existing data structure, element offset may optionally be specified on a simple type, enum or bitset within a composite type. Offset is the number of octets from the start of the composite; it is a zero-based index.
If specified, offset must be greater than or equal to the sum of the sizes of prior elements. In other words, an offset is invalid if it would cause elements to overlap.
For a composite type, nullness is indicated by the value of its first element. For example, if a price field is optional, a null value in its mantissa element indicates that the price is null.
A composite type often has its elements defined in-line within the <composite> XML element as shown in the example above. Alternatively, a common type may be defined once on its own, and then referred to by name with the composite type using a <ref> element.
<ref>
Reference to an enum
In this example, a futuresPrice is encoded as 64 bit integer mantissa, 8 bit exponent, and a reused enum type.
<enum name="booleanEnum" encodingType="uint8" semanticType="Boolean"> + <validValue name="false">0</validValue> + <validValue name="true">1</validValue> +</enum> + +<composite name="futuresPrice"> + <type name="mantissa" primitiveType="int64" /> + <type name="exponent" primitiveType="int8" /> + <ref name="isSettlement" type="boolEnum" /> +</composite>
Reference to a composite type
In this example, a nested composite is formed by using a reference to another composite type. It supports the expresson of a monetary amount with its currency, such as USD150.45. Note that a reference may carry an offset within the composite encoding that contains it.
<composite name="price"> + <type name="mantissa" primitiveType="int64" /> + <type name="exponent" primitiveType="int8" /> +</composite> + +<composite name="money"> + <type name="currencyCode" primitiveType="char" length="3" semanticType="Currency" /> + <ref name="amount" type="price" semanticType="Price" offset="3" /> +</composite>
An enumeration explicitly lists the valid values of a data domain. Any number of fields may share the same enumeration.
Each enumeration is represented by an <enum> element. It contains any number of <validValue> elements.
The encodingType attribute refers to a simple encoding of scalar type. The encoding of an enumeration may be char or any unsigned integer type.
encodingType
The name attribute of the <validValue> uniquely identifies it.
The element is required to carry a value, which is the valid value as a string. The string value in XML must be convertible to the data type of the encoding, such as an integer.
<enum> and <validValue> elements
Enumeration example (not all valid values listed)
This enumeration is encoded as an 8 bit unsigned integer value. Others are encoded as char codes.
<type name="intEnum" primitiveType="uint8" /> + +<enum name="PartyRole" encodingType="intEnum"> + <validValue name="ExecutingFirm">1</validValue> + <validValue name="BrokerOfCredit">2</validValue> + <validValue name="ClientID">3</validValue> + <validValue name="ClearingFirm">4</validValue> +</enum>
An enumeration explicitly lists the valid values of a data domain. Any number of fields may share the same set of choices.
Each multi-value choice is represented by a <set> element. It may contain a number of <choice> elements up to the number of bits in the primitive encoding type. The largest number possible is 64 choices in a uint64 encoding.
The encodingType attribute refers to a simple encoding of scalar type. The encoding of a bitset should be an unsigned integer type.
The name attribute of the <choice> uniquely identifies it.
name
< choice >
The element is required to carry a value, which is an unsigned integer representing a zero-based index to a bit within a bitset. Zero is the least significant bit.
<set> and <choice> XML elements
Multi-value choice example, The choice is encoded as a bitset.
<type name="bitset" primitiveType="uint8" /> + +<set name="Scope" encodingType="bitset" > + <choice name="LocalMarket">0</choice> + <choice name="National">1</choice> + <choice name="Global">2</choice> +</set>
To define a message type, add a <message> element to the root element of the XML document, <messageSchema>.
<message>
The name and id attributes are required. The first is a display name for a message, while the latter is a unique numeric identifier, commonly called template ID.
id
By default, message size is the sum of its field lengths. However, a larger size may be reserved by setting blockLength, either to allow for future growth or for desired byte alignment. If so, the extra reserved space should be filled with zeros by message encoders.
A <message> element contains its field definitions in three categories, which must appear in this sequence:
Element <field> defines a fixed-length field
Element <group> defines a repeating group
Element <data> defines a variable-length field, such as raw data
<data>
The number of members of each type is unbound.
The order that fields are listed in the message schema governs the order that they are encoded on the wire.
<message> element attributes
Note that there need not be a one-to-one relationship between message template (identified by id attribute) and semanticType attribute. You might design multiple templates for the same FIX MsgType to optimize different scenarios.
Example <message> element
<sbe:message name="NewOrderSingle" id="2" semanticType="D">
Fields are added to a <message> element as child elements. See Field Encoding section above for a listing of all field types.
These are the common attributes of all field types.
Example field schemas
Field that uses a composite encoding
<composite name="intQty32" semanticType="Qty"> + <type name="mantissa" primitiveType="int32" /> + <type name="exponent" primitiveType="int8" + presence="constant">0\</type> +</composite> + +<field type="intQty32" name="OrderQty" id="38" offset="16" + description="Shares: Total number of shares" />
A <group> has the same attributes as a <message> element since they both inherit attributes from the blockType XML type. A group has the same child members as a message, and they must appear in the same order:
Element <group> defines a repeating group. Groups may be nested to any level.
<group> element inherits attributes of blockType. See <message> above.
Example group schema with default dimension encoding
<composite name="groupSizeEncoding"> + <type name="blockLength" primitiveType="uint16"/> + <type name="numInGroup" primitiveType="uint16" + semanticType="NumInGroup"/> +</composite> + +<group name="Parties" id="1012" > + <field type="string14" name="PartyID" id="448" /> + <field type="partyRoleEnum" name="PartyRole" id="452" /> +</group>
The first level of schema validation is enforced by XML schema validation tools to make sure that a schema is well-formed according to XSD schema rules. Well-formed XML is necessary but insufficient to prove that a schema is correct according to FIX Simple Binary Encoding rules.
Additional conditions that render a schema invalid include the following.
<message name="ListOrder" id="2" description="Simplified + NewOrderList. Demonstrates repeating group"> + <field name="ListID" id="66" type="string14" semanticType="String"/> + <field name="BidType" id="394" type="uint8" semanticType="int"/> + <group name="ListOrdGrp" id="2030" > + <field name="ClOrdID" id="11" type="string14" semanticType="String"/> + <field name="ListSeqNo" id="67" type="uint32" semanticType="int"/> + <field name="Symbol" id="55" type="string8" semanticType="String"/> + <field name="Side" id="54" type="char" semanticType="char"/> + <field name="OrderQty" id="38" type="intQty32" semanticType="Qty"/> + </group> +</message>
<message name="UserRequest" id="4" description="Demonstrates raw data usage"> + <field name="UserRequestId" id="923" type="string14" semanticType="String"/> + <field name="UserRequestType" id="924" type="uint8" semanticType="int"/> + <field name="UserName" id="553" type="string14" semanticType="String"/> + <field name="Password" id="554" type="string14" semanticType="String"/> + <field name="NewPassword" id="925" type="string14" semanticType="String"/> + <field name="EncryptedPasswordMethod" id="1400" type="uint8" description="This should be an enum but values undefined." + semanticType="int"/> + <field name="EncryptedPasswordLen" id="1401" type="uint8" semanticType="Length"/> + <field name="EncryptedNewPasswordLen" id="1403" type="uint8" semanticType="Length"/> + <field name="RawDataLength" id="95" type="uint8" semanticType="Length"/> + <data name="EncryptedPassword" id="1402" type="rawData" semanticType="data"/> + <data name="EncryptedNewPassword" id="1404" type="rawData" semanticType="data"/> + <data name="RawData" id="96" type="rawData" semanticType="data"/> +</message>
It is not always practical to update all message publishers and consumers simultaneously. Within certain constraints, message schemas and wire formats can be extended in a controlled way. Consumers using an older version of a schema should be compatible if interpretation of added fields or messages is not required for business processing.
This specification only details compatibility at the presentation layer. It does not relieve application developers of any responsibility for carefully planning a migration strategy and for handling exceptions at the application layer.
Compatibility is only ensured under these conditions:
Fields may be added to either the root of a message or to a repeating group, but in each case, they must be appended to end of a block.
Existing fields cannot change data type or move within a message.
A repeating group may be added after existing groups at the root level or nested within another repeating group.
A variable-length data field may be added after existing variable-length data at the root level or within a repeating group.
Message header encoding cannot change.
In general, metadata changes such as name or description corrections do not break compatibility so long as wire format does not change.
Changes that break those constraints require consumers to update to the current schema used by publishers. An message template that has changed in an incompatible way must be assinged a new template “id” attribute.
The <messageSchema> root element contains a version number attribute. By default, version is zero, the initial version of a message schema. Each time a message schema is changed, the version number is incremented.
Version applies to the schema as a whole, not to individual elements. Version is sent in the message header so the consumer can determine which version of the message schema was used to encode the message.
See section 4.3.1 above for schema attributes.
When a new field, enumeration value, group or message is added to a message schema, the extension may be documented by adding a sinceVersion attribute to the element. The sinceVersion attribute tells in which schema version the element was added. This attribute remains the same for that element for the lifetime of the schema. This attribute is for documentation purposes only, it is not sent on the wire.
Over time, multiple extensions may be added to a message schema. New fields must be appended following earlier extensions. By documenting when each element was added, it possible to verify that extensions were appended in proper order.
The length of the root level of the message may optionally be documented on a <message> element in the schema using the blockLength attribute. See section 4.5.3 above for message attributes. If not set in the schema, block length of the message root is the sum of its field lengths. Whether it is set in the schema or not, the block length is sent on the wire to consumers.
Likewise, a repeating group has a blockLength attribute to tell how much space is reserved for group entries, and the value is sent on the wire. It is encoded in the schema as part of the NumInGroup field encoding. See section 3.4.8.2 above.
A message schema may document obsolete elements, such as messages, fields, and valid values of enumerations with deprecated attribute. Updated applications should not publish deprecated messages or values, but declarations may remain in the message schema during a staged migration to replacement message layouts.
The length of the root level of the message is sent on the wire in the SBE message header. See section 3.2.2 above. Therefore, if new fields were appended in a later version of the schema, the consumer would still know how many octets to consume to find the next message element, such as repeating group or variable-length Data field. Without the current schema version, the consumer cannot interpret the new fields, but it does not break parsing of earlier fields.
Likewise, block size of a repeating group is conveyed in the NumInGroup encoding.
Message headers and repeating group dimensions carry a count of the number of repeating groups and a count of variable-length data fields on the wire. This supports a walk by a decoder of all the elements of a message, even when the decoder was built with an older version of a schema. As for added fixed-length fields, new repeating groups cannot be interpreted by the decoder, but it still can process the ones it knows, and it can correctly reach the end of a message.
This suggested strategy is non-normative.
A message decoder compares the schema version in a received message header to the version that the decoder was built with.
If the received version is equal to the decoder’s version, then all fields known to the decoder may be parsed, and no further analysis is required.
If the received version is greater than the decoder’s version (that is, the producer’s encoder is newer than the consumer’s decoder), then all fields known to the decoder may be parsed but it will be unable to parse added fields.
Also, an old decoder may encounter unexpected enumeration values. The application layer determines whether an unexpected value is a fatal error. Probably so for a required field since the business meaning is unknown, but it may choose to allow an unknown value of an optional field to pass through. For example, if OrdType value J=“Market If Touched” is added to a schema, and the consumer does not recognize it, then the application returns an order rejection with reason “order type not supported”, even if it does not know what “J” represents. Note that this is not strictly a versioning problem, however. This exception handling is indistinguishable from the case where “J” was never added to the enum but was simply sent in error.
If the received version is less than the decoder’s version (that is, the producer’s encoder is older than the consumer’s decoder), then only the fields of the older version may be parsed. This information is available through metadata as “sinceVersion” attribute of a field. If sinceVersion is greater than received schema version, then the field is not available. How a decoder signals an application that a field is unavailable is an implementation detail. One strategy is for an application to provide a default value for unavailable fields.
Initial version of a message schema
<messageSchema package="FIXBinaryTest" byteOrder="littleEndian"> + <types> + <type name="int8" primitiveType="int8"/> + </types> + +<message name="FIX Binary Message1" id="1" blockLength="4"> + <field name="Field1" id="1" type="int8" semanticType="int"/> +</message> + +</messageSchema>
Second version - a new message is added
<messageSchema package="FIXBinaryTest" byteOrder="littleEndian" + version="1"> + +<types> + <type name="int8" primitiveType="int8"/> + <type name="int16" primitiveType="int16" + sinceVersion="1"/> +</types> + +<message name="FIX Binary Message1" id="1" blockLength="4"> + <field name="Field1" id="1" type="int8" semanticType="int"/> +</message> + +<!-- New message added in this version--> +<message name="FIX Binary Message2" id="2" blockLength="4" + sinceVersion="1"> + <field name="Field2" id="2" type="int16" semanticType="int"/> +</message> +</messageSchema>
Third version - a field is added
<messageSchema package="FIXBinaryTest" byteOrder="littleEndian" + version="2"> + +<types> + <type name="int8" primitiveType="int8"/> + <type name="int16" primitiveType="int16" + sinceVersion="1"/> + <type name="int32" primitiveType="int32" + sinceVersion="2"/> +</types> + +<message name="FIX Binary Message1" id="1" blockLength="8"> + <field name="Field1" id="1" type="int8" semanticType="int"/> + <field name="Field11" id="11" type="int32" semanticType="int" + sinceVersion="2"/> +</message> + +<message name="FIX Binary Message2" id="2" blockLength="4" + sinceVersion="1"> + <field name="Field2" id="2" type="int16" semanticType="int"/> +</message> +</messageSchema>
FIX specifies request and entity identifiers as String type. Common practice is to specify an identifier field as fixed-length character of a certain size.
Optionally, a message schema may restrict such identifiers to numeric encodings.
Example of an identifier field with character encoding
<type name="idString" primitiveType="char" length="16" /> + +<field name="QuoteReqId" id="131" type="idString" + semanticType="String"/>
Example of an identifier field with numeric encoding
<type name="uint64" primitiveType="uint64" /> + +<field name="QuoteReqId" id="131" type="uint64" + semanticType="String"/>
The example messages are preceded by Simple Open Framing Header. Note that SOFH encoding is always big-endian, regardless of the byte order of the SBE message body. See that FIX standard for details.
Not all FIX enumeration values are listed in the samples.
This is an example of a simple, flat order message without repeating groups or variable-length data.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> + +<sbe:messageSchema + xmlns:sbe="http://fixprotocol.io/2016/sbe" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + package="Examples" id="100" + description="Test dictionary" + byteOrder="littleEndian" + xsi:schemaLocation="http://fixprotocol.io/2016/sbe sbe.xsd"> + +<types> + <type name="enumEncoding" primitiveType="char"/> + <type name="idString" length="8" primitiveType="char" semanticType="String"/> + <type name="timestampEncoding" primitiveType="uint64" semanticType="UTCTimestamp"/> + + <composite name="messageHeader"> + <type name="blockLength" primitiveType="uint16"/> + <type name="templateId" primitiveType="uint16"/> + <type name="schemaId" primitiveType="uint16"/> + <type name="version" primitiveType="uint16"/> + </composite> + + <composite name="optionalDecimalEncoding" + description="Optional decimal with constant exponent"> + <type name="mantissa" presence="optional" primitiveType="int64"/> + <type name="exponent" presence="constant" primitiveType="int8">-3</type> + </composite> + + <composite name="qtyEncoding" description="Decimal constrained to integers"> + <type name="mantissa" primitiveType="int32"/> + <type name="exponent" presence="constant" primitiveType="int8">0</type> + </composite> + + <enum name="ordTypeEnum" encodingType="enumEncoding"> + <validValue name="Market" description="Market">1</validValue> + <validValue name="Limit" description="Limit">2</validValue> + <validValue name="Stop" description="Stop Loss">3</validValue> + <validValue name="StopLimit" description="Stop Limit">4</validValue> + </enum> + + <enum name="sideEnum" encodingType="enumEncoding"> + <validValue name="Buy" description="Buy">1</validValue> + <validValue name="Sell" description="Sell">2</validValue> + </enum> + +</types> + +<sbe:message name="NewOrderSingle" id="99" blockLength="54" +semanticType="D"> + <field name="ClOrdID" id="11" type="idString" description="Customer Order ID" + offset="0" semanticType="String"/> + <field name="Account" id="1" type="idString" description="Account mnemonic" + offset="8" semanticType="String"/> + <field name="Symbol" id="55" type="idString" description="Security ID" + offset="16" semanticType="String"/> + <field name="Side" id="54" type="sideEnum" description="Side" offset="24" + semanticType="char"/> + <field name="TransactTime" id="60" type="timestampEncoding" + description="Order entry time" offset="25" semanticType="UTCTimestamp"/> + <field name="OrderQty" id="38" type="qtyEncoding" description="Order quantity" + offset="33" semanticType="Qty"/> + <field name="OrdType" id="40" type="ordTypeEnum" description="Order type" + offset="37" semanticType="char"/> + <field name="Price" id="44" type="optionalDecimalEncoding" + description="Limit price" offset="38" semanticType="Price"/> + <field name="StopPx" id="99" type="optionalDecimalEncoding" + description="Stop price" offset="46" semanticType="Price"/> +</sbe:message> + +</sbe:messageSchema>
Notes on the message schema
In this case, there is a lot of verbiage for one message, but in practice, a schema would define a set of messages. The same encodings within the <types> element would be used for a whole collection of messages. For example, a price encoding need only be defined once but can be used in any number of messages in a schema. Many of the attributes, such as description, offset, and semanticType, are optional but are shown here for a full illustration.
All character fields in the message are fixed-length. Values may be shorter than the specified field length, but not longer. Since all fields are fixed-length, they are always in a fixed position, supporting direct access to data.
An enumeration gives the valid values of a field. Both enumerations in the example use character encoding, but note that some enumerations in FIX are of integer type.
There are two decimal encodings. The one used for quantity sets the exponent to constant zero. In effect there is no fractional part and only the mantissa is sent on the wire, acting as an integer. However, FIX defines Qty as a float type since certain asset classes may use fractional shares.
The other decimal encoding is used for prices. The exponent is constant -3. In essence, each price is transmitted as an integer on the wire with assumed three decimal places. Each of the prices in the message is conditionally required. If OrdType=Limit, then Price field required. If OrdType=Stop then StopPx is required. Otherwise, if OrdType=Market, then neither price is required. Therefore, the price takes an optional encoding. To indicate that it is null, a special value is sent on the wire. See the table in section 2.4.2 above for the null value of the int64 mantissa.
In this example, all fields are packed without special byte alignment. Performance testing may prove better results with a different arrangement of the fields or adjustments to field offsets. However, those sorts of optimizations are platform dependent.
Hexadecimal and ASCII representations (little-endian byte order):
00 00 00 44 eb 50 36 00 63 00 5b 00 00 00 4f 52 : D P6 c [ OR +44 30 30 30 30 31 41 43 43 54 30 31 00 00 47 45 :D00001ACCT01 GE +4d 34 00 00 00 00 31 80 16 b3 3b 13 65 29 15 07 :M4 1 ; e) +00 00 00 32 1a 85 01 00 00 00 00 00 00 00 00 00 : 2 +00 00 00 80
Interpretation
00000044
eb50
3600
6300
5b00
0000
4f52443030303031
4143435430310000
47454d3400000000
31
8016b33b13652915
07000000
32
1a85010000000000
0000000000000080
This is an example of a message with a repeating group.
Add this encoding types element to those in the previous example.
<types> + <type name="date" primitiveType="uint16" semanticType="LocalMktDate"/> + <composite name="MONTH_YEAR" semanticType="MonthYear"> + <type name="year" primitiveType="uint16"/> + <type name="month" primitiveType="uint8"/> + <type name="day" primitiveType="uint8"/> + <type name="week" primitiveType="uint8"/> + </composite> + + <composite name="groupSizeEncoding" description="Repeating group dimensions"> + <type name="blockLength" primitiveType="uint16" + semanticType="Length"/> + <type name="numInGroup" primitiveType="uint16" + semanticType="NumInGroup"/> + </composite> + + <enum name="execTypeEnum" encodingType="enumEncoding"> + <validValue name="New" description="New">0</validValue> + <validValue name="DoneForDay" description="Done for day">3</validValue> + <validValue name="Canceled" description="Canceled">4</validValue> + <validValue name="Replaced" description="Replaced">5</validValue> + <validValue name="PendingCancel">6</validValue> + <validValue name="Rejected" description="Rejected">8</validValue> + <validValue name="PendingNew" description="Pending New">A</validValue> + <validValue name="Trade" description="partial fill or fill">F</validValue> + </enum> + + <enum name="ordStatusEnum" encodingType="enumEncoding"> + <validValue name="New" description="New">0</validValue> + <validValue name="PartialFilled">1</validValue> + <validValue name="Filled" description="Filled">2</validValue> + <validValue name="DoneForDay" description="Done for day">3</validValue> + <validValue name="Canceled" description="Canceled">4</validValue> + <validValue name="PendingCancel">6</validValue> + <validValue name="Rejected" description="Rejected">8</validValue> + <validValue name="PendingNew" description="Pending New">A</validValue> + <validValue name="PendingReplace" >E</validValue> + </enum> + +</types> + +<sbe:message name="ExecutionReport" id="98" blockLength="42" +semanticType="8"> + <field name="OrderID" id="37" type="idString" description="Order ID" + offset="0" semanticType="String"/> + <field name="ExecID" id="17" type="idString" description="Execution ID" + offset="8" semanticType="String"/> + <field name="ExecType" id="150" type="execTypeEnum" + description="Execution type" offset="16" semanticType="char"/> + <field name="OrdStatus" id="39" type="ordStatusEnum" + description="Order status" offset="17" semanticType="char"/> + <field name="Symbol" id="55" type="idString" description="Security ID" + offset="18" semanticType="String"/> + <field name="MaturityMonthYear" id="200" type="MONTH_YEAR" + description="Expiration" offset="26" semanticType="MonthYear"/> + <field name="Side" id="54" type="sideEnum" description="Side" offset="31" + semanticType="char"/> + <field name="LeavesQty" id="151" type="qtyEncoding" + description="Quantity open" offset="32" semanticType="Qty"/> + <field name="CumQty" id="14" type="qtyEncoding" + description="Executed quantity" offset="36" semanticType="Qty"/> + <field name="TradeDate" id="75" type="date" + description="Trade date" offset="40" semanticType="LocalMktDate"/> + <group name="FillsGrp" id="2112" description="Partial fills" + blockLength="12" dimensionType="groupSizeEncoding"> + <field name="FillPx" id="1364" type="optionalDecimalEncoding" + description="Price of partial fill" offset="0" semanticType="Price"/> + <field name="FillQty" id="1365" type="qtyEncoding" + description="Executed quantity" offset="8" semanticType="Qty"/> + </group> +</sbe:message>
The message contains a MonthYear field. It is encoded as a composite type with year, month, day and week subfields.
This message layout contains a repeating group containing a collection of partial fills for an execution report. The <group> XML tag enclosed the fields within a group entry. The dimensions of the repeating group are encoding as a composite type called groupSizeEncoding.
00 00 00 54 eb 50 2a 00 62 00 5b 00 00 00 4f 30 : T P* b [ O0 +30 30 30 30 30 31 45 58 45 43 30 30 30 30 46 31 :000001EXEC0000F1 +47 45 4d 34 00 00 00 00 de 07 06 ff ff 31 01 00 :GEM4 1 +00 00 06 00 00 00 75 3e 0c 00 02 00 1a 85 01 00 : u> +00 00 00 00 02 00 00 00 24 85 01 00 00 00 00 00 : $ +04 00 00 00 :
Offset is from beginning of block.
00000054
2a00
6200
4558454330303030
30
de0706ffff
01000000
06000000
753e
0c000200
02000000
2485010000000000
04000000
+<types> + <type name="intEnumEncoding" primitiveType="uint8"/> + + <composite name="DATA" description="Variable-length data"> + <type name="length" primitiveType="uint16" /> + <type name="varData" length="0" primitiveType="uint8"> + </composite> + + <enum name="businessRejectReasonEnum" encodingType="intEnumEncoding">> + <validValue name="Other" 0</validValue> + <validValue name="UnknownID" 1</validValue> + <validValue name="UnknownSecurity" >2</validValue> + <validValue name="ApplicationNotAvailable" >4</validValue> + <validValue name="NotAuthorized" >6</validValue> + </enum> + +</types> + + <sbe:message name="BusinessMessageReject" id="97" + blockLength="9" semanticType="j"> + <field name="BusinesRejectRefId" id="379" type="idString" + offset="0" semanticType="String" /> + <field name="BusinessRejectReason" id="380" type="businessRejectReasonEnum" + offset="8" semanticType="int" /> + <data name="Text" id="58" type="DATA" semanticType="data" /> + </sbe:message>
00 00 00 40 eb 50 09 00 61 00 5b 00 00 00 4f 52 : @ P a [ OR +44 30 30 30 30 31 06 27 00 4e 6f 74 20 61 75 74 :D00001 ' Not aut +68 6f 72 69 7a 65 64 20 74 6f 20 74 72 61 64 65 :horized to trade +20 74 68 61 74 20 69 6e 73 74 72 75 6d 65 6e 74 : that instrument
00000040
0900
6100
06
4e6f74206175...
Version 1.0 with Errata – Technical Standard – November 2020
The Financial Information eXchange Simple Binary Encoding (SBE) targets high performance trading systems. It is optimized for low latency of encoding and decoding while keeping bandwidth utilization reasonably small. For compatibility, it is intended to represent all FIX semantics.
In order to support traditional FIX semantics, all the documented field types are supported. However, instead of printable character representations of tag-value encoding, the type system binds to native binary datatypes, and defines derived types as needed.
Usage of native binary datatypes and simple types derived from native binaries, such as prices and timestamps.
Message schemas may be based on standard FIX message specifications or may be customized as needed by agreement between counterparties.
The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.
— IETF RFC 2119 – Key words for use in RFCs to Indicate Requirement Levels March 1997
Simple Open Framing Header, technical specification of a message framing standard for FIX messages.
FIX Latest, normative specification of the application layer of the FIX Protocol.
ISO/IEC 11404:2007 Information technology – General-Purpose Datatypes (GPD)
datatype - A field type with its associated encoding attributes, including backing primitive types and valid values or range. Some types have additional attributes, e.g. epoch of a date.
Encoding - a message format for interchange. The term is commonly used to mean the conversion of one data format to another, such as text to binary. However, Simple Binary Encoding strives to use native binary datatypes in order to make conversion unnecessary, or at least trivial. Encoding also refers to the act of formatting a message, as opposed to decoding.
Session protocol - a protocol concerned with the reliable delivery of messages over a transport. FIX protocol makes a distinction between session protocol and the encoding of a message payload, as described by this document. See the specifications section of the FIX protocol web site for supported protocols.
A field is a unit of data contained by a FIX message. Every field has the following aspects: semantic datatype, encoding, and metadata. They will be specified in more detail in the sections on datatype encoding and message schema but are introduced here as an overview.
The FIX semantic datatype of a field tells a data domain in a broad sense, for example, whether it is numeric or character data, or whether it represents a time or price. Simple Binary Encoding represents all of the semantic datatypes that FIX protocol has defined across all encodings. In message specifications, FIX datatype is declared with attribute semanticType. See the section FIX datatype summary for details.
A datatype is defined as a combination of a value space and a lexical space. Value space is the range of its possible values while lexical space is how those values are represented in a message encoding, in this case SBE. Value space of datatypes is defined using the vocabulary in ISO/IEC 11404:2007 Information technology – General-Purpose Datatypes (GPD). That standard defines types independently of platform and programming language.
Encoding tells how a field of a specific datatype is encoded on the wire. An encoding maps a FIX datatype to either a simple, primitive datatype, such as a 32-bit signed integer, or to a composite type. A composite type is composed of two or more simple primitive types. For example, the FIX datatype Price is encoded as a decimal, a composite type containing a mantissa and an exponent. Note that many fields may share a datatype and an encoding. The sections that follow explain the valid encodings for each datatype.
The FIX semantic datatype and encoding type that it maps to
See section Message Schema for details.
By default, fields are assumed to be required in a message. However, fields may be specified as optional. To indicate that a value is not set, a special null indicator value is sent on the wire. The null value varies according to datatype and encoding. Global defaults for null value may be overridden in a message schema by explicitly specifying the value that indicates nullness.
Schema attributes may restrict the range of valid values for a field. See section Common field schema attributes for details.
Encodings may be added to SBE messages that do not correspond to listed FIX datatypes. In that case, the encoding and fields that use the encoding will not have a semanticType attribute.
Numeric datatypes may be specified by range and signed or unsigned attribute. Integer types are intended to convey common platform primitive datatypes as they reside in memory. An integer type should be selected to hold the maximum range of values that a field is expected to hold.
The default data range and null indicator are listed below for each integer encoding.
See section Message schema attributes for the specification, including byteOrder. Message schema designers should specify the byte order most appropriate to their system architecture and that of their counterparties.
Implementations should support both 32-bit and 64-bit mantissa. The usage depends on the data range that must be represented for a particular application. It is expected that an 8-bit exponent should be sufficient for all FIX uses.
When both mantissa and exponent are sent on the wire for a decimal, the elements are packed by default. However, byte alignment may be controlled by specifying offset of the exponent within the composite encoding. See section Element offset within a composite type for details.
FIX Qty datatype is a float type, but a decimal may be constrained to integer values by setting exponent to zero.
Binary floating point encodings are compatible with IEEE Standard for Floating-Point Arithmetic (IEEE 754-2008). They should be used for floating point numeric fields that do not represent prices or monetary amounts. Examples include interest rates, volatility and dimensionless quantities such as ratios. On the other hand, decimal prices should be encoded as decimals; see section Decimal encoding for details.
Both single and double precision encodings are supported as primitive datatypes. See the IEEE 754-2008 standard for ranges and details of the encodings.
Like integer encodings, floating point encodings follow the byte order specified by message schema. See section Message schema attributes for the specification, including byteOrder.
Character fields hold a single character. They are most commonly used for field with character code enumerations. See section Enumeration encoding for details.
A length attribute set to zero indicates variable length. See section Variable-length string encoding for details.
Data may either be of fixed-length or variable-length. In Simple Binary Encoding, fixed-length data encoding may be used for data of predetermined length, even though it does not represent a FIX datatype. Variable-length encoding should be reserved for raw data when its length is not known until run-time.
The four subfields of MonthYear are packed at an octet level by default. However, byte alignment may be controlled by specifying offset of the elements within the composite encoding. See section Element offset within a composite type for details.
MonthYear datatype is based on a composite encoding that carries its required and optional elements.
Time specifications use an enumeration of time units. See section Enumeration encoding for details.
004047baa145fb17
0010d74916220000
The subfields of TZTimestamp are packed at an octet level by default. However, byte alignment may be controlled by specifying offset of the elements within the composite encoding. See section Element offset within a composite type for details.
Wire format of TZTimestamp 8:30 17 September 2013 with Chicago time zone offset (-6:00) and nanosecond timeunit
0050d489fea2241309fa00
The subfields of TZTimeOnly are packed at an octet level by default. However, byte alignment may be controlled by specifying offset of the elements within the composite encoding. See section Element offset within a composite type for details.
If a field is of FIX datatype char, then its valid values are restricted to US-ASCII printable characters. See section Character for details.
If the field is of FIX datatype int, then a primitive integer datatype should be selected that can contain the number of choices. For most cases, an 8-bit integer will be sufficient, allowing 255 possible values.
Enumerations of other datatypes, such as String valid values specified in FIX, should be mapped to an integer wire format in SBE.
In-line style: the value of encodingType is its primitive datatype.
Like other integer-backed encodings, multi-value encodings follow the byte order specified by message schema when serializing to the wire. See section Message schema attributes for the specification, including byteOrder.
The purpose of the message encoding header is to tell which message template was used to encode the message and to give information about the size of the message body to aid in decoding, even when a message template has been extended in a later version. See section Schema Extension Mechanism for details.
Block length is specified in a message schema, but it is also serialized on the wire. By default, block length is set to the sum of the sizes of body fields in the message. However, it may be increased to force padding at the end of block. See section Padding at end of a message or group for details.
The message header is encoded in the same byte order as the message body, as specified in a message schema. See section Message schema attributes for the specification.
The total space reserved for the root level of the message not counting any repeating groups or variable-length fields. (Repeating groups have their own block length; see section Repeating groups for details. Length of a variable-length Data field is given by its corresponding Length field; see section Variable-length string encoding for details.) Block length only represents message body fields; it does not include the length of the message header itself, which is a fixed size.
The identifier of a message type in a message schema. See section Message schema attributes for the specification.
The identifier of a message schema. See section Message schema attributes for the specification.
The version number of the message schema that was used to encode a message. See section Message schema attributes for the specification.
Each group is associated with a required counter field of semantic data type NumInGroup to tell how many entries are contained by a message. The value of the counter is a non-negative integer. See section Encoding of repeating group dimensions for details.
The number of entries may be restricted to a specific range; see section Restricting repeating group entries for details.
Aside from message schema validations (see section Schema validation), these validations apply to message structure.
The byteOrder attribute controls the byte order of integer and float encodings within the schema. It is a global setting for all specified messages and their encodings.
In this example, a Price is encoded as 32-bit integer mantissa and a constant exponent, which is not sent on the wire.
In this example, a futuresPrice is encoded as 64-bit integer mantissa, 8-bit exponent, and a reused enum type.
This enumeration is encoded as an 8-bit unsigned integer value. Others are encoded as char codes.
Multi-value choice example, the choice is encoded as a bitset.
Fields are added to a <message> element as child elements. See section Field Encoding for a listing of all field types.
<group> element inherits attributes of blockType. See <message> element above.
See section Message schema attributes for the specification.
The length of the root level of the message may optionally be documented on a <message> element in the schema using the blockLength attribute. See section Message element attributes for details. If not set in the schema, block length of the message root is the sum of its field lengths. Whether it is set in the schema or not, the block length is sent on the wire to consumers.
Likewise, a repeating group has a blockLength attribute to tell how much space is reserved for group entries, and the value is sent on the wire. It is encoded in the schema as part of the NumInGroup field encoding. See section Encoding of repeating group dimensions for details.
The length of the root level of the message is sent on the wire in the SBE message header. See section Root block length for details. Therefore, if new fields were appended in a later version of the schema, the consumer would still know how many octets to consume to find the next message element, such as repeating group or variable-length Data field. Without the current schema version, the consumer cannot interpret the new fields, but it does not break parsing of earlier fields.
Also, an old decoder may encounter unexpected enumeration values. The application layer determines whether an unexpected value is a fatal error. Probably so for a required field since the business meaning is unknown, but it may choose to allow an unknown value of an optional field to pass through. For example, if OrdType(40)=J (Market If Touched (MIT)) is added to a schema, and the consumer does not recognize it, then the application returns an order rejection with reason “order type not supported”, even if it does not know what “J” represents. Note that this is not strictly a versioning problem, however. This exception handling is indistinguishable from the case where “J” was never added to the enum but was simply sent in error.
The other decimal encoding is used for prices. The exponent is constant -3. In essence, each price is transmitted as an integer on the wire with assumed three decimal places. Each of the prices in the message is conditionally required. If OrdType(40)=2 (Limit), then the field Price(44) is required. If OrdType(40)=3 (Stop/Stop Loss) then StopPx(99) is required. Otherwise, if OrdType(40)=1 (Market), then neither price is required. Therefore, the price fields take an optional encoding. To indicate that it is null, a special value is sent on the wire. See the table in section Range attributes for integer fields for the null value of the int64 mantissa.
00b863e7343d2a15
+<types> + <type name="intEnumEncoding" primitiveType="uint8"/> + + <composite name="DATA" description="Variable-length data"> + <type name="length" primitiveType="uint16" /> + <type name="varData" length="0" primitiveType="uint8"> + </composite> + + <enum name="businessRejectReasonEnum" encodingType="intEnumEncoding">> + <validValue name="Other">0</validValue> + <validValue name="UnknownID">1</validValue> + <validValue name="UnknownSecurity">2</validValue> + <validValue name="ApplicationNotAvailable">4</validValue> + <validValue name="NotAuthorized">6</validValue> + </enum> + +</types> + + <sbe:message name="BusinessMessageReject" id="97" + blockLength="9" semanticType="j"> + <field name="BusinessRejectRefID" id="379" type="idString" + offset="0" semanticType="String" /> + <field name="BusinessRejectReason" id="380" type="businessRejectReasonEnum" + offset="8" semanticType="int" /> + <data name="Text" id="58" type="DATA" semanticType="String" /> + </sbe:message>