Skip to main content
Private channels deliver account-level data including balances, positions, orders, and algorithmic orders. They require API credentials and the client handles authentication automatically on connection.

Configuration

Provide your API credentials in the accounts array when constructing the client.
All three credential fields — apiKey, apiSecret, and apiPass — are required for authentication. Missing any of them will cause an error when the private connection is opened.

Auto-authentication

Authentication is triggered automatically when the private WebSocket connection is established. You do not need to call any login method manually. When you call subscribe() with a private channel, the client:
1

Opens the connection

The private WebSocket connection is opened if it is not already active.
2

Authenticates

A signed login request is sent using your API credentials. The signature uses timestamp + 'GET' + '/users/self/verify' with HMAC-SHA256.
3

Subscribes

Once authentication succeeds, the subscription request is sent.
You can optionally call connectPrivate() early to warm up the connection before subscribing:

Event listeners

Set up all event listeners before subscribing.

Private channels

Account

Streams changes to account balance and related information.

Positions

Balance and Position

Combines balance and position data in one channel.

Orders

Algo Orders

Liquidation Warning

Account Greeks

Options greeks for the account.

Withdrawal Info

Grid Orders

Multiple accounts

You can authenticate multiple accounts on a single WebsocketClient instance by adding more entries to the accounts array. Each account is authenticated independently and account-level data from all accounts arrives on the same update event.

Handling authentication failures

Authentication errors arrive on the exception event. To prevent an infinite reconnect loop when credentials are invalid, close the connection explicitly:
If you do not handle authentication errors, the client will attempt to reconnect automatically after each failure. With invalid credentials this creates a continuous reconnect loop. Always check for error code 60005 and close the connection if credentials are bad.
Before establishing a private WebSocket connection, consider making a lightweight REST API call (such as fetching account balance) to verify your credentials are valid. This is safer than discovering bad credentials after the WebSocket connects.

Batch subscriptions