-
Notifications
You must be signed in to change notification settings - Fork 2
SBE 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.

-
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 CTS-Base-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 payload decoder and extract the message.
-
Further we get each value of the payload decoder 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.

- Using the example of EiCreateTenderPayload, we can use the SBE-generated toString() method to interpret the raw ByteBuffer into a human-readable format. We can then compare this against the toString() output of the original Java payload object to verify that the encoding and decoding processes preserve data integrity.

- This hex dump and decoded layout represent a serialized
EiCreateTenderPayloadmessage using SBE. Each field is mapped to its byte range and decoded value, verifying that the encoded buffer matches the expected payload structure. The expiration time and interval timestamps confirm proper Instant encoding, while fields likeside,quantity, andpricedemonstrate that numeric and enum types are correctly represented. TheFull Raw Buffershows the actual bytes transmitted over the wire. This output can be used to visually validate correctness of the encoding process at a low level.

- We benchmarked EiCreateTenderPayload using both JSON and Simple Binary Encoding (SBE). SBE completed 1 million operations in 190.99ms (0.19µs/op), while JSON took 6635.37ms (6.64µs/op)—showing SBE is nearly 35x faster. These results validate our SBE encoder/decoder implementation, highlighting major improvements in speed, memory efficiency, and suitability for high-performance energy market messaging in EML-CTS.
- 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