developers:websocket:accounts

This is an old revision of the document!


Account Feed

The Account Feed provides real-time updates on account status, positions, and order activity. Before receiving updates, accounts must first be subscribed.

The list of available accounts is included in the LoginResult message. To begin receiving updates, clients must send an AccountSubscribe message. Multiple accounts can be subscribed in a batch.

Example AccountSubscribe message for three accounts:

AccountSubscribe {
   Subscribe = AccountSubscribeType.Subscribe,
   SubscribeAllAccounts = false,
   AccountId = [
      "2a4b6c8d-9e10-11ea-bb37-0242ac130002",
      "3d5e7f9g-9e10-11ea-bb37-0242ac130003",
      "4f6h8j0k-9e10-11ea-bb37-0242ac130004"
   ]
}

Once subscribed, the server will begin streaming real-time updates for the selected accounts.

The AccountSnapshot message is a batch message that contains the latest state of an account including:

  • Account balances
  • Open positions
  • Working orders

The server sends account-related updates as separate messages. These include:

  • AccountDetails – Provides static information about the account.
  • AccountUpdate – Sends real-time updates for account values.
  • AccountPosition – Reports current open positions.
  • AccountSnapshot – A batch message containing the latest state of the account.
  • OrderUpdateMulti – Sends batch updates for a position.

Example message handling structure:

```csharp
private void HandleAccountMessage(ServerMessage serverMessage)
{
    switch (serverMessage.PayloadCase)
    {
        case ServerMessage.PayloadOneofCase.AccountSubscribeResponse:
            _logger.LogInformation("Received account subscribe response. Success: {Success}", serverMessage.AccountSubscribeResponse.Success);
            serverMessage.AccountSubscribeResponse.Errors.ToList().ForEach(e => _logger.LogWarning(" * " + e));
            break;

        case ServerMessage.PayloadOneofCase.AccountDetails:
            ProcessAccountDetails(serverMessage.AccountDetails);
            _logger.LogInformation("Received account details: {AccountId}", serverMessage.AccountDetails.AccountId);
            break;

        case ServerMessage.PayloadOneofCase.AccountUpdate:
            ProcessAccountUpdate(serverMessage.AccountUpdate);
            _logger.LogInformation("Received account update: {AccountId}", serverMessage.AccountUpdate.AccountId);
            break;

        case ServerMessage.PayloadOneofCase.AccountPosition:
            ProcessAccountPosition(serverMessage.AccountPosition);
            _logger.LogInformation("Received account position: {AccountId}, Market: {MarketId}", serverMessage.AccountPosition.AccountId, serverMessage.AccountPosition.MarketId);
            break;

        case ServerMessage.PayloadOneofCase.AccountSnapshot:
            ProcessAccountSnapshot(serverMessage.AccountSnapshot);
            _logger.LogInformation("Received account snapshot: {AccountId}", serverMessage.AccountSnapshot.AccountId);
            break;

        case ServerMessage.PayloadOneofCase.OrderUpdateMulti:
            ProcessOrderUpdateMulti(serverMessage.OrderUpdateMulti);
            _logger.LogInformation("Received order update multi: {AccountId}", serverMessage.OrderUpdateMulti.AccountId);
            break;

        case ServerMessage.PayloadOneofCase.MarketDetails:
            ProcessMarketDetails(serverMessage.MarketDetails);
            _logger.LogInformation("Received market details: {MarketId}", serverMessage.MarketDetails.MarketId);
            break;

        default:
            _logger.LogWarning("Unhandled Account Message: {PayloadCase}", serverMessage.PayloadCase);
            break;
    }
}
  • developers/websocket/accounts.1741993892.txt.gz
  • Last modified: 2025/03/14 23:11
  • by chad