-
Notifications
You must be signed in to change notification settings - Fork 2
Simple Binary Encoding Quick Guide
SBE is designed by FIX Trading company, which is industry standard trading protocol designed for high frequency trading.
The SBE Tool does not have a dedicated Maven plugin. So we need to add few dependencies and configurations as follows:
- Insert the agrona dependency in the pom.xml file to allow maven to run SBE.
<dependency>
<groupId>org.agrona</groupId>
<artifactId>agrona</artifactId>
<version>1.9.0</version>
</dependency>
- Add the configuration in the pom.xml file as mentioned below, we use sbe 1.20.4 version in our project.

- Refer how to add plugins in maven project.
-
To use SBE tool we need to define the SBE message schema, which is an XML file.
-
SBE message schema contains the structure of the SBE message and defines all the possible attributes Marketpayloads-sbe.xml
-
We define the encode method, in which we use an unsafe buffer to encode the message and message header encoder to encode all the attributes of the message into a single SBE message.
-
To decode we use unsafebuffer to wrap the message into payloaddecoder and extract the message.
-
Further we get each value of the payloaddecoder and create transaction payload.
-
TEUA creates a tender by updating EiCreateTenderPayload.java
-
Encode method in TeuaRestController.java tries to encode the message using byte buffers and sent it using resttemplate which is received at LmaRestcontroller.java
-
This SBE message is decoded at lmaRestcontroller using SBE Decoder method.
-
SBE message is encoded at LmaRestController.java and sent to LmeRestController.java by using EiCreateTenderPayload.java
-
This communication between TEUA and LMA is performed using resttemplate And the following flow Chart illustrates how SBE works.

-
When marketcreatetenderpayload.java is created encode method in SBEEncoderDecoder.java encodes the message using unsafebuffer and MarketCreateTenderPayloadEncoder to encode the message.
-
This message is received by the CTSSocketServer.java which decodes the message using MarketcreatetenderpayloadDecoder
-
If there is a match then CTSSocketClient.java will create an matchnumber along with parityorderId.
-
This communication between LmesocketClient - CTSSocketServer is performed using serversocket.

-
Validation of SBE messages is performed at every hop from creating a tender to finding a match and responding back with match id. We can achieve this by printing the message at every hop before encoding the message and after decoding the message.
-
To print the message we use toString method in payloads classes under controllers.
-
This will help us to track the message at every step, sample snapshot as follows.

- Now if we cross verify we can validate the message at the encoder end. and the decoder end to validate the message.

- FIX trading protocol, SBE detailed synopsis
- SBE dependencies are not pre-defined in Maven, so we need to add few dependencies and configurations in pom.xml file. click here for step by step.
Code Documentation
- Actor Pseudocode - LMA, LMM, TEUA
- RESTful Controller Payloads
- Position Manager
- Logging
- Time in CTS
- UML and Java Classes
- Simple Binary Encoding (SBE)
- SBE Quick Guide
- Auction Market
Building and Running the Project
- Setup Run and Drive - with YouTube videos
- Dependencies and Prerequisites
- Set Up MySQL
- Parity Terminal Client
- Project Build Steps
- In Case of Difficulty
Docker
- Docker Background
- Docker Setup Requirements
- Docker Setup Part 1
- Docker Setup Part 2
- Running EML-CTS as a Single Executable JAR
- Docker Quick Guide
General Tech Guides
Spring 2024 Updates