developers:websocket

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
developers:websocket [2025/03/14 02:56] chaddevelopers:websocket [2025/03/14 19:15] (current) – [Message Structure Overview] chad
Line 1: Line 1:
-====== Getting Started ======+===== WebSocket API Introduction =====
  
-To begin integratingvisit the [[getting_started|Getting Started]] guide for **connection details, authentication steps, and demo projects**.+The WebSocket API provides a high-performancelow-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:** 
 +  * Persistent connection reduces handshake overhead 
 +  * Low-latencyreal-time data exchange 
 +  * Efficient bandwidth usage compared to REST APIs 
 + 
 +==== 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?** 
 +  * **Compact Encoding:** Reduces message size for faster transmission 
 +  * **High Performance:** Faster serialization/deserialization than JSON 
 +  * **Schema Evolution:** Backward-compatible changes allow for future expansion without breaking existing clients 
 + 
 +==== Communication Model ==== 
 +The API follows a structured messaging approach: 
 +  * **Client Messages:** Requests sent from clients to the server (e.g., order submission, subscription requests) 
 +  * **Server Messages:** Responses and real-time updates sent from the server (e.g., trade confirmations, market data) 
 + 
 +==== 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**: 
 + 
 +<code> 
 +message ClientMessage { 
 +  oneof payload { 
 +    AuthenticationRequest authentication_request = 1; 
 +    MarketSubscription market_subscription = 2; 
 +    OrderRequest order_request = 3; 
 +    // ... other client messages 
 +  } 
 +
 +</code> 
 + 
 +=== 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**: 
 + 
 +<code> 
 +message ServerMessage { 
 +  oneof payload { 
 +    AuthenticationResponse authentication_response = 1; 
 +    MarketSnapshot market_snapshot = 2; 
 +    OrderUpdate order_update = 3; 
 +    // ... other server messages 
 +  } 
 +
 +</code> 
 + 
 + 
 +=== Message Tools === 
 + 
 +The [[https://github.com/CTS-Futures/t4-api-tools|T4 API Tools repository]] has code that makes wrapping messages from your client very easy. 
 + 
 +<bootnote> 
 +Reach out to support if you would like a API tool's for a language we have not covered yet. 
 +</bootnote> 
 + 
 +^ **Platform** ^ **Client Message Helper** ^ 
 +| **.Net** | [[https://github.com/CTS-Futures/t4-api-tools|ClientMessageHelper.cs]]|
  
-For a detailed breakdown of all available messages, see the [[message_reference|Message Reference]]. 
  
----- 
  
-💡 **Tip:** Use WebSocket clients like `wscat` or our sample SDKs to test the API before building your integration. 
  
  
-===== Next Steps ===== 
-  * Connect and Authenticate to **market data streams** ([[api:websocket:connecting|Connecting and Authenticating]]). 
  
  • developers/websocket.1741920969.txt.gz
  • Last modified: 2025/03/14 02:56
  • by chad