This is an old revision of the document!
I'll help you create a comprehensive Message Reference page for your Dokuwiki in the correct syntax. Let's start with the Client/Server Message Envelopes and Login Messages sections.
T4 Protocol Message Reference
This document provides a reference for all messages in the T4 Protocol. The protocol uses Protocol Buffers (protobuf) for message serialization.
Client/Server Message Envelopes
All communication in the T4 Protocol is done via a pair of envelope messages: ClientMessage
(client to server) and ServerMessage
(server to client). These messages encapsulate all other message types using Protocol Buffers' oneof field.
ClientMessage
The ClientMessage
is sent from the client to the server and can contain any of the following payloads:
Field | Type | Description |
---|---|---|
heartbeat | Heartbeat | A simple heartbeat to maintain connection |
login_request | LoginRequest | Authentication request |
market_depth_subscribe | MarketDepthSubscribe | Request to subscribe to market depth data |
market_by_order_subscribe | MarketByOrderSubscribe | Request to subscribe to market by order data |
account_subscribe | AccountSubscribe | Request to subscribe to account data |
order_submit | OrderSubmit | Submit a new order |
order_revise | OrderRevise | Modify an existing order |
order_pull | OrderPull | Cancel an existing order |
create_uds | CreateUDS | Create a user-defined strategy |
ServerMessage
The ServerMessage
is sent from the server to the client and can contain any of the following payloads:
Field | Type | Description |
---|---|---|
heartbeat | Heartbeat | A simple heartbeat to maintain connection |
login_response | LoginResponse | Authentication response |
market_depth_subscribe_reject | MarketDepthSubscribeReject | Rejection of market depth subscription |
market_by_order_subscribe_reject | MarketByOrderSubscribeReject | Rejection of market by order subscription |
market_details | MarketDetails | Details about a market |
market_depth | MarketDepth | Market depth data |
market_depth_trade | MarketDepthTrade | Trade data for a market |
market_high_low | MarketHighLow | High/low prices for a market |
market_price_limits | MarketPriceLimits | Price limits for a market |
market_settlement | MarketSettlement | Settlement data for a market |
market_snapshot | MarketSnapshot | Complete snapshot of a market |
market_by_order_snapshot | MarketByOrderSnapshot | Complete snapshot of order book |
market_by_order_update | MarketByOrderUpdate | Update to the order book |
account_subscribe_response | AccountSubscribeResponse | Response to account subscription |
account_currency | AccountCurrency | Account currency information |
account_position | AccountPosition | Position data for an account |
account_update | AccountUpdate | Update to account data |
account_details | AccountDetails | Detailed account information |
account_snapshot | AccountSnapshot | Complete snapshot of account data |
order_update | OrderUpdate | Update to an order |
order_update_multi | OrderUpdateMulti | Multiple order updates |
order_update_failed | OrderUpdateFailed | Failed order update |
order_update_status | OrderUpdateStatus | Order status update |
order_update_trade | OrderUpdateTrade | Trade update for an order |
order_update_trade_leg | OrderUpdateTradeLeg | Trade leg update for a complex order |
create_uds_response | CreateUDSResponse | Response to user-defined strategy creation |
Heartbeat
The Heartbeat
message is used to maintain an active connection between client and server.
Field | Type | Description |
---|---|---|
timestamp | int64 | UTC timestamp in milliseconds |
Login Messages (auth.proto)
LoginRequest
The LoginRequest
message is used to authenticate with the server. It supports either API key authentication or username/password authentication.
Field | Type | Description |
---|---|---|
api_key | string | API key for authentication (if used, this is the only required field) |
firm | string | Firm name/identifier for username/password authentication |
username | string | Username for authentication |
password | string | Password for authentication |
app_name | string | Application name |
app_license | string | Application license key |
LoginResponse
The LoginResponse
message is the server's response to a login request.
Field | Type | Description |
---|---|---|
result | LoginResult | Result of the login attempt |
session_id | string | Session identifier for the authenticated session |
user_id | string | User identifier |
firm_id | string | Firm identifier |
roles | repeated string | List of roles the user has |
error_message | string | Error message if login failed |
exchanges | repeated Exchange | List of exchanges the user has access to |
accounts | repeated Account | List of accounts the user has access to |
LoginResponse.Exchange
The Exchange
message inside LoginResponse contains details about an exchange the user has access to.
Field | Type | Description |
---|---|---|
exchange_id | string | Exchange identifier |
user_id | string | User identifier for this exchange |
market_data_type | MarketDataType | Type of market data available |
has_executing_account | bool | Whether the user has an executing account on this exchange |
primary_user_id | string | Primary user identifier |
secondary_user_id | string | Secondary user identifier |
location | string | Location identifier |
smp_id | string | SMP identifier |
extra_detail | map<string, string> | Additional exchange-specific details |
LoginResponse.Account
The Account
message inside LoginResponse contains details about an account the user has access to.
Field | Type | Description |
---|---|---|
account_id | string | Account identifier |
account_number | string | Account number |
account_name | string | Account name |
display_name | string | Display name for the account |
mode | AccountMode | Account mode |
LoginResult Enum
The LoginResult
enum defines possible results of a login attempt.
Value | Description |
---|---|
LOGIN_RESULT_SUCCESS | Login successful |
LOGIN_RESULT_FAILED | Login failed |
LOGIN_RESULT_APPLICATION_NOT_VALID | Application not valid |
LOGIN_RESULT_FIRM_NOT_ALLOWED | Firm not allowed |
LOGIN_RESULT_USER_NOT_ALLOWED | User not allowed |
LOGIN_RESULT_INCORRECT_VERSION | Incorrect version |
LOGIN_RESULT_LOGGED_IN_ELSEWHERE | User already logged in elsewhere |
LOGIN_RESULT_LOGOUT | Logout |
LOGIN_RESULT_UNEXPECTED_DISCONNECT | Unexpected disconnect |
LOGIN_RESULT_UNAUTHORIZED | Unauthorized |
LOGIN_RESULT_UNEXPECTED_ERROR | Unexpected error |
LOGIN_RESULT_ROLE_NOT_SUPPORTED | Role not supported |
LOGIN_RESULT_API_MESSAGE_BACKLOG | API message backlog |
LOGIN_RESULT_SERVER_MESSAGE_BACKLOG | Server message backlog |
LOGIN_RESULT_PASSWORD_EXPIRED | Password expired |
LOGIN_RESULT_PASSWORD_CHANGE_FAILED | Password change failed |
LOGIN_RESULT_PASSWORD_ALREADY_USED | Password already used |
LOGIN_RESULT_LOCKED_OUT | Account locked out |
LOGIN_RESULT_ADDITIONAL_USERS_NOT_ALLOWED | Additional users not allowed |
LOGIN_RESULT_MARKET_DATA_NOT_SETUP | Market data not set up |
LOGIN_RESULT_TWO_FACTOR_NOT_SETUP | Two-factor authentication not set up |
LOGIN_RESULT_TWO_FACTOR_FAILED | Two-factor authentication failed |
LOGIN_RESULT_FIX_SESSION_ERROR | FIX session error |
LOGIN_RESULT_TWO_FACTOR_REQUIRED | Two-factor authentication required |
LOGIN_RESULT_USER_EXISTS | User already exists |
LOGIN_RESULT_UNKNOWN | Unknown error |