Table of Contents

WebSocket API Introduction

The WebSocket API provides a high-performance, low-latency communication channel for real-time trading data and order execution. This section introduces the key technologies used in the API: WebSockets and Google Protocol Buffers (Protobuf).

WebSockets

WebSockets establish a persistent, full-duplex connection between the client and server, allowing for continuous bi-directional message exchange. This ensures minimal latency, making it ideal for market data feeds and order updates.

Key Advantages:

Google Protocol Buffers (Protobuf)

The API utilizes Protobuf for efficient, compact, and high-speed message serialization. Unlike JSON or XML, Protobuf messages are smaller and faster to parse, making them well-suited for high-frequency trading applications.

Why Protobuf?

Communication Model

The API follows a structured messaging approach:

Message Structure Overview

All messages sent to the server must be wrapped in a ClientMessage envelope, and all messages received from the server will be contained within a ServerMessage envelope. This ensures a consistent structure and simplifies message parsing.

Client Message Structure

A ClientMessage is the top-level wrapper for all messages sent to the server. It contains fields for various message types, such as authentication requests, order submissions, and subscription requests.

Example ClientMessage:

message ClientMessage {
  oneof payload {
    AuthenticationRequest authentication_request = 1;
    MarketSubscription market_subscription = 2;
    OrderRequest order_request = 3;
    // ... other client messages
  }
}

Server Message Structure

A ServerMessage is the top-level wrapper for all responses and updates from the server. It encapsulates messages related to market data, account updates, and execution reports.

Example ServerMessage:

message ServerMessage {
  oneof payload {
    AuthenticationResponse authentication_response = 1;
    MarketSnapshot market_snapshot = 2;
    OrderUpdate order_update = 3;
    // ... other server messages
  }
}

Message Tools

The T4 API Tools repository has code that makes wrapping messages from your client very easy.

Note: Reach out to support if you would like a API tool's for a language we have not covered yet.

Platform Client Message Helper
.Net ClientMessageHelper.cs