WebSockets
Account Updates WebSocket
Real-time WebSocket API for account updates, P&L candles, watchlists, and news on a single authenticated connection.
WSS
What this stream gives you. Open one connection to
wss://api.aries.com/v1/accounts/ws, authenticate, and the server will push updates whenever anything changes on your trading account - an order fills, a position is opened or closed, your buying power moves, news drops on a stock you hold, or a watchlist gets edited on another device. You get the same live picture a brokerage app would show, without polling.Key Features
Key Features
Order Status Updates
Real-time notifications when orders are placed, filled, partially filled, or cancelled. Track order lifecycle with millisecond latency.
Position Changes
Live updates when positions are opened, modified, or closed. Monitor both stock and option positions in real-time.
Balance Updates
Instant account balance updates including buying power, equity, cash movements, and margin changes.
P&L Candles
Real-time profit/loss candles at various intervals (
15s, 1m, 5m, 15m, 1h, 1d, 1mo) for performance tracking.Watchlist Updates
Live synchronization for the authenticated user’s watchlists. Each update carries the latest full watchlist state.
News Feed
Real-time news updates relevant to your portfolio and watchlist symbols.
Connection
Connection
Endpoint
Connect to the accounts WebSocket endpoint for all account-related streams (orders, positions, balances, P&L candles, watchlist updates, and news):Production:wss://api.aries.com/v1/accounts/wsMigration: If you were using wss://api.ariesfinancial.com/ws, update to the URL above.After connecting, authenticate within 5 seconds, then subscribe to the topics you need: account, pnl, watchlist, or news.Authentication & Security
Authentication & Security
Authentication Required
All connections must use WSS (WebSocket Secure) protocol. Each user receives only their own account updates, ensuring data privacy and security.Session Management
Sessions expire after 65 minutes (3900000ms). The server:- Sends a refresh warning 5 minutes before expiration
- Closes the connection when the session expires
- Requires re-authentication after expiration
Security Best Practices
- Always use WSS in production
- Store JWT tokens securely
- Implement automatic re-authentication on expiration warnings
- Monitor connection status and implement reconnection logic
Subscription Topics
Subscription Topics
Each topic is a separate stream - subscribe only to what your app needs.Account Updates (
One subscription covers everything that happens on a trading account:
P&L Candles (
A live time-series of your account’s profit-and-loss, broken into “candles” of a fixed length (just like price candles on a chart). Useful for plotting equity curves and intraday performance.Supported intervals - choose the candle length that matches your dashboard:
Watchlist Updates (
Returns the authenticated user’s current watchlists immediately after you subscribe. After that, every watchlist event carries the latest full watchlist array, so your app can replace local watchlist state without reconstructing add or remove operations.Requires: Nothing extra. Send only
News Updates (
Pushes news articles in real time.Requires:
Subscribe request object
Every subscribe message uses the same top-level shape:Account Updates (account)
One subscription covers everything that happens on a trading account:- Orders - order status changes as your orders move through the system (see the full status list below).
- Positions - when a position is opened, increased, reduced, or closed, for both stocks and options.
- Balance - buying power, equity, margin, and cash movements.
- Account info - changes to the account record itself (type, options level, etc.).
accountId in params - the ID of the account you want to subscribe to.Initial snapshot: Right after you subscribe, the server sends a snapshot containing current account/balance fields, all open positions, legacy orders, and the new ordersV2 list, so you start with the full state.P&L Candles (pnl)
A live time-series of your account’s profit-and-loss, broken into “candles” of a fixed length (just like price candles on a chart). Useful for plotting equity curves and intraday performance.Supported intervals - choose the candle length that matches your dashboard:Requires:
accountId and startTime (an RFC3339 timestamp marking how far back to start the series) in params. interval is optional and defaults to 1m.Watchlist Updates (watchlist)
Returns the authenticated user’s current watchlists immediately after you subscribe. After that, every watchlist event carries the latest full watchlist array, so your app can replace local watchlist state without reconstructing add or remove operations.Requires: Nothing extra. Send only payload.topic = "watchlist". The backend ties the subscription to your authenticated user, not to a specific account.News Updates (news)
Pushes news articles in real time.Requires: payload.topic = "news".Optional params:symbols- array of tickers to filter by, for example["AAPL", "TSLA"]. Live news subscriptions are filtered by symbol.topics- array of topic strings, for example["earnings"]. The backend accepts this on subscribe and uses it when it fetches the initial news snapshot. Live push filtering is still symbol-based.
Connection Management
Connection Management
Ping/Pong Keepalive
Send periodic pings to keep the WebSocket connection alive and detect network issues:Recommendation: Send a ping every 30-60 seconds to maintain connection health.Handling Disconnects
Always implement reconnection logic with exponential backoff:- Start with 1 second delay
- Double the delay on each retry (2s, 4s, 8s)
- Cap maximum delay at 60 seconds
- Re-authenticate after reconnection
Connection States
Monitor the connection state and handle state transitions gracefully in your application.
Use Cases
Use Cases
Trading Applications
Real-time order status for trading platforms. Display live order fills, rejections, and modifications.
Portfolio Monitoring
Track position changes, P&L, and balance updates for portfolio management dashboards.
Risk Management
Monitor buying power, margin levels, and position sizes in real-time for risk control systems.
Order Notifications
Push notifications to mobile apps when orders are filled or positions change.
Performance Analytics
Real-time P&L candles for performance tracking and analytics dashboards.
News Alerts
Real-time news feed integration for trading signals and market sentiment analysis.
Message Flow
Message Flow
Best Practices
Best Practices
Performance Optimization
- Subscribe once per account to
accounttopic to receive all account events - Use specific intervals for P&L candles based on your needs
- Implement batching for handling high-frequency updates
- Store state locally to avoid unnecessary re-subscriptions
Reliability
- Monitor connection health with periodic pings (30-60 second intervals)
- Implement exponential backoff for reconnections
- Handle session expiration proactively using refresh warnings
- Store subscription state to restore after reconnection
Security
- Rotate tokens periodically
- Use environment variables for connection URLs and tokens
- Log authentication events for audit trails
- Validate all incoming messages before processing
Development
- Use development environment for testing
- Test failure scenarios (disconnects, authentication failures, malformed messages)
- Monitor bandwidth usage in production
- Implement message queuing for high-volume scenarios
Authentication
Authenticate Connection
Authentication must be completed within 5 seconds of connection establishment.Authentication Success Response
expiresIn field indicates session duration in milliseconds (65 minutes = 3900000ms).
Subscribing to Updates
Subscribe to Account Updates
Subscribe to all account-level updates including orders, positions, balance, and account information.Account Updates
Account Updates
Subscribe to All Account Updates
Get orders, positions, balance, and account info for a specific account:Response with Initial Snapshot
The server responds with asubscribed message containing current account state. Decimal values are serialized as JSON strings.The initial snapshot includes merged
account and balance fields, positions, legacy orders, and ordersV2. After this, you’ll receive real-time event messages as changes occur.P&L Candles
P&L Candles
Watchlist & News
Watchlist & News
Subscribe to Watchlist Updates
Get notified when symbols are added, updated, or removed from watchlists:Subscribe to News Updates
Receive real-time news. You can optionally filter by symbol:params entirely to receive all news without filtering.Watchlist subscription response
The server confirms the watchlist subscription with the user’s current watchlists:Watchlist and news subscriptions are user-level and don’t require an account ID. The
watchlist topic returns the full current watchlist array on subscribe and on every later update.Payload Data Types
Real-Time Update Messages
Once subscribed, the server pushesevent messages as data changes.
Order Updates
Receive notifications when order status changes.- Stock Order
- Option Spread
Order Filled
ordStatus Values
The order status field is ordStatus. These are the full set of states an order can be in over its lifetime:
Order field enums
Order event payloads contain several enum fields. Here’s the full vocabulary you’ll see across stocks and options:side - direction of the trade:
type - order type, i.e. how the order is priced:
timeInForce - how long the order stays alive:
securityType / instrument - what asset class:
putCall (options only): CALL or PUT.
positionEffect (options only): OPEN (creates/increases a position) or CLOSE (reduces/closes one).
Position Updates
Receive notifications when positions change.- Stock Position
- Option Position
Long Stock Position
Position updates emit primary fields
avgPrice, todayRealizedPnL, and securityType. The backend also emits backward-compatible aliases avgCost, realizedPL, and instrument.Balance Updates
The account topic can also emit
account.balance.apex. That event is a partial Apex-sourced balance update and currently carries accountId, fullyPaidUnsettledFunds, amountAvailableToWithdraw, and updatedAt. Clients should merge that payload into their latest balance state instead of treating it as a full balance snapshot.Account-level enums
The account-info and account snapshot messages include a few enum fields. Here are the full sets of values you may see:accountType - how the account is funded and settled:
accountClass - who owns the account:
optionsLevel - what option strategies the account is approved for. Higher levels unlock more complex (and risky) strategies:
Account Info Updates
P&L Candle Updates
Watchlist Updates
Watchlist events do not send item-by-item patches. Each event contains the latest full watchlist array for the authenticated user.News Updates
Unsubscribing from Updates
Stop receiving updates for specific topics.Connection Management
Ping/Pong Keepalive
Send periodic pings to maintain connection health and detect network issues. Ping Request:Session Expiration
Refresh Warning (5 minutes before expiration):Error Handling
Error Response Format
All errors follow this format:Common Error Scenarios
Authentication Errors
Authentication Errors