> ## Documentation Index
> Fetch the complete documentation index at: https://finance.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Account Updates WebSocket

> Real-time WebSocket API for account updates, P&L candles, watchlists, and news on a single authenticated connection.

<Note>
  **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.
</Note>

<AccordionGroup>
  <Accordion title="Key Features" icon="star" defaultOpen>
    <CardGroup cols={2}>
      <Card title="Order Status Updates" icon="list-check">
        Real-time notifications when orders are placed, filled, partially filled, or cancelled. Track order lifecycle with millisecond latency.
      </Card>

      <Card title="Position Changes" icon="chart-pie">
        Live updates when positions are opened, modified, or closed. Monitor both stock and option positions in real-time.
      </Card>

      <Card title="Balance Updates" icon="wallet">
        Instant account balance updates including buying power, equity, cash movements, and margin changes.
      </Card>

      <Card title="P&L Candles" icon="chart-candlestick">
        Real-time profit/loss candles at various intervals (`15s`, `1m`, `5m`, `15m`, `1h`, `1d`, `1mo`) for performance tracking.
      </Card>

      <Card title="Watchlist Updates" icon="eye">
        Live synchronization for the authenticated user's watchlists. Each update carries the latest full watchlist state.
      </Card>

      <Card title="News Feed" icon="newspaper">
        Real-time news updates relevant to your portfolio and watchlist symbols.
      </Card>
    </CardGroup>
  </Accordion>

  <Accordion title="Connection" icon="plug">
    ### 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/ws`

    **Migration:** 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`.
  </Accordion>

  <Accordion title="Authentication & Security" icon="shield-check">
    ### Authentication Required

    <Warning>
      Send a **request** message to **POST /auth** with your token in `payload.body`:

      **Auth request example:**

      ```json theme={null}
      {
        "type": "request",
        "id": "auth-001",
        "payload": {
          "method": "POST",
          "path": "/auth",
          "body": {
            "token": "YOUR_ACCESS_TOKEN"
          }
        }
      }
      ```

      Authentication is **required** and must be completed within 5 seconds of connection. This WebSocket contains sensitive account information and requires a valid JWT token.
    </Warning>

    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
  </Accordion>

  <Accordion title="Subscription Topics" icon="filter">
    Each topic is a separate stream - subscribe only to what your app needs.

    ### Subscribe request object

    Every subscribe message uses the same top-level shape:

    ```json theme={null}
    {
      "type": "subscribe",
      "id": "req-001",
      "payload": {
        "topic": "account|pnl|watchlist|news",
        "params": {}
      }
    }
    ```

    | Topic       | What to send in `payload`                                                                    | Required fields                        | Optional fields                   | Notes                                                                                                              |
    | ----------- | -------------------------------------------------------------------------------------------- | -------------------------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
    | `account`   | `{ "topic": "account", "params": { "accountId": "..." } }`                                   | `params.accountId`                     | None                              | The backend verifies access to one trading account.                                                                |
    | `pnl`       | `{ "topic": "pnl", "params": { "accountId": "...", "startTime": "...", "interval": "1m" } }` | `params.accountId`, `params.startTime` | `params.interval`                 | `interval` defaults to `1m` if omitted. `startTime` must be RFC3339.                                               |
    | `watchlist` | `{ "topic": "watchlist" }`                                                                   | None                                   | None                              | Do not send `accountId`. The backend uses the authenticated user from the WebSocket session.                       |
    | `news`      | `{ "topic": "news", "params": { ... } }`                                                     | None                                   | `params.symbols`, `params.topics` | Both filters are optional. `topics` affects the initial snapshot fetch; live pushed news is still symbol-filtered. |

    ### 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.).

    **Requires:** `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:

    | Interval | Candle length | Typical use                     |
    | -------- | ------------- | ------------------------------- |
    | `15s`    | 15 seconds    | Very granular intraday tracking |
    | `1m`     | 1 minute      | Default - intraday equity curve |
    | `5m`     | 5 minutes     | Smoother intraday view          |
    | `15m`    | 15 minutes    | Half-day / full-day view        |
    | `1h`     | 1 hour        | Multi-day view                  |
    | `1d`     | 1 day         | Daily P\&L history              |
    | `1mo`    | 1 month       | Long-term performance           |

    **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.
  </Accordion>

  <Accordion title="Connection Management" icon="plug">
    ### 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

    | State               | Description                                    |
    | ------------------- | ---------------------------------------------- |
    | **Connected**       | WebSocket connection established               |
    | **Authenticated**   | Successfully authenticated, ready to subscribe |
    | **Subscribed**      | Actively receiving updates                     |
    | **Refresh Warning** | Session expiring in 5 minutes                  |
    | **Expired**         | Session expired, connection closing            |

    <Info>
      Monitor the connection state and handle state transitions gracefully in your application.
    </Info>
  </Accordion>

  <Accordion title="Use Cases" icon="lightbulb">
    <CardGroup cols={2}>
      <Card title="Trading Applications" icon="arrow-right-arrow-left">
        Real-time order status for trading platforms. Display live order fills, rejections, and modifications.
      </Card>

      <Card title="Portfolio Monitoring" icon="chart-line">
        Track position changes, P\&L, and balance updates for portfolio management dashboards.
      </Card>

      <Card title="Risk Management" icon="shield-halved">
        Monitor buying power, margin levels, and position sizes in real-time for risk control systems.
      </Card>

      <Card title="Order Notifications" icon="bell">
        Push notifications to mobile apps when orders are filled or positions change.
      </Card>

      <Card title="Performance Analytics" icon="chart-pie">
        Real-time P\&L candles for performance tracking and analytics dashboards.
      </Card>

      <Card title="News Alerts" icon="newspaper">
        Real-time news feed integration for trading signals and market sentiment analysis.
      </Card>
    </CardGroup>
  </Accordion>

  <Accordion title="Message Flow" icon="diagram-project">
    ### Connection Lifecycle

    ```mermaid theme={null}
    sequenceDiagram
        participant Client
        participant Server

        Client->>Server: Connect to WebSocket
        Note over Server: Wait up to 5 seconds
        Client->>Server: Send Auth Request
        Server->>Client: Auth Success (type: event, action: authSuccess)

        Client->>Server: Subscribe (topic: account)
        Server->>Client: Subscribed (type: subscribed, with snapshot)

        loop Real-time Updates
            Server->>Client: Order Updates (type: event, name: account.order)
            Server->>Client: Position Updates (type: event, name: account.position)
            Server->>Client: Balance Updates (type: event, name: account.balance)
        end

        Note over Server: 5 minutes before expiry
        Server->>Client: Refresh Auth Warning (type: event, action: refreshAuth)

        Client->>Server: Ping (type: ping)
        Server->>Client: Pong (type: pong)

        Note over Server: Session expires
        Server->>Client: Auth Expired (type: event, action: authExpired)
        Server->>Client: Close Connection
    ```

    ### Subscription Flow

    1. **Connect** to WebSocket endpoint
    2. **Authenticate** within 5 seconds
    3. **Subscribe** to desired topics
    4. **Receive** the initial snapshot the server returns for the topic you subscribed to
    5. **Stream** real-time updates
    6. **Unsubscribe** when done
    7. **Monitor** session expiration warnings
  </Accordion>

  <Accordion title="Error Handling" icon="triangle-exclamation">
    ### Common Errors

    | Error Code           | Cause                                 | Resolution                                              |
    | -------------------- | ------------------------------------- | ------------------------------------------------------- |
    | `AUTH_REQUIRED`      | Did not authenticate within 5 seconds | Authenticate immediately after connecting               |
    | `INVALID_TOKEN`      | Invalid or expired JWT token          | Generate a new token and re-authenticate                |
    | `MISSING_ACCOUNT_ID` | `accountId` not provided in `params`  | Include `accountId` in subscription params              |
    | `UNKNOWN_TOPIC`      | Invalid subscription topic            | Use valid topic: `account`, `pnl`, `watchlist`, `news`  |
    | `MISSING_START_TIME` | `startTime` not provided for P\&L     | Include an RFC3339 timestamp in `params.startTime`      |
    | `INVALID_INTERVAL`   | Invalid PnL candle interval           | Use: `15s`, `1m`, `5m`, `15m`, `1h`, `1d`, `1mo`        |
    | `ACCESS_DENIED`      | User does not own the account         | Verify the account ID belongs to the authenticated user |

    ### Error Response Format

    ```json theme={null}
    {
      "type": "response",
      "id": "req-002",
      "timestamp": "2024-01-15T10:30:00Z",
      "payload": {
        "status": 400,
        "error": "accountId is required",
        "code": "MISSING_ACCOUNT_ID"
      }
    }
    ```

    <Warning>
      Always implement comprehensive error handling to gracefully handle network issues, authentication failures, and server errors.
    </Warning>
  </Accordion>

  <Accordion title="Best Practices" icon="thumbs-up">
    ### Performance Optimization

    * **Subscribe once** per account to `account` topic 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
  </Accordion>
</AccordionGroup>

## Authentication

### Authenticate Connection

Authentication must be completed within 5 seconds of connection establishment.

```json theme={null}
{
  "type": "request",
  "id": "auth-001",
  "payload": {
    "method": "post",
    "path": "/auth",
    "body": {
      "token": "YOUR_ACCESS_TOKEN"
    }
  }
}
```

### Authentication Success Response

```json theme={null}
{
  "type": "event",
  "payload": {
    "action": "authSuccess",
    "data": {
      "expiresIn": 3900000
    },
    "id": "auth-001",
    "timestamp": 1703001234567
  }
}
```

The `expiresIn` field indicates session duration in milliseconds (65 minutes = 3900000ms).

<Warning>
  If authentication is not completed within 5 seconds, the server will close the connection with an `authTimeout` event.
</Warning>

## Subscribing to Updates

### Subscribe to Account Updates

Subscribe to all account-level updates including orders, positions, balance, and account information.

<AccordionGroup>
  <Accordion title="Account Updates" icon="play" defaultOpen>
    ### Subscribe to All Account Updates

    Get orders, positions, balance, and account info for a specific account:

    ```json theme={null}
    {
      "type": "subscribe",
      "id": "req-002",
      "payload": {
        "topic": "account",
        "params": {
          "accountId": "ACC123456"
        }
      }
    }
    ```

    ### Response with Initial Snapshot

    The server responds with a `subscribed` message containing current account state. Decimal values are serialized as JSON strings.

    ```json theme={null}
    {
      "type": "subscribed",
      "id": "req-002",
      "timestamp": "2024-01-15T10:30:00Z",
      "payload": {
        "status": 200,
        "topic": "account",
        "params": {
          "accountId": "ACC123456"
        },
        "data": {
          "account": {
            "accountNumber": "ACC123456",
            "accountType": "MARGIN",
            "accountClass": "INDIVIDUAL",
            "optionsLevel": "LEVEL_3",
            "cashAvailable": "25155.00",
            "netLiquidity": "50155.00",
            "marginEquity": "50155.00",
            "maintenanceExcess": "17508.50",
            "sma": "25155.00",
            "maintReq": "7646.50",
            "netBuyingPower": "25155.00",
            "stockBuyingPower": "50310.00",
            "dayTradeBuyingPower": "100620.00",
            "optionBuyingPower": "25155.00",
            "totalEquity": "50155.00",
            "pendingOrdersCount": 0
          },
          "positions": [
            {
              "accountId": "ACC123456",
              "symbol": "AAPL",
              "securityType": "EQUITY",
              "qty": "100",
              "avgPrice": "150.45",
              "avgCost": "150.45",
              "unRealizedPL": "155.00",
              "todayRealizedPnL": "0",
              "realizedPL": "0",
              "todayPL": "155.00",
              "instrument": "EQUITY"
            }
          ],
          "orders": [
            {
              "ordId": "ORD-001",
              "clOrdId": "CLIENT-001",
              "accountId": "ACC123456",
              "symbol": "AAPL",
              "side": "BUY",
              "type": "LIMIT",
              "timeInForce": "DAY",
              "qty": "100",
              "price": "150.50",
              "ordStatus": "FILLED"
            }
          ],
          "ordersV2": []
        }
      }
    }
    ```

    <Info>
      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.
    </Info>
  </Accordion>

  <Accordion title="P&L Candles" icon="chart-candlestick">
    ### Subscribe to P\&L Candles

    Track profit/loss at specified intervals. `startTime` is required:

    ```json theme={null}
    {
      "type": "subscribe",
      "id": "req-003",
      "payload": {
        "topic": "pnl",
        "params": {
          "accountId": "ACC123456",
          "interval": "1m",
          "startTime": "2024-01-01T00:00:00Z"
        }
      }
    }
    ```

    ### Supported Intervals

    | Interval | Description |
    | -------- | ----------- |
    | `15s`    | 15 seconds  |
    | `1m`     | 1 minute    |
    | `5m`     | 5 minutes   |
    | `15m`    | 15 minutes  |
    | `1h`     | 1 hour      |
    | `1d`     | 1 day       |
    | `1mo`    | 1 month     |
  </Accordion>

  <Accordion title="Watchlist & News" icon="newspaper">
    ### Subscribe to Watchlist Updates

    Get notified when symbols are added, updated, or removed from watchlists:

    ```json theme={null}
    {
      "type": "subscribe",
      "id": "req-004",
      "payload": {
        "topic": "watchlist"
      }
    }
    ```

    ### Subscribe to News Updates

    Receive real-time news. You can optionally filter by symbol:

    ```json theme={null}
    {
      "type": "subscribe",
      "id": "req-005",
      "payload": {
        "topic": "news",
        "params": {
          "symbols": ["AAPL", "TSLA"],
          "topics": ["earnings"]
        }
      }
    }
    ```

    Omit `params` entirely to receive all news without filtering.

    ### Watchlist subscription response

    The server confirms the watchlist subscription with the user's current watchlists:

    ```json theme={null}
    {
      "type": "subscribed",
      "id": "req-004",
      "timestamp": "2024-01-15T10:30:00Z",
      "payload": {
        "status": 200,
        "topic": "watchlist",
        "data": [
          {
            "id": 101,
            "name": "Core holdings",
            "symbols": ["AAPL", "MSFT", "NVDA"]
          },
          {
            "id": 205,
            "name": "Earnings radar",
            "symbols": ["TSLA", "AMD"]
          }
        ]
      }
    }
    ```

    <Info>
      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.
    </Info>
  </Accordion>
</AccordionGroup>

## Payload Data Types

| Field group                                           | JSON type | Notes                                                                                                               |
| ----------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------- |
| `id`, `topic`, `params.accountId`, enum fields        | string    | Request IDs and topic/account identifiers are strings.                                                              |
| Trading amounts and quantities                        | string    | Decimal fields such as `qty`, `price`, `avgPrice`, `totalEquity`, `PDT`, and P\&L values are serialized as strings. |
| `pendingOrdersCount`                                  | integer   | Count fields remain numeric integers.                                                                               |
| `timestamp`, `createdAt`, `updatedAt`                 | string    | WebSocket envelopes and domain timestamps use RFC3339 strings. Auth event payload timestamps use Unix milliseconds. |
| `expiresIn`, `expiresAt`, `t`                         | integer   | Auth expiry values are Unix milliseconds. P\&L `t` values are Unix seconds.                                         |
| `orders`, `ordersV2`, `positions`                     | array     | Account subscription snapshots return arrays for these fields.                                                      |
| watchlist snapshot and watchlist event `payload.data` | array     | Watchlist subscribe responses and watchlist events both return the full watchlist array.                            |

## Real-Time Update Messages

Once subscribed, the server pushes `event` messages as data changes.

### Order Updates

Receive notifications when order status changes.

<Tabs>
  <Tab title="Stock Order">
    ### Order Filled

    ```json theme={null}
    {
      "type": "event",
      "timestamp": "2024-01-15T10:30:05Z",
      "payload": {
        "topic": "account",
        "name": "account.order",
        "target": "account:ACC123456",
        "data": {
          "ordId": "ORD-12345",
          "clOrdId": "CLIENT-001",
          "accountId": "ACC123456",
          "symbol": "AAPL",
          "side": "BUY",
          "type": "LIMIT",
          "timeInForce": "DAY",
          "qty": "100",
          "price": "150.50",
          "ordStatus": "FILLED",
          "cumQty": "100",
          "leavesQty": "0",
          "avgPrice": "150.45",
          "currency": "USD",
          "exDestination": "MNGDFTE",
          "securityType": "EQUITY",
          "category": "EQUITY",
          "createdAt": "2024-01-15T10:30:00Z",
          "updatedAt": "2024-01-15T10:30:05Z"
        }
      }
    }
    ```
  </Tab>

  <Tab title="Option Spread">
    ### Multi-Leg Option Order

    ```json theme={null}
    {
      "type": "event",
      "timestamp": "2024-01-15T11:00:10Z",
      "payload": {
        "topic": "account",
        "name": "account.order",
        "target": "account:ACC123456",
        "data": {
          "ordId": "ORD-67890",
          "clOrdId": "CLIENT-002",
          "accountId": "ACC123456",
          "symbol": "SPY",
          "side": "BUY",
          "type": "LIMIT",
          "qty": "1",
          "price": "2.50",
          "ordStatus": "PARTIALLY_FILLED",
          "cumQty": "1",
          "avgPrice": "2.48",
          "securityType": "OPTION",
          "category": "MULTI_LEG",
          "legs": [
            {
              "symbol": "SPY",
              "side": "BUY",
              "ratioQty": "1",
              "securityType": "OPTION",
              "maturity": "2024-12-20",
              "strikePrice": "450",
              "positionEffect": "OPEN",
              "putCall": "CALL"
            },
            {
              "symbol": "SPY",
              "side": "SELL",
              "ratioQty": "1",
              "securityType": "OPTION",
              "maturity": "2024-12-20",
              "strikePrice": "460",
              "positionEffect": "OPEN",
              "putCall": "CALL"
            }
          ],
          "createdAt": "2024-01-15T11:00:00Z",
          "updatedAt": "2024-01-15T11:00:10Z"
        }
      }
    }
    ```
  </Tab>
</Tabs>

### `ordStatus` Values

The order status field is `ordStatus`. These are the full set of states an order can be in over its lifetime:

| Status             | What it means                                                                                                           | What to show the user     |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------- | ------------------------- |
| `PENDING_NEW`      | The order is on its way to the exchange but hasn't been accepted yet.                                                   | "Submitting..."           |
| `NEW`              | The exchange has accepted the order and it is live in the book (working but not yet executed).                          | "Working" / "Open"        |
| `PARTIALLY_FILLED` | Some of the order's quantity has executed; the rest is still working. Watch `cumQty` and `leavesQty`.                   | "Partially filled"        |
| `FILLED`           | The entire order quantity has executed. The order is done.                                                              | "Filled" / "Complete"     |
| `PENDING_CANCEL`   | You sent a cancel request; the exchange has not confirmed it yet.                                                       | "Cancelling..."           |
| `CANCELED`         | The order was cancelled (by you, by the system, or by the exchange). It will not execute further.                       | "Cancelled"               |
| `PENDING_REPLACE`  | You sent a modify/replace request; the exchange has not confirmed it yet.                                               | "Modifying..."            |
| `REJECTED`         | The order was refused (bad parameters, insufficient buying power, halted symbol, etc.). It never made it onto the book. | "Rejected" + error reason |
| `EXPIRED`          | The order reached its time-in-force limit without filling (e.g. a `DAY` order that didn't fill before market close).    | "Expired"                 |

### 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:

| Value          | Meaning                                                                        |
| -------------- | ------------------------------------------------------------------------------ |
| `BUY`          | Buying - opening a long position or closing a short.                           |
| `SELL`         | Selling - closing a long position or opening a short.                          |
| `SELL_SHORT`   | Selling shares you do not own (short sale). Subject to short-sale regulations. |
| `BUY_TO_COVER` | Buying back shares to close an existing short position.                        |

**`type`** - order type, i.e. how the order is priced:

| Value           | Meaning                                                                                       |
| --------------- | --------------------------------------------------------------------------------------------- |
| `MARKET`        | Execute immediately at the best available price. No price guarantee.                          |
| `LIMIT`         | Execute only at the specified `price` or better. Price guarantee, no execution guarantee.     |
| `STOP`          | Sits inactive until the stop price is touched, then becomes a market order.                   |
| `STOP_LIMIT`    | Sits inactive until the stop price is touched, then becomes a limit order at the limit price. |
| `TRAILING_STOP` | A stop that follows the market by a fixed dollar or percentage offset.                        |

**`timeInForce`** - how long the order stays alive:

| Value | Meaning                                                                                  |
| ----- | ---------------------------------------------------------------------------------------- |
| `DAY` | Active until the end of today's regular trading session, then cancelled if not filled.   |
| `GTC` | **Good 'Til Cancelled** - stays open until you cancel it (broker may cap at 60-90 days). |
| `IOC` | **Immediate Or Cancel** - fill whatever you can immediately, cancel the rest.            |
| `FOK` | **Fill Or Kill** - fill the entire order immediately, or cancel it entirely.             |
| `GTD` | **Good 'Til Date** - stays open until a specific date you provide.                       |
| `OPG` | At the market open.                                                                      |
| `CLO` | At the market close.                                                                     |

**`securityType` / `instrument`** - what asset class:

| Value       | Meaning                                                           |
| ----------- | ----------------------------------------------------------------- |
| `EQUITY`    | Stock or ETF.                                                     |
| `OPTION`    | Single option contract.                                           |
| `MULTI_LEG` | Multi-leg option order (spread, condor, etc.) - see `legs` array. |

**`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.

<Tabs>
  <Tab title="Stock Position">
    ### Long Stock Position

    ```json theme={null}
    {
      "type": "event",
      "timestamp": "2024-01-15T14:30:00Z",
      "payload": {
        "topic": "account",
        "name": "account.position",
        "target": "account:ACC123456",
        "data": {
          "accountId": "ACC123456",
          "symbol": "AAPL",
          "securityType": "EQUITY",
          "qty": "100",
          "avgPrice": "150.45",
          "avgCost": "150.45",
          "unRealizedPL": "155.00",
          "todayRealizedPnL": "0",
          "realizedPL": "0",
          "todayPL": "155.00",
          "instrument": "EQUITY",
          "createdAt": "2024-01-15T10:30:05Z",
          "updatedAt": "2024-01-15T14:30:00Z"
        }
      }
    }
    ```
  </Tab>

  <Tab title="Option Position">
    ### Long Call Option

    ```json theme={null}
    {
      "type": "event",
      "timestamp": "2024-01-15T14:30:00Z",
      "payload": {
        "topic": "account",
        "name": "account.position",
        "target": "account:ACC123456",
        "data": {
          "accountId": "ACC123456",
          "symbol": "SPY241220C00450000",
          "securityType": "OPTION",
          "qty": "1",
          "avgPrice": "248.00",
          "avgCost": "248.00",
          "unRealizedPL": "12.00",
          "todayRealizedPnL": "0",
          "realizedPL": "0",
          "todayPL": "12.00",
          "instrument": "OPTION",
          "putCall": "CALL",
          "strikePrice": "450",
          "maturity": "2024-12-20",
          "createdAt": "2024-01-15T11:00:10Z",
          "updatedAt": "2024-01-15T14:30:00Z"
        }
      }
    }
    ```
  </Tab>
</Tabs>

<Info>
  Position updates emit primary fields `avgPrice`, `todayRealizedPnL`, and `securityType`. The backend also emits backward-compatible aliases `avgCost`, `realizedPL`, and `instrument`.
</Info>

### Balance Updates

```json theme={null}
{
  "type": "event",
  "timestamp": "2024-01-15T14:30:00Z",
  "payload": {
    "topic": "account",
    "name": "account.balance",
    "target": "account:ACC123456",
    "data": {
      "accountId": "ACC123456",
      "sodPositionsMarketValue": "48000.00",
      "netBuyingPower": "25155.00",
      "stockBuyingPower": "50310.00",
      "dayTradeBuyingPower": "100620.00",
      "optionBuyingPower": "25155.00",
      "dayTradeOvernightRegTBuyingPower": "50310.00",
      "totalEquity": "50155.00",
      "settledFunds": "35000.00",
      "unsettledFunds": "0",
      "heldBackFunds": "0",
      "grossMargin": "15045.00",
      "pendingOrdersMarginRequirements": "0",
      "maintReq": "7646.50",
      "creditMultiplier": "2",
      "pendingOrdersCount": 0,
      "credit": "50000.00",
      "creditRemaining": "25155.00",
      "realizedPL": "0",
      "unRealizedPL": "167.00",
      "SMA": "25155.00",
      "smaCreditRemaining": "25155.00",
      "PDT": "0",
      "pdtCreditRemaining": "100620.00",
      "startOfDayCash": "35000.00",
      "valueBought": "15293.00",
      "valueSold": "0"
    }
  }
}
```

<Info>
  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.
</Info>

**Balance field reference** - decimal values arrive as JSON strings to preserve precision:

| Field                              | What it means                                                                                                                                    |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `accountId`                        | The account this balance update belongs to.                                                                                                      |
| `sodPositionsMarketValue`          | Start-of-day market value of all open positions (i.e. what your holdings were worth when the trading day opened).                                |
| `netBuyingPower`                   | Total purchasing power available right now across all instruments. The most common number to display as "buying power" in a UI.                  |
| `stockBuyingPower`                 | How much you can use specifically to buy stock (typically up to 2x cash on margin).                                                              |
| `dayTradeBuyingPower`              | How much you can use for **same-day** round-trip trades (typically up to 4x equity for pattern day traders). Resets at end of day.               |
| `optionBuyingPower`                | How much you can use to buy options. Options usually require cash, so this is typically lower than stock buying power.                           |
| `dayTradeOvernightRegTBuyingPower` | Day-trade buying power that can also be held overnight under Reg T rules.                                                                        |
| `totalEquity`                      | Cash + market value of positions - margin debit. Your account's net worth.                                                                       |
| `settledFunds`                     | Cash that has fully settled and is freely available (T+1/T+2 has passed).                                                                        |
| `unsettledFunds`                   | Cash from recent sales that hasn't settled yet - usable for most trades, but cash accounts have restrictions.                                    |
| `heldBackFunds`                    | Cash temporarily reserved for pending orders or compliance holds. Not usable.                                                                    |
| `amountAvailableToWithdraw`        | Cash currently available to withdraw from the account.                                                                                           |
| `fullyPaidUnsettledFunds`          | Unsettled funds that are fully paid and tracked separately by the backend.                                                                       |
| `grossMargin`                      | Total amount you have borrowed from the broker on margin.                                                                                        |
| `pendingOrdersMarginRequirements`  | Margin already earmarked for orders that are working but not yet filled.                                                                         |
| `maintReq`                         | **Maintenance requirement** - the minimum equity you must hold to support your current positions. Drop below this and you may get a margin call. |
| `creditMultiplier`                 | How many times your equity you can borrow on standard margin (typically `2`).                                                                    |
| `pendingOrdersCount`               | Number of orders currently working.                                                                                                              |
| `credit`                           | Total margin credit line extended to the account.                                                                                                |
| `creditRemaining`                  | How much of that credit line is still available.                                                                                                 |
| `realizedPL`                       | Cumulative profit/loss from positions that have been **closed**.                                                                                 |
| `unRealizedPL`                     | Profit/loss on positions you currently **hold open** - i.e. paper gains/losses based on current market value.                                    |
| `SMA`                              | **Special Memorandum Account** - a margin-account balance that effectively stores up "extra" buying power from gains. Reg T concept.             |
| `smaCreditRemaining`               | SMA buying power still available.                                                                                                                |
| `PDT`                              | **Pattern Day Trader** flag balance - relates to the four-day-trade rule and the \$25,000 minimum equity requirement under FINRA Rule 4210.      |
| `pdtCreditRemaining`               | Remaining day-trade buying power for a flagged PDT account.                                                                                      |
| `startOfDayCash`                   | Cash balance at the start of today's session. Useful for calculating daily change.                                                               |
| `valueBought`                      | Dollar value of purchases executed today.                                                                                                        |
| `valueSold`                        | Dollar value of sales executed today.                                                                                                            |

### 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:

| Value        | Meaning                                                                         |
| ------------ | ------------------------------------------------------------------------------- |
| `CASH`       | Cash account - trades must be paid for with settled funds; no margin borrowing. |
| `MARGIN`     | Standard margin account - can borrow against equity (subject to Reg T).         |
| `IRA`        | Individual Retirement Account - tax-advantaged, no margin borrowing.            |
| `ROTH_IRA`   | Roth IRA - after-tax retirement account.                                        |
| `RETIREMENT` | Generic retirement account (401k, SEP, etc.).                                   |

**`accountClass`** - who owns the account:

| Value        | Meaning                                    |
| ------------ | ------------------------------------------ |
| `INDIVIDUAL` | Single-person account.                     |
| `JOINT`      | Joint ownership (two or more individuals). |
| `CORPORATE`  | Owned by a corporation.                    |
| `TRUST`      | Owned by a trust.                          |
| `LLC`        | Owned by an LLC.                           |

**`optionsLevel`** - what option strategies the account is approved for. Higher levels unlock more complex (and risky) strategies:

| Value     | What you can trade                                                                            |
| --------- | --------------------------------------------------------------------------------------------- |
| `LEVEL_0` | Not approved for options.                                                                     |
| `LEVEL_1` | Covered calls and cash-secured puts only.                                                     |
| `LEVEL_2` | Adds long calls and long puts (buying options).                                               |
| `LEVEL_3` | Adds spreads (e.g. vertical spreads, iron condors) - defined-risk multi-leg strategies.       |
| `LEVEL_4` | Adds naked option selling - undefined-risk strategies. Requires the highest equity threshold. |

### Account Info Updates

```json theme={null}
{
  "type": "event",
  "timestamp": "2024-01-15T14:30:00Z",
  "payload": {
    "topic": "account",
    "name": "account.info",
    "target": "account:ACC123456",
    "data": {
      "id": "ACC123456",
      "sterlingAccountId": "STERLING-123",
      "apexAccountId": "",
      "fdid": "FDID-123456",
      "description": "John Doe Trading Account",
      "accountType": "MARGIN",
      "accountClass": "INDIVIDUAL",
      "optionsLevel": "LEVEL_3",
      "maintenanceExcess": "17508.50",
      "cashAvailable": "25155.00",
      "exchangeSurplus": "0",
      "accruedCash": "0",
      "netLiquidity": "50155.00",
      "marginEquity": "50155.00",
      "sma": "25155.00",
      "maintReq": "7646.50",
      "email": "john.doe@example.com",
      "cell": "+1234567890",
      "groupId": "TRADING"
    }
  }
}
```

### P\&L Candle Updates

```json theme={null}
{
  "type": "event",
  "timestamp": "2024-01-15T10:30:00Z",
  "payload": {
    "topic": "pnl",
    "data": {
      "accountId": "ACC123456",
      "interval": "1m",
      "t": [1703001000],
      "c": [50155]
    }
  }
}
```

### Watchlist Updates

Watchlist events do not send item-by-item patches. Each event contains the latest full watchlist array for the authenticated user.

```json theme={null}
{
  "type": "event",
  "timestamp": "2024-01-15T14:30:00Z",
  "payload": {
    "topic": "watchlist",
    "data": [
      {
        "id": 101,
        "name": "Core holdings",
        "symbols": ["AAPL", "MSFT", "NVDA", "TSLA"]
      },
      {
        "id": 205,
        "name": "Earnings radar",
        "symbols": ["AMD"]
      }
    ]
  }
}
```

### News Updates

```json theme={null}
{
  "type": "event",
  "timestamp": "2024-01-15T14:30:00Z",
  "payload": {
    "topic": "news",
    "data": {
      "msgType": "add",
      "items": [
        {
          "id": 12345,
          "title": "Fed Announces Rate Decision",
          "news_type": "news",
          "authors": ["Reuters"],
          "timestamp": "2024-01-15T14:30:00Z",
          "symbols": ["SPY", "QQQ"]
        }
      ]
    }
  }
}
```

## Unsubscribing from Updates

Stop receiving updates for specific topics.

<Tabs>
  <Tab title="Account">
    ### Unsubscribe from Account Updates

    ```json theme={null}
    {
      "type": "unsubscribe",
      "id": "req-007",
      "payload": {
        "topic": "account",
        "params": {
          "accountId": "ACC123456"
        }
      }
    }
    ```

    ### Response

    ```json theme={null}
    {
      "type": "response",
      "id": "req-007",
      "timestamp": "2024-01-15T10:30:00Z",
      "payload": {
        "status": 200,
        "data": {
          "unsubscribed": true,
          "topic": "account",
          "accountId": "ACC123456"
        }
      }
    }
    ```
  </Tab>

  <Tab title="Watchlist">
    ### Unsubscribe from Watchlist Updates

    ```json theme={null}
    {
      "type": "unsubscribe",
      "id": "req-008",
      "payload": {
        "topic": "watchlist"
      }
    }
    ```

    ### Response

    ```json theme={null}
    {
      "type": "response",
      "id": "req-008",
      "timestamp": "2024-01-15T10:30:00Z",
      "payload": {
        "status": 200,
        "data": {
          "unsubscribed": true,
          "topic": "watchlist"
        }
      }
    }
    ```
  </Tab>

  <Tab title="News">
    ### Unsubscribe from News Updates

    ```json theme={null}
    {
      "type": "unsubscribe",
      "id": "req-009",
      "payload": {
        "topic": "news"
      }
    }
    ```

    ### Response

    ```json theme={null}
    {
      "type": "response",
      "id": "req-009",
      "timestamp": "2024-01-15T10:30:00Z",
      "payload": {
        "status": 200,
        "data": {
          "unsubscribed": true,
          "topic": "news"
        }
      }
    }
    ```
  </Tab>
</Tabs>

## Connection Management

### Ping/Pong Keepalive

Send periodic pings to maintain connection health and detect network issues.

**Ping Request:**

```json theme={null}
{
  "type": "ping",
  "id": "ping-001"
}
```

**Pong Response:**

```json theme={null}
{
  "type": "pong",
  "id": "ping-001",
  "timestamp": "2024-01-15T10:30:00Z"
}
```

**Recommendation:** Send a ping every 30-60 seconds to keep the connection alive.

### Session Expiration

**Refresh Warning** (5 minutes before expiration):

```json theme={null}
{
  "type": "event",
  "payload": {
    "action": "refreshAuth",
    "data": {
      "expiresIn": 300000,
      "expiresAt": 1703001534567
    },
    "id": "system",
    "timestamp": 1703001234567
  }
}
```

**Session Expired:**

```json theme={null}
{
  "type": "event",
  "payload": {
    "action": "authExpired",
    "data": {
      "error": "session expired"
    },
    "id": "system",
    "timestamp": 1703001234567
  }
}
```

<Warning>
  When you receive a `refreshAuth` warning, you should re-authenticate or be prepared to reconnect. The connection will be closed when the session expires.
</Warning>

## Error Handling

### Error Response Format

All errors follow this format:

```json theme={null}
{
  "type": "response",
  "id": "req-002",
  "timestamp": "2024-01-15T10:30:00Z",
  "payload": {
    "status": 400,
    "error": "accountId is required",
    "code": "MISSING_ACCOUNT_ID"
  }
}
```

### Common Error Scenarios

<AccordionGroup>
  <Accordion title="Authentication Errors" icon="key">
    ### Authentication Timeout

    ```json theme={null}
    {
      "type": "event",
      "payload": {
        "action": "authTimeout",
        "data": {
          "error": "authentication timeout"
        },
        "id": "system",
        "timestamp": 1703001234567
      }
    }
    ```

    **Cause:** Did not authenticate within 5 seconds of connection.

    **Resolution:** Send authentication request immediately after connecting.

    ***

    ### Invalid Token

    ```json theme={null}
    {
      "type": "response",
      "id": "auth-001",
      "timestamp": "2024-01-15T10:30:00Z",
      "payload": {
        "status": 401,
        "error": "token is invalid or expired",
        "code": "INVALID_TOKEN"
      }
    }
    ```

    **Cause:** JWT token is invalid or expired.

    **Resolution:** Generate a new token and re-authenticate.
  </Accordion>

  <Accordion title="Subscription Errors" icon="plug">
    ### Missing Account ID

    ```json theme={null}
    {
      "type": "response",
      "id": "req-002",
      "timestamp": "2024-01-15T10:30:00Z",
      "payload": {
        "status": 400,
        "error": "accountId is required",
        "code": "MISSING_ACCOUNT_ID"
      }
    }
    ```

    **Cause:** `accountId` not provided in `params` for `account` or `pnl` subscription.

    **Resolution:** Include `accountId` in `payload.params`.

    ***

    ### Unknown Topic

    ```json theme={null}
    {
      "type": "response",
      "id": "req-003",
      "timestamp": "2024-01-15T10:30:00Z",
      "payload": {
        "status": 400,
        "error": "unknown subscription topic: badtopic",
        "code": "UNKNOWN_TOPIC"
      }
    }
    ```

    **Cause:** Invalid topic specified.

    **Resolution:** Use valid topics: `account`, `pnl`, `watchlist`, `news`.
  </Accordion>
</AccordionGroup>

## Best Practices

### Reliable Connection Handling

**Implement exponential backoff for reconnections:**

```javascript theme={null}
let reconnectDelay = 1000; // Start with 1 second

function reconnect() {
  setTimeout(() => {
    connectWebSocket();
    reconnectDelay = Math.min(reconnectDelay * 2, 60000); // Cap at 60 seconds
  }, reconnectDelay);
}

ws.onclose = () => {
  console.log('Connection closed, reconnecting...');
  reconnect();
};

ws.onopen = () => {
  reconnectDelay = 1000; // Reset delay on successful connection
  authenticate();
};
```

### Handle Session Expiration

```javascript theme={null}
ws.onmessage = (event) => {
  const msg = JSON.parse(event.data);
  const payload = msg.payload;

  if (msg.type === 'event' && payload|.action === 'refreshAuth') {
    console.log('Session expiring in 5 minutes');
    // Option 1: Get a new token and re-authenticate
    getNewToken().then(token => authenticate(token));

    // Option 2: Prepare to reconnect
    scheduleReconnect();
  }

  if (msg.type === 'event' && payload|.action === 'authExpired') {
    console.log('Session expired, reconnecting...');
    reconnect();
  }
};
```

### Efficient Subscription Management

**Subscribe once to account updates** for all order, position, balance, and account changes:

```javascript theme={null}
// Subscribe to all account events
ws.send(JSON.stringify({
  type: 'subscribe',
  id: 'req-002',
  payload: {
    topic: 'account',
    params: { accountId: 'ACC123456' }
  }
}));
```

### Store State Locally

Keep local state to avoid unnecessary re-subscriptions:

```javascript theme={null}
let subscriptions = new Set();

function subscribe(topic, params) {
  const key = `${topic}:${JSON.stringify(params)}`;

  if (subscriptions.has(key)) {
    console.log('Already subscribed to', topic);
    return;
  }

  ws.send(JSON.stringify({
    type: 'subscribe',
    id: `sub-${Date.now()}`,
    payload: { topic, params }
  }));

  subscriptions.add(key);
}

ws.onclose = () => {
  // Clear subscriptions on disconnect
  subscriptions.clear();
};
```


## AsyncAPI

````yaml asyncapi-specs/account-updates.json accountUpdatesStream
id: accountUpdatesStream
title: Account updates stream
description: >-
  Bidirectional WebSocket endpoint for account updates. Clients connect here to
  authenticate, send subscription requests, and receive real-time account
  updates.
servers:
  - id: production
    protocol: wss
    host: api.aries.com
    bindings: []
    variables: []
address: /v1/accounts/ws
parameters: []
bindings: []
operations:
  - &ref_9
    id: authenticate
    title: Auth Request
    description: Authenticate the WebSocket connection
    type: receive
    messages:
      - &ref_28
        id: authRequest
        contentType: application/json
        payload:
          - name: Authentication Request
            description: Sign in with an access token
            type: object
            properties:
              - name: type
                type: string
                description: Set this to `request` when you authenticate.
                enumValues:
                  - request
                required: true
              - name: id
                type: string
                description: >-
                  Optional. Add your own request ID here if you want it returned
                  in the auth event.
                required: false
              - name: payload
                type: object
                description: Put the auth request details here.
                required: true
                properties:
                  - name: method
                    type: string
                    description: Use `POST` to send the token for authentication.
                    enumValues:
                      - POST
                    required: true
                  - name: path
                    type: string
                    description: Always `/auth`.
                    enumValues:
                      - /auth
                    required: true
                  - name: body
                    type: object
                    description: >-
                      JSON body for `POST /auth`. Put the raw access token
                      directly in `body.token`.
                    required: true
                    properties:
                      - name: token
                        type: string
                        description: Access token for this WebSocket connection.
                        required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - payload
          description: >-
            Sign-in message. Send this first after connecting so the server can
            open your account-updates connection.
          properties:
            type:
              type: string
              enum:
                - request
              description: Set this to `request` when you authenticate.
              example: request
              x-parser-schema-id: <anonymous-schema-1>
            id:
              type: string
              description: >-
                Optional. Add your own request ID here if you want it returned
                in the auth event.
              example: auth-001
              x-parser-schema-id: <anonymous-schema-2>
            payload:
              type: object
              required:
                - method
                - path
                - body
              description: Put the auth request details here.
              properties:
                method:
                  type: string
                  enum:
                    - POST
                  description: Use `POST` to send the token for authentication.
                  example: POST
                  x-parser-schema-id: <anonymous-schema-4>
                path:
                  type: string
                  enum:
                    - /auth
                  description: Always `/auth`.
                  example: /auth
                  x-parser-schema-id: <anonymous-schema-5>
                body:
                  type: object
                  required:
                    - token
                  description: >-
                    JSON body for `POST /auth`. Put the raw access token
                    directly in `body.token`.
                  properties:
                    token:
                      type: string
                      description: Access token for this WebSocket connection.
                      example: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
                      x-parser-schema-id: <anonymous-schema-7>
                  example:
                    token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
                  x-parser-schema-id: <anonymous-schema-6>
              example:
                method: POST
                path: /auth
                body:
                  token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
              x-parser-schema-id: <anonymous-schema-3>
          x-parser-schema-id: AuthRequestPayload
        title: Authentication Request
        description: Sign in with an access token
        example: |-
          {
            "type": "request",
            "id": "auth-001",
            "payload": {
              "method": "post",
              "path": "/auth",
              "body": {
                "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
              }
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: authRequest
    bindings: []
    extensions: &ref_0
      - id: x-parser-unique-object-id
        value: accountUpdatesStream
  - &ref_10
    id: subscribe
    title: Subscribe Request
    description: Subscribe to account updates, P&L candles, watchlist, or news
    type: receive
    messages:
      - &ref_29
        id: subscribeRequest
        contentType: application/json
        payload:
          - name: Subscribe Request
            description: Subscribe to real-time updates
            type: object
            properties:
              - name: type
                type: string
                description: Set this to `subscribe` to start updates for a topic.
                enumValues:
                  - subscribe
                required: true
              - name: id
                type: string
                description: >-
                  Optional. Add your own request ID here if you want it returned
                  in the subscribe reply or error.
                required: false
              - name: payload
                type: object
                description: >-
                  Choose the topic and add any extra values needed for that
                  topic.
                required: true
                properties:
                  - name: topic
                    type: string
                    description: >-
                      Which updates you want: `account`, `pnl`, `watchlist`, or
                      `news`.
                    enumValues:
                      - account
                      - pnl
                      - watchlist
                      - news
                    required: true
                  - name: params
                    type: object
                    description: Extra values for the topic you picked.
                    required: false
                    properties:
                      - name: accountId
                        type: string
                        description: >-
                          Trading account ID. Required for account and pnl
                          topics. Do not send this for watchlist. News
                          subscriptions are user-level and do not require it.
                        required: false
                      - name: interval
                        type: string
                        description: >-
                          Candle interval for pnl topic. Optional; defaults to
                          1m when omitted. Ignored for other topics.
                        enumValues:
                          - 15s
                          - 1m
                          - 5m
                          - 15m
                          - 1h
                          - 1d
                          - 1mo
                        required: false
                      - name: startTime
                        type: string
                        description: >-
                          Start time for `pnl` history. Example:
                          `2024-01-01T00:00:00Z`.
                        required: false
                      - name: symbols
                        type: array
                        description: >-
                          Optional symbol filter for news topic. Ignored for
                          account, pnl, and watchlist.
                        required: false
                        properties:
                          - name: item
                            type: string
                            required: false
                      - name: topics
                        type: array
                        description: >-
                          Optional news topic filter for the first news
                          snapshot. Live pushed news is still filtered by
                          symbol. Ignored for other topics.
                        required: false
                        properties:
                          - name: item
                            type: string
                            required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - payload
          description: Use this message to start updates for a topic.
          properties:
            type:
              type: string
              enum:
                - subscribe
              description: Set this to `subscribe` to start updates for a topic.
              example: subscribe
              x-parser-schema-id: <anonymous-schema-19>
            id:
              type: string
              description: >-
                Optional. Add your own request ID here if you want it returned
                in the subscribe reply or error.
              example: req-002
              x-parser-schema-id: <anonymous-schema-20>
            payload:
              type: object
              description: Choose the topic and add any extra values needed for that topic.
              required:
                - topic
              properties:
                topic:
                  type: string
                  enum:
                    - account
                    - pnl
                    - watchlist
                    - news
                  description: >-
                    Which updates you want: `account`, `pnl`, `watchlist`, or
                    `news`.
                  example: account
                  x-parser-schema-id: <anonymous-schema-22>
                params:
                  type: object
                  description: Extra values for the topic you picked.
                  properties:
                    accountId:
                      type: string
                      description: >-
                        Trading account ID. Required for account and pnl topics.
                        Do not send this for watchlist. News subscriptions are
                        user-level and do not require it.
                      example: ACC123456
                      x-parser-schema-id: <anonymous-schema-24>
                    interval:
                      type: string
                      enum:
                        - 15s
                        - 1m
                        - 5m
                        - 15m
                        - 1h
                        - 1d
                        - 1mo
                      description: >-
                        Candle interval for pnl topic. Optional; defaults to 1m
                        when omitted. Ignored for other topics.
                      example: 1m
                      x-parser-schema-id: <anonymous-schema-25>
                    startTime:
                      type: string
                      format: date-time
                      description: >-
                        Start time for `pnl` history. Example:
                        `2024-01-01T00:00:00Z`.
                      example: '2024-01-01T00:00:00Z'
                      x-parser-schema-id: <anonymous-schema-26>
                    symbols:
                      type: array
                      items:
                        type: string
                        x-parser-schema-id: <anonymous-schema-28>
                      description: >-
                        Optional symbol filter for news topic. Ignored for
                        account, pnl, and watchlist.
                      example:
                        - AAPL
                        - TSLA
                      x-parser-schema-id: <anonymous-schema-27>
                    topics:
                      type: array
                      items:
                        type: string
                        x-parser-schema-id: <anonymous-schema-30>
                      description: >-
                        Optional news topic filter for the first news snapshot.
                        Live pushed news is still filtered by symbol. Ignored
                        for other topics.
                      example:
                        - press_release
                        - news
                      x-parser-schema-id: <anonymous-schema-29>
                  x-parser-schema-id: <anonymous-schema-23>
              example:
                topic: pnl
                params:
                  accountId: ACC123456
                  interval: 1m
                  startTime: '2024-01-01T00:00:00Z'
              x-parser-schema-id: <anonymous-schema-21>
          x-parser-schema-id: SubscribeRequestPayload
        title: Subscribe Request
        description: Subscribe to real-time updates
        example: |-
          {
            "type": "subscribe",
            "id": "req-002",
            "payload": {
              "topic": "account",
              "params": {
                "accountId": "ACC123456"
              }
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribeRequest
    bindings: []
    extensions: *ref_0
  - &ref_11
    id: unsubscribe
    title: Unsubscribe Request
    description: Unsubscribe from updates
    type: receive
    messages:
      - &ref_30
        id: unsubscribeRequest
        contentType: application/json
        payload:
          - name: Unsubscribe Request
            description: Unsubscribe from updates
            type: object
            properties:
              - name: type
                type: string
                description: Set this to `unsubscribe` to stop updates for a topic.
                enumValues:
                  - unsubscribe
                required: true
              - name: id
                type: string
                description: >-
                  Optional. Add your own request ID here if you want it returned
                  in the unsubscribe reply or error.
                required: false
              - name: payload
                type: object
                description: >-
                  Choose the topic to stop and add any extra values needed for
                  that topic.
                required: true
                properties:
                  - name: topic
                    type: string
                    description: >-
                      Topic to unsubscribe from. `account` and `pnl`
                      unsubscribes require `params.accountId`. `watchlist` and
                      `news` unsubscribes do not require params.
                    enumValues:
                      - account
                      - pnl
                      - watchlist
                      - news
                    required: true
                  - name: params
                    type: object
                    description: Extra values for the topic you want to stop.
                    required: false
                    properties:
                      - name: accountId
                        type: string
                        description: >-
                          Trading account ID. Required for account and pnl
                          unsubscribe requests. Do not send for watchlist or
                          news.
                        required: false
                      - name: interval
                        type: string
                        description: >-
                          For `pnl`, which interval to stop. If you leave this
                          empty, the server uses `1m`.
                        enumValues:
                          - 15s
                          - 1m
                          - 5m
                          - 15m
                          - 1h
                          - 1d
                          - 1mo
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - payload
          description: Use this message to stop updates for one topic.
          properties:
            type:
              type: string
              enum:
                - unsubscribe
              description: Set this to `unsubscribe` to stop updates for a topic.
              example: unsubscribe
              x-parser-schema-id: <anonymous-schema-161>
            id:
              type: string
              description: >-
                Optional. Add your own request ID here if you want it returned
                in the unsubscribe reply or error.
              example: req-006
              x-parser-schema-id: <anonymous-schema-162>
            payload:
              type: object
              description: >-
                Choose the topic to stop and add any extra values needed for
                that topic.
              required:
                - topic
              properties:
                topic:
                  type: string
                  enum:
                    - account
                    - pnl
                    - watchlist
                    - news
                  description: >-
                    Topic to unsubscribe from. `account` and `pnl` unsubscribes
                    require `params.accountId`. `watchlist` and `news`
                    unsubscribes do not require params.
                  example: account
                  x-parser-schema-id: <anonymous-schema-164>
                params:
                  type: object
                  description: Extra values for the topic you want to stop.
                  properties:
                    accountId:
                      type: string
                      description: >-
                        Trading account ID. Required for account and pnl
                        unsubscribe requests. Do not send for watchlist or news.
                      example: ACC123456
                      x-parser-schema-id: <anonymous-schema-166>
                    interval:
                      type: string
                      enum:
                        - 15s
                        - 1m
                        - 5m
                        - 15m
                        - 1h
                        - 1d
                        - 1mo
                      description: >-
                        For `pnl`, which interval to stop. If you leave this
                        empty, the server uses `1m`.
                      example: 1m
                      x-parser-schema-id: <anonymous-schema-167>
                  x-parser-schema-id: <anonymous-schema-165>
              example:
                topic: account
                params:
                  accountId: ACC123456
              x-parser-schema-id: <anonymous-schema-163>
          x-parser-schema-id: UnsubscribeRequestPayload
        title: Unsubscribe Request
        description: Unsubscribe from updates
        example: |-
          {
            "type": "unsubscribe",
            "id": "req-006",
            "payload": {
              "topic": "account",
              "params": {
                "accountId": "ACC123456"
              }
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: unsubscribeRequest
    bindings: []
    extensions: *ref_0
  - &ref_12
    id: ping
    title: Ping Request
    description: Send ping to keep connection alive
    type: receive
    messages:
      - &ref_31
        id: pingRequest
        contentType: application/json
        payload:
          - name: Ping
            description: Keep-alive ping
            type: object
            properties:
              - name: type
                type: string
                description: >-
                  Set this to `ping` to check that the connection is still
                  alive.
                enumValues:
                  - ping
                required: true
              - name: id
                type: string
                description: >-
                  Optional. Add your own request ID here if you want it returned
                  in the `pong` reply.
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
          description: >-
            Use this message to check that the WebSocket connection is still
            alive.
          properties:
            type:
              type: string
              enum:
                - ping
              description: Set this to `ping` to check that the connection is still alive.
              example: ping
              x-parser-schema-id: <anonymous-schema-14>
            id:
              type: string
              description: >-
                Optional. Add your own request ID here if you want it returned
                in the `pong` reply.
              example: ping-001
              x-parser-schema-id: <anonymous-schema-15>
          x-parser-schema-id: PingPayload
        title: Ping
        description: Keep-alive ping
        example: |-
          {
            "type": "ping",
            "id": "ping-001"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: pingRequest
    bindings: []
    extensions: *ref_0
  - &ref_13
    id: receiveAuthExpired
    title: Auth Expired
    description: Receive authentication expired notification
    type: send
    messages:
      - &ref_32
        id: authExpired
        contentType: application/json
        payload:
          - name: Authentication Expired
            description: Session has expired
            type: object
            properties:
              - name: type
                type: string
                description: The server sets this to `event` for auth status messages.
                enumValues:
                  - event
                required: false
              - name: payload
                type: object
                required: false
                properties:
                  - name: action
                    type: string
                    description: >-
                      Sign-in result or sign-in status. `authSuccess` means you
                      can start subscribing. `authError` means the token was
                      rejected. The other values are sent by the server as the
                      connection ages.
                    enumValues:
                      - authSuccess
                      - authError
                      - authTimeout
                      - authExpired
                      - refreshAuth
                    required: false
                  - name: data
                    type: object
                    description: Action-specific data
                    required: false
                  - name: id
                    type: string
                    description: >-
                      Request ID from your client message, or `system` if this
                      event was sent by the server on its own.
                    required: false
                  - name: timestamp
                    type: integer
                    description: Unix timestamp in milliseconds
                    required: false
        headers: []
        jsonPayloadSchema: &ref_1
          type: object
          description: Server message about sign-in status.
          properties:
            type:
              type: string
              enum:
                - event
              description: The server sets this to `event` for auth status messages.
              x-parser-schema-id: <anonymous-schema-8>
            payload:
              type: object
              properties:
                action:
                  type: string
                  enum:
                    - authSuccess
                    - authError
                    - authTimeout
                    - authExpired
                    - refreshAuth
                  description: >-
                    Sign-in result or sign-in status. `authSuccess` means you
                    can start subscribing. `authError` means the token was
                    rejected. The other values are sent by the server as the
                    connection ages.
                  x-parser-schema-id: <anonymous-schema-10>
                data:
                  type: object
                  description: Action-specific data
                  x-parser-schema-id: <anonymous-schema-11>
                id:
                  type: string
                  description: >-
                    Request ID from your client message, or `system` if this
                    event was sent by the server on its own.
                  x-parser-schema-id: <anonymous-schema-12>
                timestamp:
                  type: integer
                  description: Unix timestamp in milliseconds
                  x-parser-schema-id: <anonymous-schema-13>
              x-parser-schema-id: <anonymous-schema-9>
          x-parser-schema-id: AuthEventPayload
        title: Authentication Expired
        description: Session has expired
        example: |-
          {
            "type": "event",
            "payload": {
              "action": "authExpired",
              "data": {
                "error": "session expired"
              },
              "id": "system",
              "timestamp": 1703001234567
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: authExpired
    bindings: []
    extensions: *ref_0
  - &ref_14
    id: receiveRefreshAuth
    title: Refresh Auth Warning
    description: Receive sign-in expiring warning
    type: send
    messages:
      - &ref_33
        id: refreshAuth
        contentType: application/json
        payload:
          - name: Refresh Authentication Warning
            description: Session expires soon, re-authentication recommended
            type: object
            properties:
              - name: type
                type: string
                description: The server sets this to `event` for auth status messages.
                enumValues:
                  - event
                required: false
              - name: payload
                type: object
                required: false
                properties:
                  - name: action
                    type: string
                    description: >-
                      Sign-in result or sign-in status. `authSuccess` means you
                      can start subscribing. `authError` means the token was
                      rejected. The other values are sent by the server as the
                      connection ages.
                    enumValues:
                      - authSuccess
                      - authError
                      - authTimeout
                      - authExpired
                      - refreshAuth
                    required: false
                  - name: data
                    type: object
                    description: Action-specific data
                    required: false
                  - name: id
                    type: string
                    description: >-
                      Request ID from your client message, or `system` if this
                      event was sent by the server on its own.
                    required: false
                  - name: timestamp
                    type: integer
                    description: Unix timestamp in milliseconds
                    required: false
        headers: []
        jsonPayloadSchema: *ref_1
        title: Refresh Authentication Warning
        description: Session expires soon, re-authentication recommended
        example: |-
          {
            "type": "event",
            "payload": {
              "action": "refreshAuth",
              "data": {
                "expiresIn": 300000,
                "expiresAt": 1703001534567
              },
              "id": "system",
              "timestamp": 1703001234567
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: refreshAuth
    bindings: []
    extensions: *ref_0
  - &ref_15
    id: receiveOrderUpdate
    title: Order Update
    description: Receive real-time order status updates
    type: send
    messages:
      - &ref_34
        id: orderUpdate
        contentType: application/json
        payload:
          - name: Order Update
            description: Real-time order update
            type: object
            properties:
              - name: type
                type: string
                description: Top-level message type. Always `event` for streaming updates.
                enumValues:
                  - event
                required: false
              - name: timestamp
                type: string
                description: Time when the server sent this event, in RFC3339 format.
                required: false
              - name: payload
                type: object
                description: 'Routing: `topic`, `name`, and `data` for the event.'
                required: false
                properties:
                  - name: topic
                    type: string
                    description: Topic identifier. Always `account` for these events.
                    enumValues:
                      - account
                    required: false
                  - name: name
                    type: string
                    description: Event name
                    enumValues:
                      - account.order
                      - account.position
                      - account.balance
                      - account.balance.apex
                      - account.info
                    required: false
                  - name: target
                    type: string
                    description: Target identifier (e.g. account:ACC123456)
                    required: false
                  - name: data
                    type: object
                    required: false
                    properties:
                      - name: clOrdId
                        type: string
                        description: Client order ID.
                        required: false
                      - name: ordId
                        type: string
                        description: Broker/order ID.
                        required: false
                      - name: origClOrdId
                        type: string
                        description: Original client order ID for replaces/cancels.
                        required: false
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: clientId
                        type: string
                        description: Client/user ID.
                        required: false
                      - name: symbol
                        type: string
                        description: Trading symbol.
                        required: false
                      - name: side
                        type: string
                        description: Order side, for example BUY or SELL.
                        required: false
                      - name: type
                        type: string
                        description: Order type, for example LIMIT or MARKET.
                        required: false
                      - name: timeInForce
                        type: string
                        description: Time in force, for example DAY.
                        required: false
                      - name: qty
                        type: string
                        description: Order quantity serialized as a string.
                        required: false
                      - name: price
                        type: string
                        description: Limit price serialized as a string.
                        required: false
                      - name: stopPrice
                        type: string
                        description: Stop price serialized as a string.
                        required: false
                      - name: ordStatus
                        type: string
                        description: Order status.
                        enumValues:
                          - NEW
                          - PARTIALLY_FILLED
                          - FILLED
                          - DONE_FOR_DAY
                          - CANCELED
                          - REPLACED
                          - PENDING_CANCEL
                          - STOPPED
                          - REJECTED
                          - SUSPENDED
                          - PENDING_NEW
                          - CALCULATED
                          - EXPIRED
                          - ACCEPTED_FOR_BID
                          - PENDING_REPLACE
                          - SUPERSEDED
                        required: false
                      - name: cumQty
                        type: string
                        description: Cumulative filled quantity serialized as a string.
                        required: false
                      - name: leavesQty
                        type: string
                        description: Remaining open quantity serialized as a string.
                        required: false
                      - name: avgPrice
                        type: string
                        description: Average execution price serialized as a string.
                        required: false
                      - name: currency
                        type: string
                        description: Currency code.
                        required: false
                      - name: exDestination
                        type: string
                        description: Execution destination, for example MNGDFTE or MNGD.
                        required: false
                      - name: text
                        type: string
                        description: Broker or venue message.
                        required: false
                      - name: ordRejReason
                        type: string
                        description: Order reject reason when present.
                        required: false
                      - name: securityType
                        type: string
                        description: Security type, for example EQUITY or OPTION.
                        required: false
                      - name: category
                        type: string
                        description: >-
                          Order category, for example EQUITY, SINGLE_LEG, or
                          MULTI_LEG.
                        required: false
                      - name: legs
                        type: array
                        required: false
                        properties:
                          - name: symbol
                            type: string
                            description: Underlying or option symbol.
                            required: false
                          - name: side
                            type: string
                            description: Order side, for example BUY or SELL.
                            required: false
                          - name: ratioQty
                            type: string
                            description: Leg ratio quantity serialized as a string.
                            required: false
                          - name: securityType
                            type: string
                            description: Security type, for example OPTION.
                            required: false
                          - name: maturity
                            type: string
                            description: Option maturity date in YYYY-MM-DD format.
                            required: false
                          - name: strikePrice
                            type: string
                            description: Option strike price serialized as a string.
                            required: false
                          - name: positionEffect
                            type: string
                            description: Position effect, for example OPEN or CLOSE.
                            required: false
                          - name: putCall
                            type: string
                            description: Option side, CALL or PUT.
                            required: false
                          - name: avgPrice
                            type: string
                            description: >-
                              Average fill price for the leg, serialized as a
                              string.
                            required: false
                      - name: execId
                        type: string
                        description: Execution ID for fill events.
                        required: false
                      - name: execType
                        type: string
                        description: >-
                          Execution type, for example NEW, FILL, PARTIAL_FILL,
                          or REJECTED.
                        required: false
                      - name: lastPx
                        type: string
                        description: Last execution price serialized as a string.
                        required: false
                      - name: lastQty
                        type: string
                        description: Last execution quantity serialized as a string.
                        required: false
                      - name: maturity
                        type: string
                        description: >-
                          Flat option maturity when sent on single-leg option
                          orders.
                        required: false
                      - name: putCall
                        type: string
                        description: Flat option side, CALL or PUT.
                        required: false
                      - name: strikePrice
                        type: string
                        description: Flat option strike price serialized as a string.
                        required: false
                      - name: positionEffect
                        type: string
                        description: Flat option position effect.
                        required: false
                      - name: createdAt
                        type: string
                        description: Creation timestamp.
                        required: false
                      - name: updatedAt
                        type: string
                        description: Last update timestamp.
                        required: false
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: symbol
                        type: string
                        description: Equity or OCC option symbol.
                        required: false
                      - name: securityType
                        type: string
                        description: Security type, for example EQUITY or OPTION.
                        required: false
                      - name: qty
                        type: string
                        description: Position quantity serialized as a string.
                        required: false
                      - name: avgPrice
                        type: string
                        description: Average position price serialized as a string.
                        required: false
                      - name: avgCost
                        type: string
                        description: Backward-compatible alias of avgPrice.
                        required: false
                      - name: unRealizedPL
                        type: string
                        description: Unrealized P&L serialized as a string.
                        required: false
                      - name: todayRealizedPnL
                        type: string
                        description: Today realized P&L serialized as a string.
                        required: false
                      - name: realizedPL
                        type: string
                        description: Backward-compatible alias of todayRealizedPnL.
                        required: false
                      - name: todayPL
                        type: string
                        description: Today total P&L serialized as a string.
                        required: false
                      - name: instrument
                        type: string
                        description: Backward-compatible alias of securityType.
                        required: false
                      - name: putCall
                        type: string
                        description: CALL or PUT for options.
                        required: false
                      - name: strikePrice
                        type: string
                        description: Option strike price serialized as a string.
                        required: false
                      - name: maturity
                        type: string
                        description: Option maturity date in YYYY-MM-DD format.
                        required: false
                      - name: flags
                        type: integer
                        description: Position flags.
                        required: false
                      - name: createdAt
                        type: string
                        description: Creation timestamp.
                        required: false
                      - name: updatedAt
                        type: string
                        description: Last update timestamp.
                        required: false
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: sodPositionsMarketValue
                        type: string
                        description: Start-of-day positions market value.
                        required: false
                      - name: netBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: stockBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: dayTradeBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: optionBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: dayTradeOvernightRegTBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: totalEquity
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: settledFunds
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: unsettledFunds
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: heldBackFunds
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: grossMargin
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: pendingOrdersMarginRequirements
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: maintReq
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: creditMultiplier
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: pendingOrdersCount
                        type: integer
                        description: Number of pending orders.
                        required: false
                      - name: credit
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: creditRemaining
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: realizedPL
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: unRealizedPL
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: SMA
                        type: string
                        description: Special memorandum account value.
                        required: false
                      - name: smaCreditRemaining
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: PDT
                        type: string
                        description: Pattern day trader value serialized as a string.
                        required: false
                      - name: pdtCreditRemaining
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: startOfDayCash
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: valueBought
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: valueSold
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: sodTtlEquity
                        type: string
                        description: Optional start-of-day total equity.
                        required: false
                      - name: sodTtlEquityUpdatedAt
                        type: string
                        description: Optional timestamp for sodTtlEquity.
                        required: false
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: fullyPaidUnsettledFunds
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: amountAvailableToWithdraw
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: updatedAt
                        type: string
                        description: Timestamp for the Apex update.
                        required: false
                      - name: id
                        type: string
                        description: Sterling account ID used for subscription routing.
                        required: false
                      - name: sterlingAccountId
                        type: string
                        description: Raw Sterling account ID.
                        required: false
                      - name: apexAccountId
                        type: string
                        description: Apex account ID when available.
                        required: false
                      - name: fdid
                        type: string
                        description: FDID when available.
                        required: false
                      - name: description
                        type: string
                        description: Account description.
                        required: false
                      - name: accountType
                        type: string
                        description: Account type.
                        required: false
                      - name: accountClass
                        type: string
                        description: Account class.
                        required: false
                      - name: optionsLevel
                        type: string
                        description: Options level.
                        required: false
                      - name: maintenanceExcess
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: cashAvailable
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: exchangeSurplus
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: accruedCash
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: netLiquidity
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: marginEquity
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: sma
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: maintReq
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: email
                        type: string
                        description: Account email.
                        required: false
                      - name: cell
                        type: string
                        description: Account phone number.
                        required: false
                      - name: groupId
                        type: string
                        description: Sterling group ID.
                        required: false
        headers: []
        jsonPayloadSchema: &ref_2
          type: object
          description: >-
            Server message for the `account` topic. `name` tells you what
            changed.
          properties:
            type:
              type: string
              enum:
                - event
              description: Top-level message type. Always `event` for streaming updates.
              x-parser-schema-id: <anonymous-schema-177>
            timestamp:
              type: string
              description: Time when the server sent this event, in RFC3339 format.
              x-parser-schema-id: <anonymous-schema-178>
            payload:
              type: object
              description: 'Routing: `topic`, `name`, and `data` for the event.'
              properties:
                topic:
                  type: string
                  enum:
                    - account
                  description: Topic identifier. Always `account` for these events.
                  x-parser-schema-id: <anonymous-schema-180>
                name:
                  type: string
                  enum:
                    - account.order
                    - account.position
                    - account.balance
                    - account.balance.apex
                    - account.info
                  description: Event name
                  x-parser-schema-id: <anonymous-schema-181>
                target:
                  type: string
                  description: Target identifier (e.g. account:ACC123456)
                  x-parser-schema-id: <anonymous-schema-182>
                data:
                  oneOf:
                    - &ref_5
                      type: object
                      description: >-
                        Order update from the server. This includes the order
                        plus fill details when the order changes.
                      properties:
                        clOrdId:
                          type: string
                          description: Client order ID.
                          x-parser-schema-id: <anonymous-schema-97>
                        ordId:
                          type: string
                          description: Broker/order ID.
                          x-parser-schema-id: <anonymous-schema-98>
                        origClOrdId:
                          type: string
                          description: Original client order ID for replaces/cancels.
                          x-parser-schema-id: <anonymous-schema-99>
                        accountId:
                          type: string
                          description: Sterling account ID.
                          x-parser-schema-id: <anonymous-schema-100>
                        clientId:
                          type: string
                          description: Client/user ID.
                          x-parser-schema-id: <anonymous-schema-101>
                        symbol:
                          type: string
                          description: Trading symbol.
                          x-parser-schema-id: <anonymous-schema-102>
                        side:
                          type: string
                          description: Order side, for example BUY or SELL.
                          x-parser-schema-id: <anonymous-schema-103>
                        type:
                          type: string
                          description: Order type, for example LIMIT or MARKET.
                          x-parser-schema-id: <anonymous-schema-104>
                        timeInForce:
                          type: string
                          description: Time in force, for example DAY.
                          x-parser-schema-id: <anonymous-schema-105>
                        qty:
                          type: string
                          description: Order quantity serialized as a string.
                          x-parser-schema-id: <anonymous-schema-106>
                        price:
                          type: string
                          description: Limit price serialized as a string.
                          x-parser-schema-id: <anonymous-schema-107>
                        stopPrice:
                          type: string
                          description: Stop price serialized as a string.
                          x-parser-schema-id: <anonymous-schema-108>
                        ordStatus:
                          type: string
                          enum:
                            - NEW
                            - PARTIALLY_FILLED
                            - FILLED
                            - DONE_FOR_DAY
                            - CANCELED
                            - REPLACED
                            - PENDING_CANCEL
                            - STOPPED
                            - REJECTED
                            - SUSPENDED
                            - PENDING_NEW
                            - CALCULATED
                            - EXPIRED
                            - ACCEPTED_FOR_BID
                            - PENDING_REPLACE
                            - SUPERSEDED
                          description: Order status.
                          x-parser-schema-id: <anonymous-schema-109>
                        cumQty:
                          type: string
                          description: Cumulative filled quantity serialized as a string.
                          x-parser-schema-id: <anonymous-schema-110>
                        leavesQty:
                          type: string
                          description: Remaining open quantity serialized as a string.
                          x-parser-schema-id: <anonymous-schema-111>
                        avgPrice:
                          type: string
                          description: Average execution price serialized as a string.
                          x-parser-schema-id: <anonymous-schema-112>
                        currency:
                          type: string
                          description: Currency code.
                          x-parser-schema-id: <anonymous-schema-113>
                        exDestination:
                          type: string
                          description: Execution destination, for example MNGDFTE or MNGD.
                          x-parser-schema-id: <anonymous-schema-114>
                        text:
                          type: string
                          description: Broker or venue message.
                          x-parser-schema-id: <anonymous-schema-115>
                        ordRejReason:
                          type: string
                          description: Order reject reason when present.
                          x-parser-schema-id: <anonymous-schema-116>
                        securityType:
                          type: string
                          description: Security type, for example EQUITY or OPTION.
                          x-parser-schema-id: <anonymous-schema-117>
                        category:
                          type: string
                          description: >-
                            Order category, for example EQUITY, SINGLE_LEG, or
                            MULTI_LEG.
                          x-parser-schema-id: <anonymous-schema-118>
                        legs:
                          type: array
                          items:
                            type: object
                            description: One option leg in an order update.
                            properties:
                              symbol:
                                type: string
                                description: Underlying or option symbol.
                                x-parser-schema-id: <anonymous-schema-120>
                              side:
                                type: string
                                description: Order side, for example BUY or SELL.
                                x-parser-schema-id: <anonymous-schema-121>
                              ratioQty:
                                type: string
                                description: Leg ratio quantity serialized as a string.
                                x-parser-schema-id: <anonymous-schema-122>
                              securityType:
                                type: string
                                description: Security type, for example OPTION.
                                x-parser-schema-id: <anonymous-schema-123>
                              maturity:
                                type: string
                                description: Option maturity date in YYYY-MM-DD format.
                                x-parser-schema-id: <anonymous-schema-124>
                              strikePrice:
                                type: string
                                description: Option strike price serialized as a string.
                                x-parser-schema-id: <anonymous-schema-125>
                              positionEffect:
                                type: string
                                description: Position effect, for example OPEN or CLOSE.
                                x-parser-schema-id: <anonymous-schema-126>
                              putCall:
                                type: string
                                description: Option side, CALL or PUT.
                                x-parser-schema-id: <anonymous-schema-127>
                              avgPrice:
                                type: string
                                description: >-
                                  Average fill price for the leg, serialized as
                                  a string.
                                x-parser-schema-id: <anonymous-schema-128>
                            x-parser-schema-id: AccountOrderLeg
                          x-parser-schema-id: <anonymous-schema-119>
                        execId:
                          type: string
                          description: Execution ID for fill events.
                          x-parser-schema-id: <anonymous-schema-129>
                        execType:
                          type: string
                          description: >-
                            Execution type, for example NEW, FILL, PARTIAL_FILL,
                            or REJECTED.
                          x-parser-schema-id: <anonymous-schema-130>
                        lastPx:
                          type: string
                          description: Last execution price serialized as a string.
                          x-parser-schema-id: <anonymous-schema-131>
                        lastQty:
                          type: string
                          description: Last execution quantity serialized as a string.
                          x-parser-schema-id: <anonymous-schema-132>
                        maturity:
                          type: string
                          description: >-
                            Flat option maturity when sent on single-leg option
                            orders.
                          x-parser-schema-id: <anonymous-schema-133>
                        putCall:
                          type: string
                          description: Flat option side, CALL or PUT.
                          x-parser-schema-id: <anonymous-schema-134>
                        strikePrice:
                          type: string
                          description: Flat option strike price serialized as a string.
                          x-parser-schema-id: <anonymous-schema-135>
                        positionEffect:
                          type: string
                          description: Flat option position effect.
                          x-parser-schema-id: <anonymous-schema-136>
                        createdAt:
                          type: string
                          format: date-time
                          description: Creation timestamp.
                          x-parser-schema-id: <anonymous-schema-137>
                        updatedAt:
                          type: string
                          format: date-time
                          description: Last update timestamp.
                          x-parser-schema-id: <anonymous-schema-138>
                      x-parser-schema-id: OrderData
                    - &ref_4
                      type: object
                      description: >-
                        Position update from the server. Decimal numbers are
                        sent as strings.
                      properties:
                        accountId:
                          type: string
                          description: Sterling account ID.
                          x-parser-schema-id: <anonymous-schema-79>
                        symbol:
                          type: string
                          description: Equity or OCC option symbol.
                          x-parser-schema-id: <anonymous-schema-80>
                        securityType:
                          type: string
                          description: Security type, for example EQUITY or OPTION.
                          x-parser-schema-id: <anonymous-schema-81>
                        qty:
                          type: string
                          description: Position quantity serialized as a string.
                          x-parser-schema-id: <anonymous-schema-82>
                        avgPrice:
                          type: string
                          description: Average position price serialized as a string.
                          x-parser-schema-id: <anonymous-schema-83>
                        avgCost:
                          type: string
                          description: Backward-compatible alias of avgPrice.
                          x-parser-schema-id: <anonymous-schema-84>
                        unRealizedPL:
                          type: string
                          description: Unrealized P&L serialized as a string.
                          x-parser-schema-id: <anonymous-schema-85>
                        todayRealizedPnL:
                          type: string
                          description: Today realized P&L serialized as a string.
                          x-parser-schema-id: <anonymous-schema-86>
                        realizedPL:
                          type: string
                          description: Backward-compatible alias of todayRealizedPnL.
                          x-parser-schema-id: <anonymous-schema-87>
                        todayPL:
                          type: string
                          description: Today total P&L serialized as a string.
                          x-parser-schema-id: <anonymous-schema-88>
                        instrument:
                          type: string
                          description: Backward-compatible alias of securityType.
                          x-parser-schema-id: <anonymous-schema-89>
                        putCall:
                          type: string
                          description: CALL or PUT for options.
                          x-parser-schema-id: <anonymous-schema-90>
                        strikePrice:
                          type: string
                          description: Option strike price serialized as a string.
                          x-parser-schema-id: <anonymous-schema-91>
                        maturity:
                          type: string
                          description: Option maturity date in YYYY-MM-DD format.
                          x-parser-schema-id: <anonymous-schema-92>
                        flags:
                          type: integer
                          description: Position flags.
                          x-parser-schema-id: <anonymous-schema-93>
                        createdAt:
                          type: string
                          format: date-time
                          description: Creation timestamp.
                          x-parser-schema-id: <anonymous-schema-94>
                        updatedAt:
                          type: string
                          format: date-time
                          description: Last update timestamp.
                          x-parser-schema-id: <anonymous-schema-95>
                      x-parser-schema-id: PositionData
                    - type: object
                      description: >-
                        Balance update from the server. Decimal numbers are sent
                        as strings.
                      properties:
                        accountId:
                          type: string
                          description: Sterling account ID.
                          x-parser-schema-id: <anonymous-schema-183>
                        sodPositionsMarketValue:
                          type: string
                          description: Start-of-day positions market value.
                          x-parser-schema-id: <anonymous-schema-184>
                        netBuyingPower:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-185>
                        stockBuyingPower:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-186>
                        dayTradeBuyingPower:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-187>
                        optionBuyingPower:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-188>
                        dayTradeOvernightRegTBuyingPower:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-189>
                        totalEquity:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-190>
                        settledFunds:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-191>
                        unsettledFunds:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-192>
                        heldBackFunds:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-193>
                        grossMargin:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-194>
                        pendingOrdersMarginRequirements:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-195>
                        maintReq:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-196>
                        creditMultiplier:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-197>
                        pendingOrdersCount:
                          type: integer
                          description: Number of pending orders.
                          x-parser-schema-id: <anonymous-schema-198>
                        credit:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-199>
                        creditRemaining:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-200>
                        realizedPL:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-201>
                        unRealizedPL:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-202>
                        SMA:
                          type: string
                          description: Special memorandum account value.
                          x-parser-schema-id: <anonymous-schema-203>
                        smaCreditRemaining:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-204>
                        PDT:
                          type: string
                          description: Pattern day trader value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-205>
                        pdtCreditRemaining:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-206>
                        startOfDayCash:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-207>
                        valueBought:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-208>
                        valueSold:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-209>
                        sodTtlEquity:
                          type: string
                          description: Optional start-of-day total equity.
                          x-parser-schema-id: <anonymous-schema-210>
                        sodTtlEquityUpdatedAt:
                          type: string
                          format: date-time
                          description: Optional timestamp for sodTtlEquity.
                          x-parser-schema-id: <anonymous-schema-211>
                      x-parser-schema-id: BalanceData
                    - type: object
                      description: >-
                        Smaller balance update. Merge these fields into the
                        latest balance data you already have.
                      properties:
                        accountId:
                          type: string
                          description: Sterling account ID.
                          x-parser-schema-id: <anonymous-schema-212>
                        fullyPaidUnsettledFunds:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-213>
                        amountAvailableToWithdraw:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-214>
                        updatedAt:
                          type: string
                          format: date-time
                          description: Timestamp for the Apex update.
                          x-parser-schema-id: <anonymous-schema-215>
                      x-parser-schema-id: ApexBalanceData
                    - type: object
                      description: >-
                        Account info update from the server. Decimal numbers are
                        sent as strings.
                      properties:
                        id:
                          type: string
                          description: Sterling account ID used for subscription routing.
                          x-parser-schema-id: <anonymous-schema-216>
                        sterlingAccountId:
                          type: string
                          description: Raw Sterling account ID.
                          x-parser-schema-id: <anonymous-schema-217>
                        apexAccountId:
                          type: string
                          description: Apex account ID when available.
                          x-parser-schema-id: <anonymous-schema-218>
                        fdid:
                          type: string
                          description: FDID when available.
                          x-parser-schema-id: <anonymous-schema-219>
                        description:
                          type: string
                          description: Account description.
                          x-parser-schema-id: <anonymous-schema-220>
                        accountType:
                          type: string
                          description: Account type.
                          x-parser-schema-id: <anonymous-schema-221>
                        accountClass:
                          type: string
                          description: Account class.
                          x-parser-schema-id: <anonymous-schema-222>
                        optionsLevel:
                          type: string
                          description: Options level.
                          x-parser-schema-id: <anonymous-schema-223>
                        maintenanceExcess:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-224>
                        cashAvailable:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-225>
                        exchangeSurplus:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-226>
                        accruedCash:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-227>
                        netLiquidity:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-228>
                        marginEquity:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-229>
                        sma:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-230>
                        maintReq:
                          type: string
                          description: Decimal value serialized as a string.
                          x-parser-schema-id: <anonymous-schema-231>
                        email:
                          type: string
                          description: Account email.
                          x-parser-schema-id: <anonymous-schema-232>
                        cell:
                          type: string
                          description: Account phone number.
                          x-parser-schema-id: <anonymous-schema-233>
                        groupId:
                          type: string
                          description: Sterling group ID.
                          x-parser-schema-id: <anonymous-schema-234>
                      x-parser-schema-id: AccountInfoData
                  x-parser-schema-id: AccountEventData
              x-parser-schema-id: <anonymous-schema-179>
          x-parser-schema-id: AccountEventPayload
        title: Order Update
        description: Real-time order update
        example: |-
          {
            "type": "event",
            "timestamp": "2024-01-15T10:30:05Z",
            "payload": {
              "topic": "account",
              "name": "account.order",
              "target": "account:ACC123456",
              "data": {
                "ordId": "ORD-12345",
                "clOrdId": "CLIENT-001",
                "accountId": "ACC123456",
                "clientId": "CLIENT-USER-001",
                "symbol": "AAPL",
                "side": "BUY",
                "type": "LIMIT",
                "timeInForce": "DAY",
                "qty": "100",
                "price": "150.50",
                "stopPrice": "0",
                "ordStatus": "FILLED",
                "cumQty": "100",
                "leavesQty": "0",
                "avgPrice": "150.45",
                "currency": "USD",
                "exDestination": "MNGDFTE",
                "securityType": "EQUITY",
                "category": "EQUITY",
                "createdAt": "2024-01-15T10:30:00Z",
                "updatedAt": "2024-01-15T10:30:05Z"
              }
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: orderUpdate
    bindings: []
    extensions: *ref_0
  - &ref_16
    id: receivePositionUpdate
    title: Position Update
    description: Receive real-time position updates
    type: send
    messages:
      - &ref_35
        id: positionUpdate
        contentType: application/json
        payload:
          - name: Position Update
            description: Real-time position update
            type: object
            properties:
              - name: type
                type: string
                description: Top-level message type. Always `event` for streaming updates.
                enumValues:
                  - event
                required: false
              - name: timestamp
                type: string
                description: Time when the server sent this event, in RFC3339 format.
                required: false
              - name: payload
                type: object
                description: 'Routing: `topic`, `name`, and `data` for the event.'
                required: false
                properties:
                  - name: topic
                    type: string
                    description: Topic identifier. Always `account` for these events.
                    enumValues:
                      - account
                    required: false
                  - name: name
                    type: string
                    description: Event name
                    enumValues:
                      - account.order
                      - account.position
                      - account.balance
                      - account.balance.apex
                      - account.info
                    required: false
                  - name: target
                    type: string
                    description: Target identifier (e.g. account:ACC123456)
                    required: false
                  - name: data
                    type: object
                    required: false
                    properties:
                      - name: clOrdId
                        type: string
                        description: Client order ID.
                        required: false
                      - name: ordId
                        type: string
                        description: Broker/order ID.
                        required: false
                      - name: origClOrdId
                        type: string
                        description: Original client order ID for replaces/cancels.
                        required: false
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: clientId
                        type: string
                        description: Client/user ID.
                        required: false
                      - name: symbol
                        type: string
                        description: Trading symbol.
                        required: false
                      - name: side
                        type: string
                        description: Order side, for example BUY or SELL.
                        required: false
                      - name: type
                        type: string
                        description: Order type, for example LIMIT or MARKET.
                        required: false
                      - name: timeInForce
                        type: string
                        description: Time in force, for example DAY.
                        required: false
                      - name: qty
                        type: string
                        description: Order quantity serialized as a string.
                        required: false
                      - name: price
                        type: string
                        description: Limit price serialized as a string.
                        required: false
                      - name: stopPrice
                        type: string
                        description: Stop price serialized as a string.
                        required: false
                      - name: ordStatus
                        type: string
                        description: Order status.
                        enumValues:
                          - NEW
                          - PARTIALLY_FILLED
                          - FILLED
                          - DONE_FOR_DAY
                          - CANCELED
                          - REPLACED
                          - PENDING_CANCEL
                          - STOPPED
                          - REJECTED
                          - SUSPENDED
                          - PENDING_NEW
                          - CALCULATED
                          - EXPIRED
                          - ACCEPTED_FOR_BID
                          - PENDING_REPLACE
                          - SUPERSEDED
                        required: false
                      - name: cumQty
                        type: string
                        description: Cumulative filled quantity serialized as a string.
                        required: false
                      - name: leavesQty
                        type: string
                        description: Remaining open quantity serialized as a string.
                        required: false
                      - name: avgPrice
                        type: string
                        description: Average execution price serialized as a string.
                        required: false
                      - name: currency
                        type: string
                        description: Currency code.
                        required: false
                      - name: exDestination
                        type: string
                        description: Execution destination, for example MNGDFTE or MNGD.
                        required: false
                      - name: text
                        type: string
                        description: Broker or venue message.
                        required: false
                      - name: ordRejReason
                        type: string
                        description: Order reject reason when present.
                        required: false
                      - name: securityType
                        type: string
                        description: Security type, for example EQUITY or OPTION.
                        required: false
                      - name: category
                        type: string
                        description: >-
                          Order category, for example EQUITY, SINGLE_LEG, or
                          MULTI_LEG.
                        required: false
                      - name: legs
                        type: array
                        required: false
                        properties:
                          - name: symbol
                            type: string
                            description: Underlying or option symbol.
                            required: false
                          - name: side
                            type: string
                            description: Order side, for example BUY or SELL.
                            required: false
                          - name: ratioQty
                            type: string
                            description: Leg ratio quantity serialized as a string.
                            required: false
                          - name: securityType
                            type: string
                            description: Security type, for example OPTION.
                            required: false
                          - name: maturity
                            type: string
                            description: Option maturity date in YYYY-MM-DD format.
                            required: false
                          - name: strikePrice
                            type: string
                            description: Option strike price serialized as a string.
                            required: false
                          - name: positionEffect
                            type: string
                            description: Position effect, for example OPEN or CLOSE.
                            required: false
                          - name: putCall
                            type: string
                            description: Option side, CALL or PUT.
                            required: false
                          - name: avgPrice
                            type: string
                            description: >-
                              Average fill price for the leg, serialized as a
                              string.
                            required: false
                      - name: execId
                        type: string
                        description: Execution ID for fill events.
                        required: false
                      - name: execType
                        type: string
                        description: >-
                          Execution type, for example NEW, FILL, PARTIAL_FILL,
                          or REJECTED.
                        required: false
                      - name: lastPx
                        type: string
                        description: Last execution price serialized as a string.
                        required: false
                      - name: lastQty
                        type: string
                        description: Last execution quantity serialized as a string.
                        required: false
                      - name: maturity
                        type: string
                        description: >-
                          Flat option maturity when sent on single-leg option
                          orders.
                        required: false
                      - name: putCall
                        type: string
                        description: Flat option side, CALL or PUT.
                        required: false
                      - name: strikePrice
                        type: string
                        description: Flat option strike price serialized as a string.
                        required: false
                      - name: positionEffect
                        type: string
                        description: Flat option position effect.
                        required: false
                      - name: createdAt
                        type: string
                        description: Creation timestamp.
                        required: false
                      - name: updatedAt
                        type: string
                        description: Last update timestamp.
                        required: false
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: symbol
                        type: string
                        description: Equity or OCC option symbol.
                        required: false
                      - name: securityType
                        type: string
                        description: Security type, for example EQUITY or OPTION.
                        required: false
                      - name: qty
                        type: string
                        description: Position quantity serialized as a string.
                        required: false
                      - name: avgPrice
                        type: string
                        description: Average position price serialized as a string.
                        required: false
                      - name: avgCost
                        type: string
                        description: Backward-compatible alias of avgPrice.
                        required: false
                      - name: unRealizedPL
                        type: string
                        description: Unrealized P&L serialized as a string.
                        required: false
                      - name: todayRealizedPnL
                        type: string
                        description: Today realized P&L serialized as a string.
                        required: false
                      - name: realizedPL
                        type: string
                        description: Backward-compatible alias of todayRealizedPnL.
                        required: false
                      - name: todayPL
                        type: string
                        description: Today total P&L serialized as a string.
                        required: false
                      - name: instrument
                        type: string
                        description: Backward-compatible alias of securityType.
                        required: false
                      - name: putCall
                        type: string
                        description: CALL or PUT for options.
                        required: false
                      - name: strikePrice
                        type: string
                        description: Option strike price serialized as a string.
                        required: false
                      - name: maturity
                        type: string
                        description: Option maturity date in YYYY-MM-DD format.
                        required: false
                      - name: flags
                        type: integer
                        description: Position flags.
                        required: false
                      - name: createdAt
                        type: string
                        description: Creation timestamp.
                        required: false
                      - name: updatedAt
                        type: string
                        description: Last update timestamp.
                        required: false
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: sodPositionsMarketValue
                        type: string
                        description: Start-of-day positions market value.
                        required: false
                      - name: netBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: stockBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: dayTradeBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: optionBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: dayTradeOvernightRegTBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: totalEquity
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: settledFunds
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: unsettledFunds
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: heldBackFunds
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: grossMargin
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: pendingOrdersMarginRequirements
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: maintReq
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: creditMultiplier
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: pendingOrdersCount
                        type: integer
                        description: Number of pending orders.
                        required: false
                      - name: credit
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: creditRemaining
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: realizedPL
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: unRealizedPL
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: SMA
                        type: string
                        description: Special memorandum account value.
                        required: false
                      - name: smaCreditRemaining
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: PDT
                        type: string
                        description: Pattern day trader value serialized as a string.
                        required: false
                      - name: pdtCreditRemaining
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: startOfDayCash
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: valueBought
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: valueSold
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: sodTtlEquity
                        type: string
                        description: Optional start-of-day total equity.
                        required: false
                      - name: sodTtlEquityUpdatedAt
                        type: string
                        description: Optional timestamp for sodTtlEquity.
                        required: false
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: fullyPaidUnsettledFunds
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: amountAvailableToWithdraw
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: updatedAt
                        type: string
                        description: Timestamp for the Apex update.
                        required: false
                      - name: id
                        type: string
                        description: Sterling account ID used for subscription routing.
                        required: false
                      - name: sterlingAccountId
                        type: string
                        description: Raw Sterling account ID.
                        required: false
                      - name: apexAccountId
                        type: string
                        description: Apex account ID when available.
                        required: false
                      - name: fdid
                        type: string
                        description: FDID when available.
                        required: false
                      - name: description
                        type: string
                        description: Account description.
                        required: false
                      - name: accountType
                        type: string
                        description: Account type.
                        required: false
                      - name: accountClass
                        type: string
                        description: Account class.
                        required: false
                      - name: optionsLevel
                        type: string
                        description: Options level.
                        required: false
                      - name: maintenanceExcess
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: cashAvailable
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: exchangeSurplus
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: accruedCash
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: netLiquidity
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: marginEquity
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: sma
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: maintReq
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: email
                        type: string
                        description: Account email.
                        required: false
                      - name: cell
                        type: string
                        description: Account phone number.
                        required: false
                      - name: groupId
                        type: string
                        description: Sterling group ID.
                        required: false
        headers: []
        jsonPayloadSchema: *ref_2
        title: Position Update
        description: Real-time position update
        example: |-
          {
            "type": "event",
            "timestamp": "2024-01-15T14:30:00Z",
            "payload": {
              "topic": "account",
              "name": "account.position",
              "target": "account:ACC123456",
              "data": {
                "accountId": "ACC123456",
                "symbol": "AAPL",
                "securityType": "EQUITY",
                "qty": "100",
                "avgPrice": "150.45",
                "avgCost": "150.45",
                "unRealizedPL": "155.00",
                "todayRealizedPnL": "0",
                "realizedPL": "0",
                "todayPL": "155.00",
                "instrument": "EQUITY",
                "createdAt": "2024-01-15T10:30:05Z",
                "updatedAt": "2024-01-15T14:30:00Z"
              }
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: positionUpdate
    bindings: []
    extensions: *ref_0
  - &ref_17
    id: receiveBalanceUpdate
    title: Balance Update
    description: Receive real-time balance updates
    type: send
    messages:
      - &ref_36
        id: balanceUpdate
        contentType: application/json
        payload:
          - name: Balance Update
            description: Real-time balance update
            type: object
            properties:
              - name: type
                type: string
                description: Top-level message type. Always `event` for streaming updates.
                enumValues:
                  - event
                required: false
              - name: timestamp
                type: string
                description: Time when the server sent this event, in RFC3339 format.
                required: false
              - name: payload
                type: object
                description: 'Routing: `topic`, `name`, and `data` for the event.'
                required: false
                properties:
                  - name: topic
                    type: string
                    description: Topic identifier. Always `account` for these events.
                    enumValues:
                      - account
                    required: false
                  - name: name
                    type: string
                    description: Event name
                    enumValues:
                      - account.order
                      - account.position
                      - account.balance
                      - account.balance.apex
                      - account.info
                    required: false
                  - name: target
                    type: string
                    description: Target identifier (e.g. account:ACC123456)
                    required: false
                  - name: data
                    type: object
                    required: false
                    properties:
                      - name: clOrdId
                        type: string
                        description: Client order ID.
                        required: false
                      - name: ordId
                        type: string
                        description: Broker/order ID.
                        required: false
                      - name: origClOrdId
                        type: string
                        description: Original client order ID for replaces/cancels.
                        required: false
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: clientId
                        type: string
                        description: Client/user ID.
                        required: false
                      - name: symbol
                        type: string
                        description: Trading symbol.
                        required: false
                      - name: side
                        type: string
                        description: Order side, for example BUY or SELL.
                        required: false
                      - name: type
                        type: string
                        description: Order type, for example LIMIT or MARKET.
                        required: false
                      - name: timeInForce
                        type: string
                        description: Time in force, for example DAY.
                        required: false
                      - name: qty
                        type: string
                        description: Order quantity serialized as a string.
                        required: false
                      - name: price
                        type: string
                        description: Limit price serialized as a string.
                        required: false
                      - name: stopPrice
                        type: string
                        description: Stop price serialized as a string.
                        required: false
                      - name: ordStatus
                        type: string
                        description: Order status.
                        enumValues:
                          - NEW
                          - PARTIALLY_FILLED
                          - FILLED
                          - DONE_FOR_DAY
                          - CANCELED
                          - REPLACED
                          - PENDING_CANCEL
                          - STOPPED
                          - REJECTED
                          - SUSPENDED
                          - PENDING_NEW
                          - CALCULATED
                          - EXPIRED
                          - ACCEPTED_FOR_BID
                          - PENDING_REPLACE
                          - SUPERSEDED
                        required: false
                      - name: cumQty
                        type: string
                        description: Cumulative filled quantity serialized as a string.
                        required: false
                      - name: leavesQty
                        type: string
                        description: Remaining open quantity serialized as a string.
                        required: false
                      - name: avgPrice
                        type: string
                        description: Average execution price serialized as a string.
                        required: false
                      - name: currency
                        type: string
                        description: Currency code.
                        required: false
                      - name: exDestination
                        type: string
                        description: Execution destination, for example MNGDFTE or MNGD.
                        required: false
                      - name: text
                        type: string
                        description: Broker or venue message.
                        required: false
                      - name: ordRejReason
                        type: string
                        description: Order reject reason when present.
                        required: false
                      - name: securityType
                        type: string
                        description: Security type, for example EQUITY or OPTION.
                        required: false
                      - name: category
                        type: string
                        description: >-
                          Order category, for example EQUITY, SINGLE_LEG, or
                          MULTI_LEG.
                        required: false
                      - name: legs
                        type: array
                        required: false
                        properties:
                          - name: symbol
                            type: string
                            description: Underlying or option symbol.
                            required: false
                          - name: side
                            type: string
                            description: Order side, for example BUY or SELL.
                            required: false
                          - name: ratioQty
                            type: string
                            description: Leg ratio quantity serialized as a string.
                            required: false
                          - name: securityType
                            type: string
                            description: Security type, for example OPTION.
                            required: false
                          - name: maturity
                            type: string
                            description: Option maturity date in YYYY-MM-DD format.
                            required: false
                          - name: strikePrice
                            type: string
                            description: Option strike price serialized as a string.
                            required: false
                          - name: positionEffect
                            type: string
                            description: Position effect, for example OPEN or CLOSE.
                            required: false
                          - name: putCall
                            type: string
                            description: Option side, CALL or PUT.
                            required: false
                          - name: avgPrice
                            type: string
                            description: >-
                              Average fill price for the leg, serialized as a
                              string.
                            required: false
                      - name: execId
                        type: string
                        description: Execution ID for fill events.
                        required: false
                      - name: execType
                        type: string
                        description: >-
                          Execution type, for example NEW, FILL, PARTIAL_FILL,
                          or REJECTED.
                        required: false
                      - name: lastPx
                        type: string
                        description: Last execution price serialized as a string.
                        required: false
                      - name: lastQty
                        type: string
                        description: Last execution quantity serialized as a string.
                        required: false
                      - name: maturity
                        type: string
                        description: >-
                          Flat option maturity when sent on single-leg option
                          orders.
                        required: false
                      - name: putCall
                        type: string
                        description: Flat option side, CALL or PUT.
                        required: false
                      - name: strikePrice
                        type: string
                        description: Flat option strike price serialized as a string.
                        required: false
                      - name: positionEffect
                        type: string
                        description: Flat option position effect.
                        required: false
                      - name: createdAt
                        type: string
                        description: Creation timestamp.
                        required: false
                      - name: updatedAt
                        type: string
                        description: Last update timestamp.
                        required: false
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: symbol
                        type: string
                        description: Equity or OCC option symbol.
                        required: false
                      - name: securityType
                        type: string
                        description: Security type, for example EQUITY or OPTION.
                        required: false
                      - name: qty
                        type: string
                        description: Position quantity serialized as a string.
                        required: false
                      - name: avgPrice
                        type: string
                        description: Average position price serialized as a string.
                        required: false
                      - name: avgCost
                        type: string
                        description: Backward-compatible alias of avgPrice.
                        required: false
                      - name: unRealizedPL
                        type: string
                        description: Unrealized P&L serialized as a string.
                        required: false
                      - name: todayRealizedPnL
                        type: string
                        description: Today realized P&L serialized as a string.
                        required: false
                      - name: realizedPL
                        type: string
                        description: Backward-compatible alias of todayRealizedPnL.
                        required: false
                      - name: todayPL
                        type: string
                        description: Today total P&L serialized as a string.
                        required: false
                      - name: instrument
                        type: string
                        description: Backward-compatible alias of securityType.
                        required: false
                      - name: putCall
                        type: string
                        description: CALL or PUT for options.
                        required: false
                      - name: strikePrice
                        type: string
                        description: Option strike price serialized as a string.
                        required: false
                      - name: maturity
                        type: string
                        description: Option maturity date in YYYY-MM-DD format.
                        required: false
                      - name: flags
                        type: integer
                        description: Position flags.
                        required: false
                      - name: createdAt
                        type: string
                        description: Creation timestamp.
                        required: false
                      - name: updatedAt
                        type: string
                        description: Last update timestamp.
                        required: false
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: sodPositionsMarketValue
                        type: string
                        description: Start-of-day positions market value.
                        required: false
                      - name: netBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: stockBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: dayTradeBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: optionBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: dayTradeOvernightRegTBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: totalEquity
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: settledFunds
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: unsettledFunds
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: heldBackFunds
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: grossMargin
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: pendingOrdersMarginRequirements
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: maintReq
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: creditMultiplier
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: pendingOrdersCount
                        type: integer
                        description: Number of pending orders.
                        required: false
                      - name: credit
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: creditRemaining
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: realizedPL
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: unRealizedPL
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: SMA
                        type: string
                        description: Special memorandum account value.
                        required: false
                      - name: smaCreditRemaining
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: PDT
                        type: string
                        description: Pattern day trader value serialized as a string.
                        required: false
                      - name: pdtCreditRemaining
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: startOfDayCash
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: valueBought
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: valueSold
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: sodTtlEquity
                        type: string
                        description: Optional start-of-day total equity.
                        required: false
                      - name: sodTtlEquityUpdatedAt
                        type: string
                        description: Optional timestamp for sodTtlEquity.
                        required: false
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: fullyPaidUnsettledFunds
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: amountAvailableToWithdraw
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: updatedAt
                        type: string
                        description: Timestamp for the Apex update.
                        required: false
                      - name: id
                        type: string
                        description: Sterling account ID used for subscription routing.
                        required: false
                      - name: sterlingAccountId
                        type: string
                        description: Raw Sterling account ID.
                        required: false
                      - name: apexAccountId
                        type: string
                        description: Apex account ID when available.
                        required: false
                      - name: fdid
                        type: string
                        description: FDID when available.
                        required: false
                      - name: description
                        type: string
                        description: Account description.
                        required: false
                      - name: accountType
                        type: string
                        description: Account type.
                        required: false
                      - name: accountClass
                        type: string
                        description: Account class.
                        required: false
                      - name: optionsLevel
                        type: string
                        description: Options level.
                        required: false
                      - name: maintenanceExcess
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: cashAvailable
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: exchangeSurplus
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: accruedCash
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: netLiquidity
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: marginEquity
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: sma
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: maintReq
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: email
                        type: string
                        description: Account email.
                        required: false
                      - name: cell
                        type: string
                        description: Account phone number.
                        required: false
                      - name: groupId
                        type: string
                        description: Sterling group ID.
                        required: false
        headers: []
        jsonPayloadSchema: *ref_2
        title: Balance Update
        description: Real-time balance update
        example: |-
          {
            "type": "event",
            "timestamp": "2024-01-15T14:30:00Z",
            "payload": {
              "topic": "account",
              "name": "account.balance",
              "target": "account:ACC123456",
              "data": {
                "accountId": "ACC123456",
                "sodPositionsMarketValue": "48000.00",
                "netBuyingPower": "25155.00",
                "stockBuyingPower": "50310.00",
                "dayTradeBuyingPower": "100620.00",
                "optionBuyingPower": "25155.00",
                "dayTradeOvernightRegTBuyingPower": "50310.00",
                "totalEquity": "50155.00",
                "settledFunds": "35000.00",
                "unsettledFunds": "0",
                "heldBackFunds": "0",
                "grossMargin": "15045.00",
                "pendingOrdersMarginRequirements": "0",
                "maintReq": "7646.50",
                "creditMultiplier": "2",
                "pendingOrdersCount": 0,
                "credit": "50000.00",
                "creditRemaining": "25155.00",
                "realizedPL": "0",
                "unRealizedPL": "167.00",
                "SMA": "25155.00",
                "smaCreditRemaining": "25155.00",
                "PDT": "0",
                "pdtCreditRemaining": "100620.00",
                "startOfDayCash": "35000.00",
                "valueBought": "15293.00",
                "valueSold": "0"
              }
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: balanceUpdate
    bindings: []
    extensions: *ref_0
  - &ref_18
    id: receiveAccountUpdate
    title: Account Update
    description: Receive account information updates
    type: send
    messages:
      - &ref_37
        id: accountUpdate
        contentType: application/json
        payload:
          - name: Account Info Update
            description: Real-time account information update
            type: object
            properties:
              - name: type
                type: string
                description: Top-level message type. Always `event` for streaming updates.
                enumValues:
                  - event
                required: false
              - name: timestamp
                type: string
                description: Time when the server sent this event, in RFC3339 format.
                required: false
              - name: payload
                type: object
                description: 'Routing: `topic`, `name`, and `data` for the event.'
                required: false
                properties:
                  - name: topic
                    type: string
                    description: Topic identifier. Always `account` for these events.
                    enumValues:
                      - account
                    required: false
                  - name: name
                    type: string
                    description: Event name
                    enumValues:
                      - account.order
                      - account.position
                      - account.balance
                      - account.balance.apex
                      - account.info
                    required: false
                  - name: target
                    type: string
                    description: Target identifier (e.g. account:ACC123456)
                    required: false
                  - name: data
                    type: object
                    required: false
                    properties:
                      - name: clOrdId
                        type: string
                        description: Client order ID.
                        required: false
                      - name: ordId
                        type: string
                        description: Broker/order ID.
                        required: false
                      - name: origClOrdId
                        type: string
                        description: Original client order ID for replaces/cancels.
                        required: false
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: clientId
                        type: string
                        description: Client/user ID.
                        required: false
                      - name: symbol
                        type: string
                        description: Trading symbol.
                        required: false
                      - name: side
                        type: string
                        description: Order side, for example BUY or SELL.
                        required: false
                      - name: type
                        type: string
                        description: Order type, for example LIMIT or MARKET.
                        required: false
                      - name: timeInForce
                        type: string
                        description: Time in force, for example DAY.
                        required: false
                      - name: qty
                        type: string
                        description: Order quantity serialized as a string.
                        required: false
                      - name: price
                        type: string
                        description: Limit price serialized as a string.
                        required: false
                      - name: stopPrice
                        type: string
                        description: Stop price serialized as a string.
                        required: false
                      - name: ordStatus
                        type: string
                        description: Order status.
                        enumValues:
                          - NEW
                          - PARTIALLY_FILLED
                          - FILLED
                          - DONE_FOR_DAY
                          - CANCELED
                          - REPLACED
                          - PENDING_CANCEL
                          - STOPPED
                          - REJECTED
                          - SUSPENDED
                          - PENDING_NEW
                          - CALCULATED
                          - EXPIRED
                          - ACCEPTED_FOR_BID
                          - PENDING_REPLACE
                          - SUPERSEDED
                        required: false
                      - name: cumQty
                        type: string
                        description: Cumulative filled quantity serialized as a string.
                        required: false
                      - name: leavesQty
                        type: string
                        description: Remaining open quantity serialized as a string.
                        required: false
                      - name: avgPrice
                        type: string
                        description: Average execution price serialized as a string.
                        required: false
                      - name: currency
                        type: string
                        description: Currency code.
                        required: false
                      - name: exDestination
                        type: string
                        description: Execution destination, for example MNGDFTE or MNGD.
                        required: false
                      - name: text
                        type: string
                        description: Broker or venue message.
                        required: false
                      - name: ordRejReason
                        type: string
                        description: Order reject reason when present.
                        required: false
                      - name: securityType
                        type: string
                        description: Security type, for example EQUITY or OPTION.
                        required: false
                      - name: category
                        type: string
                        description: >-
                          Order category, for example EQUITY, SINGLE_LEG, or
                          MULTI_LEG.
                        required: false
                      - name: legs
                        type: array
                        required: false
                        properties:
                          - name: symbol
                            type: string
                            description: Underlying or option symbol.
                            required: false
                          - name: side
                            type: string
                            description: Order side, for example BUY or SELL.
                            required: false
                          - name: ratioQty
                            type: string
                            description: Leg ratio quantity serialized as a string.
                            required: false
                          - name: securityType
                            type: string
                            description: Security type, for example OPTION.
                            required: false
                          - name: maturity
                            type: string
                            description: Option maturity date in YYYY-MM-DD format.
                            required: false
                          - name: strikePrice
                            type: string
                            description: Option strike price serialized as a string.
                            required: false
                          - name: positionEffect
                            type: string
                            description: Position effect, for example OPEN or CLOSE.
                            required: false
                          - name: putCall
                            type: string
                            description: Option side, CALL or PUT.
                            required: false
                          - name: avgPrice
                            type: string
                            description: >-
                              Average fill price for the leg, serialized as a
                              string.
                            required: false
                      - name: execId
                        type: string
                        description: Execution ID for fill events.
                        required: false
                      - name: execType
                        type: string
                        description: >-
                          Execution type, for example NEW, FILL, PARTIAL_FILL,
                          or REJECTED.
                        required: false
                      - name: lastPx
                        type: string
                        description: Last execution price serialized as a string.
                        required: false
                      - name: lastQty
                        type: string
                        description: Last execution quantity serialized as a string.
                        required: false
                      - name: maturity
                        type: string
                        description: >-
                          Flat option maturity when sent on single-leg option
                          orders.
                        required: false
                      - name: putCall
                        type: string
                        description: Flat option side, CALL or PUT.
                        required: false
                      - name: strikePrice
                        type: string
                        description: Flat option strike price serialized as a string.
                        required: false
                      - name: positionEffect
                        type: string
                        description: Flat option position effect.
                        required: false
                      - name: createdAt
                        type: string
                        description: Creation timestamp.
                        required: false
                      - name: updatedAt
                        type: string
                        description: Last update timestamp.
                        required: false
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: symbol
                        type: string
                        description: Equity or OCC option symbol.
                        required: false
                      - name: securityType
                        type: string
                        description: Security type, for example EQUITY or OPTION.
                        required: false
                      - name: qty
                        type: string
                        description: Position quantity serialized as a string.
                        required: false
                      - name: avgPrice
                        type: string
                        description: Average position price serialized as a string.
                        required: false
                      - name: avgCost
                        type: string
                        description: Backward-compatible alias of avgPrice.
                        required: false
                      - name: unRealizedPL
                        type: string
                        description: Unrealized P&L serialized as a string.
                        required: false
                      - name: todayRealizedPnL
                        type: string
                        description: Today realized P&L serialized as a string.
                        required: false
                      - name: realizedPL
                        type: string
                        description: Backward-compatible alias of todayRealizedPnL.
                        required: false
                      - name: todayPL
                        type: string
                        description: Today total P&L serialized as a string.
                        required: false
                      - name: instrument
                        type: string
                        description: Backward-compatible alias of securityType.
                        required: false
                      - name: putCall
                        type: string
                        description: CALL or PUT for options.
                        required: false
                      - name: strikePrice
                        type: string
                        description: Option strike price serialized as a string.
                        required: false
                      - name: maturity
                        type: string
                        description: Option maturity date in YYYY-MM-DD format.
                        required: false
                      - name: flags
                        type: integer
                        description: Position flags.
                        required: false
                      - name: createdAt
                        type: string
                        description: Creation timestamp.
                        required: false
                      - name: updatedAt
                        type: string
                        description: Last update timestamp.
                        required: false
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: sodPositionsMarketValue
                        type: string
                        description: Start-of-day positions market value.
                        required: false
                      - name: netBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: stockBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: dayTradeBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: optionBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: dayTradeOvernightRegTBuyingPower
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: totalEquity
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: settledFunds
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: unsettledFunds
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: heldBackFunds
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: grossMargin
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: pendingOrdersMarginRequirements
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: maintReq
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: creditMultiplier
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: pendingOrdersCount
                        type: integer
                        description: Number of pending orders.
                        required: false
                      - name: credit
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: creditRemaining
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: realizedPL
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: unRealizedPL
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: SMA
                        type: string
                        description: Special memorandum account value.
                        required: false
                      - name: smaCreditRemaining
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: PDT
                        type: string
                        description: Pattern day trader value serialized as a string.
                        required: false
                      - name: pdtCreditRemaining
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: startOfDayCash
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: valueBought
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: valueSold
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: sodTtlEquity
                        type: string
                        description: Optional start-of-day total equity.
                        required: false
                      - name: sodTtlEquityUpdatedAt
                        type: string
                        description: Optional timestamp for sodTtlEquity.
                        required: false
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: fullyPaidUnsettledFunds
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: amountAvailableToWithdraw
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: updatedAt
                        type: string
                        description: Timestamp for the Apex update.
                        required: false
                      - name: id
                        type: string
                        description: Sterling account ID used for subscription routing.
                        required: false
                      - name: sterlingAccountId
                        type: string
                        description: Raw Sterling account ID.
                        required: false
                      - name: apexAccountId
                        type: string
                        description: Apex account ID when available.
                        required: false
                      - name: fdid
                        type: string
                        description: FDID when available.
                        required: false
                      - name: description
                        type: string
                        description: Account description.
                        required: false
                      - name: accountType
                        type: string
                        description: Account type.
                        required: false
                      - name: accountClass
                        type: string
                        description: Account class.
                        required: false
                      - name: optionsLevel
                        type: string
                        description: Options level.
                        required: false
                      - name: maintenanceExcess
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: cashAvailable
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: exchangeSurplus
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: accruedCash
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: netLiquidity
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: marginEquity
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: sma
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: maintReq
                        type: string
                        description: Decimal value serialized as a string.
                        required: false
                      - name: email
                        type: string
                        description: Account email.
                        required: false
                      - name: cell
                        type: string
                        description: Account phone number.
                        required: false
                      - name: groupId
                        type: string
                        description: Sterling group ID.
                        required: false
        headers: []
        jsonPayloadSchema: *ref_2
        title: Account Info Update
        description: Real-time account information update
        example: |-
          {
            "type": "event",
            "timestamp": "2024-01-15T14:30:00Z",
            "payload": {
              "topic": "account",
              "name": "account.info",
              "target": "account:ACC123456",
              "data": {
                "id": "ACC123456",
                "sterlingAccountId": "STERLING-123",
                "apexAccountId": "",
                "fdid": "FDID-123456",
                "description": "John Doe Trading Account",
                "accountType": "MARGIN",
                "accountClass": "INDIVIDUAL",
                "optionsLevel": "LEVEL_3",
                "maintenanceExcess": "17508.50",
                "cashAvailable": "25155.00",
                "exchangeSurplus": "0",
                "accruedCash": "0",
                "netLiquidity": "50155.00",
                "marginEquity": "50155.00",
                "sma": "25155.00",
                "maintReq": "7646.50",
                "email": "john.doe@example.com",
                "cell": "+1234567890",
                "groupId": "TRADING"
              }
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: accountUpdate
    bindings: []
    extensions: *ref_0
  - &ref_19
    id: receivePnLCandleUpdate
    title: P&L Candle Update
    description: Receive P&L candle data
    type: send
    messages:
      - &ref_38
        id: pnlCandleUpdate
        contentType: application/json
        payload:
          - name: P&L Candle Update
            description: Live profit and loss updates
            type: object
            properties:
              - name: type
                type: string
                description: Top-level message type. Always `event` for P&L updates.
                enumValues:
                  - event
                required: false
              - name: timestamp
                type: string
                description: Time when the server sent this event, in RFC3339 format.
                required: false
              - name: payload
                type: object
                description: The `pnl` topic name and its data.
                required: false
                properties:
                  - name: topic
                    type: string
                    description: Topic identifier. Always `pnl`.
                    enumValues:
                      - pnl
                    required: false
                  - name: data
                    type: object
                    description: >-
                      Profit and loss chart data. This includes timestamp,
                      close, and equity arrays.
                    required: false
                    properties:
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: interval
                        type: string
                        description: Candle interval.
                        required: false
                      - name: t
                        type: array
                        description: Unix timestamps in seconds.
                        required: false
                        properties:
                          - name: item
                            type: integer
                            required: false
                      - name: c
                        type: array
                        description: Close/equity values.
                        required: false
                        properties:
                          - name: item
                            type: number
                            required: false
        headers: []
        jsonPayloadSchema:
          type: object
          description: Server message for the `pnl` topic.
          properties:
            type:
              type: string
              enum:
                - event
              description: Top-level message type. Always `event` for P&L updates.
              x-parser-schema-id: <anonymous-schema-235>
            timestamp:
              type: string
              description: Time when the server sent this event, in RFC3339 format.
              x-parser-schema-id: <anonymous-schema-236>
            payload:
              type: object
              description: The `pnl` topic name and its data.
              properties:
                topic:
                  type: string
                  enum:
                    - pnl
                  description: Topic identifier. Always `pnl`.
                  x-parser-schema-id: <anonymous-schema-238>
                data: &ref_6
                  type: object
                  description: >-
                    Profit and loss chart data. This includes timestamp, close,
                    and equity arrays.
                  properties:
                    accountId:
                      type: string
                      description: Sterling account ID.
                      x-parser-schema-id: <anonymous-schema-141>
                    interval:
                      type: string
                      description: Candle interval.
                      x-parser-schema-id: <anonymous-schema-142>
                    t:
                      type: array
                      items:
                        type: integer
                        x-parser-schema-id: <anonymous-schema-144>
                      description: Unix timestamps in seconds.
                      x-parser-schema-id: <anonymous-schema-143>
                    c:
                      type: array
                      items:
                        type: number
                        x-parser-schema-id: <anonymous-schema-146>
                      description: Close/equity values.
                      x-parser-schema-id: <anonymous-schema-145>
                  x-parser-schema-id: PnLCandleData
              x-parser-schema-id: <anonymous-schema-237>
          x-parser-schema-id: PnLEventPayload
        title: P&L Candle Update
        description: Live profit and loss updates
        example: |-
          {
            "type": "event",
            "timestamp": "2024-01-15T10:30:00Z",
            "payload": {
              "topic": "pnl",
              "data": {
                "accountId": "ACC123456",
                "interval": "1m",
                "t": [
                  1703001000
                ],
                "c": [
                  50155
                ]
              }
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: pnlCandleUpdate
    bindings: []
    extensions: *ref_0
  - &ref_20
    id: receiveWatchlistUpdate
    title: Watchlist Update
    description: Receive watchlist change notifications
    type: send
    messages:
      - &ref_39
        id: watchlistUpdate
        contentType: application/json
        payload:
          - name: Watchlist Update
            description: Real-time watchlist updates
            type: object
            properties:
              - name: type
                type: string
                description: Top-level message type. Always `event` for watchlist/news.
                enumValues:
                  - event
                required: false
              - name: timestamp
                type: string
                description: Time when the server sent this event, in RFC3339 format.
                required: false
              - name: payload
                type: object
                description: The topic name and the data for that event.
                required: false
                properties:
                  - name: topic
                    type: string
                    description: Topic identifier
                    enumValues:
                      - watchlist
                      - news
                    required: false
                  - name: data
                    type: oneOf
                    required: false
                    properties:
                      - name: id
                        type: integer
                        description: Watchlist ID.
                        required: false
                      - name: name
                        type: string
                        description: User-facing watchlist name.
                        required: false
                      - name: symbols
                        type: array
                        description: Symbols currently saved in the watchlist.
                        required: false
                        properties:
                          - name: item
                            type: string
                            required: false
                      - name: msgType
                        type: string
                        required: false
                      - name: items
                        type: array
                        required: false
                        properties:
                          - name: id
                            type: integer
                            description: Unique news ID.
                            required: false
                          - name: title
                            type: string
                            description: Article title.
                            required: false
                          - name: news_type
                            type: string
                            description: News type, for example news or press_release.
                            required: false
                          - name: symbols
                            type: array
                            description: Related symbols.
                            required: false
                            properties:
                              - name: item
                                type: string
                                required: false
                          - name: authors
                            type: array
                            description: Article authors.
                            required: false
                            properties:
                              - name: item
                                type: string
                                required: false
                          - name: timestamp
                            type: string
                            description: Publication timestamp.
                            required: false
                          - name: body
                            type: string
                            description: Full article content when available.
                            required: false
                          - name: action
                            type: string
                            description: Action string when available.
                            required: false
        headers: []
        jsonPayloadSchema: &ref_3
          type: object
          description: Server message for the `watchlist` or `news` topic.
          properties:
            type:
              type: string
              enum:
                - event
              description: Top-level message type. Always `event` for watchlist/news.
              x-parser-schema-id: <anonymous-schema-239>
            timestamp:
              type: string
              description: Time when the server sent this event, in RFC3339 format.
              x-parser-schema-id: <anonymous-schema-240>
            payload:
              type: object
              description: The topic name and the data for that event.
              properties:
                topic:
                  type: string
                  enum:
                    - watchlist
                    - news
                  description: Topic identifier
                  x-parser-schema-id: <anonymous-schema-242>
                data:
                  oneOf:
                    - &ref_7
                      type: array
                      description: >-
                        Current watchlists for the signed-in user. The same list
                        shape is used in the first subscribe reply and later
                        watchlist events.
                      items:
                        type: object
                        description: >-
                          One saved watchlist from
                          shared/domains/watchlist.Watchlist.
                        properties:
                          id:
                            type: integer
                            description: Watchlist ID.
                            x-parser-schema-id: <anonymous-schema-147>
                          name:
                            type: string
                            description: User-facing watchlist name.
                            x-parser-schema-id: <anonymous-schema-148>
                          symbols:
                            type: array
                            items:
                              type: string
                              x-parser-schema-id: <anonymous-schema-150>
                            description: Symbols currently saved in the watchlist.
                            x-parser-schema-id: <anonymous-schema-149>
                        x-parser-schema-id: WatchlistEntry
                      x-parser-schema-id: WatchlistSnapshotData
                    - type: object
                      description: News update data sent for the `news` topic.
                      properties:
                        msgType:
                          type: string
                          x-parser-schema-id: <anonymous-schema-244>
                        items:
                          type: array
                          items: &ref_8
                            type: object
                            description: One news item.
                            properties:
                              id:
                                type: integer
                                description: Unique news ID.
                                x-parser-schema-id: <anonymous-schema-151>
                              title:
                                type: string
                                description: Article title.
                                x-parser-schema-id: <anonymous-schema-152>
                              news_type:
                                type: string
                                description: News type, for example news or press_release.
                                x-parser-schema-id: <anonymous-schema-153>
                              symbols:
                                type: array
                                items:
                                  type: string
                                  x-parser-schema-id: <anonymous-schema-155>
                                description: Related symbols.
                                x-parser-schema-id: <anonymous-schema-154>
                              authors:
                                type: array
                                items:
                                  type: string
                                  x-parser-schema-id: <anonymous-schema-157>
                                description: Article authors.
                                x-parser-schema-id: <anonymous-schema-156>
                              timestamp:
                                type: string
                                format: date-time
                                description: Publication timestamp.
                                x-parser-schema-id: <anonymous-schema-158>
                              body:
                                type: string
                                description: Full article content when available.
                                x-parser-schema-id: <anonymous-schema-159>
                              action:
                                type: string
                                description: Action string when available.
                                x-parser-schema-id: <anonymous-schema-160>
                            x-parser-schema-id: NewsItem
                          x-parser-schema-id: <anonymous-schema-245>
                      x-parser-schema-id: NewsEventData
                  x-parser-schema-id: <anonymous-schema-243>
              x-parser-schema-id: <anonymous-schema-241>
          x-parser-schema-id: TopicEventPayload
        title: Watchlist Update
        description: Real-time watchlist updates
        example: |-
          {
            "type": "event",
            "timestamp": "2024-01-15T14:30:00Z",
            "payload": {
              "topic": "watchlist",
              "data": [
                {
                  "id": 101,
                  "name": "Core holdings",
                  "symbols": [
                    "AAPL",
                    "MSFT",
                    "NVDA",
                    "TSLA"
                  ]
                },
                {
                  "id": 205,
                  "name": "Earnings radar",
                  "symbols": [
                    "AMD"
                  ]
                }
              ]
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: watchlistUpdate
    bindings: []
    extensions: *ref_0
  - &ref_21
    id: receiveNewsUpdate
    title: News Update
    description: Receive news feed updates
    type: send
    messages:
      - &ref_40
        id: newsUpdate
        contentType: application/json
        payload:
          - name: News Update
            description: Real-time news updates
            type: object
            properties:
              - name: type
                type: string
                description: Top-level message type. Always `event` for watchlist/news.
                enumValues:
                  - event
                required: false
              - name: timestamp
                type: string
                description: Time when the server sent this event, in RFC3339 format.
                required: false
              - name: payload
                type: object
                description: The topic name and the data for that event.
                required: false
                properties:
                  - name: topic
                    type: string
                    description: Topic identifier
                    enumValues:
                      - watchlist
                      - news
                    required: false
                  - name: data
                    type: oneOf
                    required: false
                    properties:
                      - name: id
                        type: integer
                        description: Watchlist ID.
                        required: false
                      - name: name
                        type: string
                        description: User-facing watchlist name.
                        required: false
                      - name: symbols
                        type: array
                        description: Symbols currently saved in the watchlist.
                        required: false
                        properties:
                          - name: item
                            type: string
                            required: false
                      - name: msgType
                        type: string
                        required: false
                      - name: items
                        type: array
                        required: false
                        properties:
                          - name: id
                            type: integer
                            description: Unique news ID.
                            required: false
                          - name: title
                            type: string
                            description: Article title.
                            required: false
                          - name: news_type
                            type: string
                            description: News type, for example news or press_release.
                            required: false
                          - name: symbols
                            type: array
                            description: Related symbols.
                            required: false
                            properties:
                              - name: item
                                type: string
                                required: false
                          - name: authors
                            type: array
                            description: Article authors.
                            required: false
                            properties:
                              - name: item
                                type: string
                                required: false
                          - name: timestamp
                            type: string
                            description: Publication timestamp.
                            required: false
                          - name: body
                            type: string
                            description: Full article content when available.
                            required: false
                          - name: action
                            type: string
                            description: Action string when available.
                            required: false
        headers: []
        jsonPayloadSchema: *ref_3
        title: News Update
        description: Real-time news updates
        example: |-
          {
            "type": "event",
            "timestamp": "2024-01-15T14:30:00Z",
            "payload": {
              "topic": "news",
              "data": {
                "msgType": "add",
                "items": [
                  {
                    "id": 12345,
                    "title": "Fed Announces Rate Decision",
                    "news_type": "news",
                    "authors": [
                      "Reuters"
                    ],
                    "timestamp": "2024-01-15T14:30:00Z",
                    "symbols": [
                      "SPY",
                      "QQQ"
                    ]
                  }
                ]
              }
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: newsUpdate
    bindings: []
    extensions: *ref_0
  - &ref_22
    id: receiveError
    title: Error Response
    description: Receive error messages
    type: send
    messages:
      - &ref_41
        id: errorResponse
        contentType: application/json
        payload:
          - name: Error
            description: Error response
            type: object
            properties:
              - name: type
                type: string
                description: Top-level message type. Always `response` for errors.
                enumValues:
                  - response
                required: false
              - name: id
                type: string
                description: >-
                  Request ID from the message that caused this error, if there
                  was one.
                required: false
              - name: timestamp
                type: string
                description: Time when the server sent this error, in RFC3339 format.
                required: false
              - name: payload
                type: object
                description: Error details returned by the server.
                required: false
                properties:
                  - name: status
                    type: integer
                    description: Status code for the error, such as `400`, `401`, or `403`.
                    required: false
                  - name: error
                    type: string
                    description: Human-readable error message
                    required: false
                  - name: code
                    type: string
                    description: >-
                      Machine-readable error code (e.g. MISSING_ACCOUNT_ID,
                      INVALID_TOKEN)
                    required: false
                  - name: topic
                    type: string
                    description: Topic that caused the error (for subscription errors)
                    required: false
        headers: []
        jsonPayloadSchema:
          type: object
          description: Error response from server.
          properties:
            type:
              type: string
              enum:
                - response
              description: Top-level message type. Always `response` for errors.
              x-parser-schema-id: <anonymous-schema-246>
            id:
              type: string
              description: >-
                Request ID from the message that caused this error, if there was
                one.
              x-parser-schema-id: <anonymous-schema-247>
            timestamp:
              type: string
              description: Time when the server sent this error, in RFC3339 format.
              x-parser-schema-id: <anonymous-schema-248>
            payload:
              type: object
              description: Error details returned by the server.
              properties:
                status:
                  type: integer
                  description: Status code for the error, such as `400`, `401`, or `403`.
                  x-parser-schema-id: <anonymous-schema-250>
                error:
                  type: string
                  description: Human-readable error message
                  x-parser-schema-id: <anonymous-schema-251>
                code:
                  type: string
                  description: >-
                    Machine-readable error code (e.g. MISSING_ACCOUNT_ID,
                    INVALID_TOKEN)
                  x-parser-schema-id: <anonymous-schema-252>
                topic:
                  type: string
                  description: Topic that caused the error (for subscription errors)
                  x-parser-schema-id: <anonymous-schema-253>
              x-parser-schema-id: <anonymous-schema-249>
          x-parser-schema-id: ErrorResponsePayload
        title: Error
        description: Error response
        example: |-
          {
            "type": "response",
            "id": "req-002",
            "timestamp": "2024-01-15T10:30:00Z",
            "payload": {
              "status": 400,
              "error": "accountId is required",
              "code": "MISSING_ACCOUNT_ID"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: errorResponse
    bindings: []
    extensions: *ref_0
  - &ref_23
    id: receiveAuthSuccess
    title: Auth success
    description: Successful authentication response
    type: send
    messages:
      - &ref_42
        id: authSuccess
        contentType: application/json
        payload:
          - name: Authentication Success
            description: Authentication succeeded
            type: object
            properties:
              - name: type
                type: string
                description: The server sets this to `event` for auth status messages.
                enumValues:
                  - event
                required: false
              - name: payload
                type: object
                required: false
                properties:
                  - name: action
                    type: string
                    description: >-
                      Sign-in result or sign-in status. `authSuccess` means you
                      can start subscribing. `authError` means the token was
                      rejected. The other values are sent by the server as the
                      connection ages.
                    enumValues:
                      - authSuccess
                      - authError
                      - authTimeout
                      - authExpired
                      - refreshAuth
                    required: false
                  - name: data
                    type: object
                    description: Action-specific data
                    required: false
                  - name: id
                    type: string
                    description: >-
                      Request ID from your client message, or `system` if this
                      event was sent by the server on its own.
                    required: false
                  - name: timestamp
                    type: integer
                    description: Unix timestamp in milliseconds
                    required: false
        headers: []
        jsonPayloadSchema: *ref_1
        title: Authentication Success
        description: Authentication succeeded
        example: |-
          {
            "type": "event",
            "payload": {
              "action": "authSuccess",
              "data": {
                "expiresIn": 3900000
              },
              "id": "auth-001",
              "timestamp": 1703001234567
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: authSuccess
    bindings: []
    extensions: *ref_0
  - &ref_24
    id: receiveAuthTimeout
    title: Auth timeout
    description: Authentication window expired
    type: send
    messages:
      - &ref_43
        id: authTimeout
        contentType: application/json
        payload:
          - name: Authentication Timeout
            description: Authentication timed out
            type: object
            properties:
              - name: type
                type: string
                description: The server sets this to `event` for auth status messages.
                enumValues:
                  - event
                required: false
              - name: payload
                type: object
                required: false
                properties:
                  - name: action
                    type: string
                    description: >-
                      Sign-in result or sign-in status. `authSuccess` means you
                      can start subscribing. `authError` means the token was
                      rejected. The other values are sent by the server as the
                      connection ages.
                    enumValues:
                      - authSuccess
                      - authError
                      - authTimeout
                      - authExpired
                      - refreshAuth
                    required: false
                  - name: data
                    type: object
                    description: Action-specific data
                    required: false
                  - name: id
                    type: string
                    description: >-
                      Request ID from your client message, or `system` if this
                      event was sent by the server on its own.
                    required: false
                  - name: timestamp
                    type: integer
                    description: Unix timestamp in milliseconds
                    required: false
        headers: []
        jsonPayloadSchema: *ref_1
        title: Authentication Timeout
        description: Authentication timed out
        example: |-
          {
            "type": "event",
            "payload": {
              "action": "authTimeout",
              "data": {
                "error": "authentication timeout"
              },
              "id": "system",
              "timestamp": 1703001234567
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: authTimeout
    bindings: []
    extensions: *ref_0
  - &ref_25
    id: receiveSubscribed
    title: Subscribed confirmation
    description: Subscription confirmed with optional snapshot
    type: send
    messages:
      - &ref_44
        id: subscribedResponse
        contentType: application/json
        payload:
          - name: Subscribed
            description: Subscription confirmed with snapshot
            type: object
            properties:
              - name: type
                type: string
                description: Message type. Always `subscribed` (ack from server).
                enumValues:
                  - subscribed
                required: false
              - name: id
                type: string
                description: Request ID from your subscribe message.
                required: false
              - name: timestamp
                type: string
                description: Time when the server sent this reply, in RFC3339 format.
                required: false
              - name: payload
                type: object
                required: false
                properties:
                  - name: status
                    type: integer
                    description: >-
                      Status code for the subscribe request. `200` means
                      success.
                    required: false
                  - name: topic
                    type: string
                    description: Subscription topic
                    enumValues:
                      - account
                      - pnl
                      - watchlist
                      - news
                    required: false
                  - name: params
                    type: object
                    description: Echo of subscription params
                    required: false
                  - name: data
                    type: oneOf
                    description: Snapshot data for the subscribed topic.
                    required: false
                    properties:
                      - name: account
                        type: object
                        description: >-
                          Merged account and balance snapshot delivered after
                          you subscribe to the `account` topic.
                        required: true
                        properties:
                          - name: accountNumber
                            type: string
                            description: Sterling account ID.
                            required: false
                          - name: accountType
                            type: string
                            required: false
                          - name: accountClass
                            type: string
                            required: false
                          - name: optionsLevel
                            type: string
                            required: false
                          - name: cashAvailable
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: netLiquidity
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: marginEquity
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: maintenanceExcess
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: accruedCash
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: exchangeSurplus
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: sma
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: maintReq
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: sodPositionsMarketValue
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: netBuyingPower
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: stockBuyingPower
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: dayTradeBuyingPower
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: optionBuyingPower
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: dayTradeOvernightRegTBuyingPower
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: totalEquity
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: settledFunds
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: unsettledFunds
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: heldBackFunds
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: grossMargin
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: pendingOrdersMarginRequirements
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: realizedPL
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: unRealizedPL
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: pendingOrdersCount
                            type: integer
                            description: Number of pending orders.
                            required: false
                          - name: credit
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: creditRemaining
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: smaCreditRemaining
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: pdtCreditRemaining
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: startOfDayCash
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: valueBought
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: valueSold
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: sodTtlEquity
                            type: string
                            description: Optional start-of-day total equity.
                            required: false
                          - name: sodTtlEquityUpdatedAt
                            type: string
                            description: Optional timestamp for sodTtlEquity.
                            required: false
                          - name: isOptionLevelEnable
                            type: boolean
                            description: Whether options level is enabled for the account.
                            required: false
                          - name: amountAvailableToWithdraw
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                          - name: fullyPaidUnsettledFunds
                            type: string
                            description: Decimal value serialized as a string.
                            required: false
                      - name: positions
                        type: array
                        required: true
                        properties:
                          - name: accountId
                            type: string
                            description: Sterling account ID.
                            required: false
                          - name: symbol
                            type: string
                            description: Equity or OCC option symbol.
                            required: false
                          - name: securityType
                            type: string
                            description: Security type, for example EQUITY or OPTION.
                            required: false
                          - name: qty
                            type: string
                            description: Position quantity serialized as a string.
                            required: false
                          - name: avgPrice
                            type: string
                            description: Average position price serialized as a string.
                            required: false
                          - name: avgCost
                            type: string
                            description: Backward-compatible alias of avgPrice.
                            required: false
                          - name: unRealizedPL
                            type: string
                            description: Unrealized P&L serialized as a string.
                            required: false
                          - name: todayRealizedPnL
                            type: string
                            description: Today realized P&L serialized as a string.
                            required: false
                          - name: realizedPL
                            type: string
                            description: Backward-compatible alias of todayRealizedPnL.
                            required: false
                          - name: todayPL
                            type: string
                            description: Today total P&L serialized as a string.
                            required: false
                          - name: instrument
                            type: string
                            description: Backward-compatible alias of securityType.
                            required: false
                          - name: putCall
                            type: string
                            description: CALL or PUT for options.
                            required: false
                          - name: strikePrice
                            type: string
                            description: Option strike price serialized as a string.
                            required: false
                          - name: maturity
                            type: string
                            description: Option maturity date in YYYY-MM-DD format.
                            required: false
                          - name: flags
                            type: integer
                            description: Position flags.
                            required: false
                          - name: createdAt
                            type: string
                            description: Creation timestamp.
                            required: false
                          - name: updatedAt
                            type: string
                            description: Last update timestamp.
                            required: false
                      - name: orders
                        type: array
                        description: Legacy recent orders snapshot.
                        required: true
                        properties:
                          - name: clOrdId
                            type: string
                            description: Client order ID.
                            required: false
                          - name: ordId
                            type: string
                            description: Broker/order ID.
                            required: false
                          - name: origClOrdId
                            type: string
                            description: Original client order ID for replaces/cancels.
                            required: false
                          - name: accountId
                            type: string
                            description: Sterling account ID.
                            required: false
                          - name: clientId
                            type: string
                            description: Client/user ID.
                            required: false
                          - name: symbol
                            type: string
                            description: Trading symbol.
                            required: false
                          - name: side
                            type: string
                            description: Order side, for example BUY or SELL.
                            required: false
                          - name: type
                            type: string
                            description: Order type, for example LIMIT or MARKET.
                            required: false
                          - name: timeInForce
                            type: string
                            description: Time in force, for example DAY.
                            required: false
                          - name: qty
                            type: string
                            description: Order quantity serialized as a string.
                            required: false
                          - name: price
                            type: string
                            description: Limit price serialized as a string.
                            required: false
                          - name: stopPrice
                            type: string
                            description: Stop price serialized as a string.
                            required: false
                          - name: ordStatus
                            type: string
                            description: Order status.
                            enumValues:
                              - NEW
                              - PARTIALLY_FILLED
                              - FILLED
                              - DONE_FOR_DAY
                              - CANCELED
                              - REPLACED
                              - PENDING_CANCEL
                              - STOPPED
                              - REJECTED
                              - SUSPENDED
                              - PENDING_NEW
                              - CALCULATED
                              - EXPIRED
                              - ACCEPTED_FOR_BID
                              - PENDING_REPLACE
                              - SUPERSEDED
                            required: false
                          - name: cumQty
                            type: string
                            description: Cumulative filled quantity serialized as a string.
                            required: false
                          - name: leavesQty
                            type: string
                            description: Remaining open quantity serialized as a string.
                            required: false
                          - name: avgPrice
                            type: string
                            description: Average execution price serialized as a string.
                            required: false
                          - name: currency
                            type: string
                            description: Currency code.
                            required: false
                          - name: exDestination
                            type: string
                            description: >-
                              Execution destination, for example MNGDFTE or
                              MNGD.
                            required: false
                          - name: text
                            type: string
                            description: Broker or venue message.
                            required: false
                          - name: ordRejReason
                            type: string
                            description: Order reject reason when present.
                            required: false
                          - name: securityType
                            type: string
                            description: Security type, for example EQUITY or OPTION.
                            required: false
                          - name: category
                            type: string
                            description: >-
                              Order category, for example EQUITY, SINGLE_LEG, or
                              MULTI_LEG.
                            required: false
                          - name: legs
                            type: array
                            required: false
                            properties:
                              - name: symbol
                                type: string
                                description: Underlying or option symbol.
                                required: false
                              - name: side
                                type: string
                                description: Order side, for example BUY or SELL.
                                required: false
                              - name: ratioQty
                                type: string
                                description: Leg ratio quantity serialized as a string.
                                required: false
                              - name: securityType
                                type: string
                                description: Security type, for example OPTION.
                                required: false
                              - name: maturity
                                type: string
                                description: Option maturity date in YYYY-MM-DD format.
                                required: false
                              - name: strikePrice
                                type: string
                                description: Option strike price serialized as a string.
                                required: false
                              - name: positionEffect
                                type: string
                                description: Position effect, for example OPEN or CLOSE.
                                required: false
                              - name: putCall
                                type: string
                                description: Option side, CALL or PUT.
                                required: false
                              - name: avgPrice
                                type: string
                                description: >-
                                  Average fill price for the leg, serialized as
                                  a string.
                                required: false
                          - name: execId
                            type: string
                            description: Execution ID for fill events.
                            required: false
                          - name: execType
                            type: string
                            description: >-
                              Execution type, for example NEW, FILL,
                              PARTIAL_FILL, or REJECTED.
                            required: false
                          - name: lastPx
                            type: string
                            description: Last execution price serialized as a string.
                            required: false
                          - name: lastQty
                            type: string
                            description: Last execution quantity serialized as a string.
                            required: false
                          - name: maturity
                            type: string
                            description: >-
                              Flat option maturity when sent on single-leg
                              option orders.
                            required: false
                          - name: putCall
                            type: string
                            description: Flat option side, CALL or PUT.
                            required: false
                          - name: strikePrice
                            type: string
                            description: Flat option strike price serialized as a string.
                            required: false
                          - name: positionEffect
                            type: string
                            description: Flat option position effect.
                            required: false
                          - name: createdAt
                            type: string
                            description: Creation timestamp.
                            required: false
                          - name: updatedAt
                            type: string
                            description: Last update timestamp.
                            required: false
                      - name: ordersV2
                        type: array
                        description: >-
                          Orders v2 cache snapshot. Empty array when
                          unavailable.
                        required: true
                        properties:
                          - name: clOrdId
                            type: string
                            description: Client order ID.
                            required: false
                          - name: ordId
                            type: string
                            description: Broker/order ID.
                            required: false
                          - name: origClOrdId
                            type: string
                            description: Original client order ID for replaces/cancels.
                            required: false
                          - name: accountId
                            type: string
                            description: Sterling account ID.
                            required: false
                          - name: clientId
                            type: string
                            description: Client/user ID.
                            required: false
                          - name: symbol
                            type: string
                            description: Trading symbol.
                            required: false
                          - name: side
                            type: string
                            description: Order side, for example BUY or SELL.
                            required: false
                          - name: type
                            type: string
                            description: Order type, for example LIMIT or MARKET.
                            required: false
                          - name: timeInForce
                            type: string
                            description: Time in force, for example DAY.
                            required: false
                          - name: qty
                            type: string
                            description: Order quantity serialized as a string.
                            required: false
                          - name: price
                            type: string
                            description: Limit price serialized as a string.
                            required: false
                          - name: stopPrice
                            type: string
                            description: Stop price serialized as a string.
                            required: false
                          - name: ordStatus
                            type: string
                            description: Order status.
                            enumValues:
                              - NEW
                              - PARTIALLY_FILLED
                              - FILLED
                              - DONE_FOR_DAY
                              - CANCELED
                              - REPLACED
                              - PENDING_CANCEL
                              - STOPPED
                              - REJECTED
                              - SUSPENDED
                              - PENDING_NEW
                              - CALCULATED
                              - EXPIRED
                              - ACCEPTED_FOR_BID
                              - PENDING_REPLACE
                              - SUPERSEDED
                            required: false
                          - name: cumQty
                            type: string
                            description: Cumulative filled quantity serialized as a string.
                            required: false
                          - name: leavesQty
                            type: string
                            description: Remaining open quantity serialized as a string.
                            required: false
                          - name: avgPrice
                            type: string
                            description: Average execution price serialized as a string.
                            required: false
                          - name: currency
                            type: string
                            description: Currency code.
                            required: false
                          - name: exDestination
                            type: string
                            description: >-
                              Execution destination, for example MNGDFTE or
                              MNGD.
                            required: false
                          - name: text
                            type: string
                            description: Broker or venue message.
                            required: false
                          - name: ordRejReason
                            type: string
                            description: Order reject reason when present.
                            required: false
                          - name: securityType
                            type: string
                            description: Security type, for example EQUITY or OPTION.
                            required: false
                          - name: category
                            type: string
                            description: >-
                              Order category, for example EQUITY, SINGLE_LEG, or
                              MULTI_LEG.
                            required: false
                          - name: legs
                            type: array
                            required: false
                            properties:
                              - name: symbol
                                type: string
                                description: Underlying or option symbol.
                                required: false
                              - name: side
                                type: string
                                description: Order side, for example BUY or SELL.
                                required: false
                              - name: ratioQty
                                type: string
                                description: Leg ratio quantity serialized as a string.
                                required: false
                              - name: securityType
                                type: string
                                description: Security type, for example OPTION.
                                required: false
                              - name: maturity
                                type: string
                                description: Option maturity date in YYYY-MM-DD format.
                                required: false
                              - name: strikePrice
                                type: string
                                description: Option strike price serialized as a string.
                                required: false
                              - name: positionEffect
                                type: string
                                description: Position effect, for example OPEN or CLOSE.
                                required: false
                              - name: putCall
                                type: string
                                description: Option side, CALL or PUT.
                                required: false
                              - name: avgPrice
                                type: string
                                description: >-
                                  Average fill price for the leg, serialized as
                                  a string.
                                required: false
                          - name: execId
                            type: string
                            description: Execution ID for fill events.
                            required: false
                          - name: execType
                            type: string
                            description: >-
                              Execution type, for example NEW, FILL,
                              PARTIAL_FILL, or REJECTED.
                            required: false
                          - name: lastPx
                            type: string
                            description: Last execution price serialized as a string.
                            required: false
                          - name: lastQty
                            type: string
                            description: Last execution quantity serialized as a string.
                            required: false
                          - name: maturity
                            type: string
                            description: >-
                              Flat option maturity when sent on single-leg
                              option orders.
                            required: false
                          - name: putCall
                            type: string
                            description: Flat option side, CALL or PUT.
                            required: false
                          - name: strikePrice
                            type: string
                            description: Flat option strike price serialized as a string.
                            required: false
                          - name: positionEffect
                            type: string
                            description: Flat option position effect.
                            required: false
                          - name: createdAt
                            type: string
                            description: Creation timestamp.
                            required: false
                          - name: updatedAt
                            type: string
                            description: Last update timestamp.
                            required: false
                      - name: error
                        type: string
                        description: >-
                          Optional partial snapshot error, for example failed to
                          fetch: positions.
                        required: false
                      - name: accountId
                        type: string
                        description: Sterling account ID.
                        required: false
                      - name: interval
                        type: string
                        description: Candle interval.
                        required: false
                      - name: t
                        type: array
                        description: Unix timestamps in seconds.
                        required: false
                        properties:
                          - name: item
                            type: integer
                            required: false
                      - name: c
                        type: array
                        description: Close/equity values.
                        required: false
                        properties:
                          - name: item
                            type: number
                            required: false
                      - name: id
                        type: integer
                        description: Watchlist ID.
                        required: false
                      - name: name
                        type: string
                        description: User-facing watchlist name.
                        required: false
                      - name: symbols
                        type: array
                        description: Symbols currently saved in the watchlist.
                        required: false
                        properties:
                          - name: item
                            type: string
                            required: false
                      - name: id
                        type: integer
                        description: Unique news ID.
                        required: false
                      - name: title
                        type: string
                        description: Article title.
                        required: false
                      - name: news_type
                        type: string
                        description: News type, for example news or press_release.
                        required: false
                      - name: symbols
                        type: array
                        description: Related symbols.
                        required: false
                        properties:
                          - name: item
                            type: string
                            required: false
                      - name: authors
                        type: array
                        description: Article authors.
                        required: false
                        properties:
                          - name: item
                            type: string
                            required: false
                      - name: timestamp
                        type: string
                        description: Publication timestamp.
                        required: false
                      - name: body
                        type: string
                        description: Full article content when available.
                        required: false
                      - name: action
                        type: string
                        description: Action string when available.
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          description: Subscribed confirmation message from server.
          properties:
            type:
              type: string
              enum:
                - subscribed
              description: Message type. Always `subscribed` (ack from server).
              x-parser-schema-id: <anonymous-schema-31>
            id:
              type: string
              description: Request ID from your subscribe message.
              x-parser-schema-id: <anonymous-schema-32>
            timestamp:
              type: string
              description: Time when the server sent this reply, in RFC3339 format.
              x-parser-schema-id: <anonymous-schema-33>
            payload:
              type: object
              properties:
                status:
                  type: integer
                  description: Status code for the subscribe request. `200` means success.
                  x-parser-schema-id: <anonymous-schema-35>
                topic:
                  type: string
                  enum:
                    - account
                    - pnl
                    - watchlist
                    - news
                  description: Subscription topic
                  x-parser-schema-id: <anonymous-schema-36>
                params:
                  type: object
                  description: Echo of subscription params
                  x-parser-schema-id: <anonymous-schema-37>
                data:
                  oneOf:
                    - type: object
                      description: >-
                        Initial account snapshot returned with account
                        subscriptions.
                      required:
                        - account
                        - positions
                        - orders
                        - ordersV2
                      properties:
                        account:
                          type: object
                          description: >-
                            Merged account and balance snapshot delivered after
                            you subscribe to the `account` topic.
                          properties:
                            accountNumber:
                              type: string
                              description: Sterling account ID.
                              x-parser-schema-id: <anonymous-schema-39>
                            accountType:
                              type: string
                              x-parser-schema-id: <anonymous-schema-40>
                            accountClass:
                              type: string
                              x-parser-schema-id: <anonymous-schema-41>
                            optionsLevel:
                              type: string
                              x-parser-schema-id: <anonymous-schema-42>
                            cashAvailable:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-43>
                            netLiquidity:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-44>
                            marginEquity:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-45>
                            maintenanceExcess:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-46>
                            accruedCash:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-47>
                            exchangeSurplus:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-48>
                            sma:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-49>
                            maintReq:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-50>
                            sodPositionsMarketValue:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-51>
                            netBuyingPower:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-52>
                            stockBuyingPower:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-53>
                            dayTradeBuyingPower:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-54>
                            optionBuyingPower:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-55>
                            dayTradeOvernightRegTBuyingPower:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-56>
                            totalEquity:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-57>
                            settledFunds:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-58>
                            unsettledFunds:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-59>
                            heldBackFunds:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-60>
                            grossMargin:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-61>
                            pendingOrdersMarginRequirements:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-62>
                            realizedPL:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-63>
                            unRealizedPL:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-64>
                            pendingOrdersCount:
                              type: integer
                              description: Number of pending orders.
                              x-parser-schema-id: <anonymous-schema-65>
                            credit:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-66>
                            creditRemaining:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-67>
                            smaCreditRemaining:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-68>
                            pdtCreditRemaining:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-69>
                            startOfDayCash:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-70>
                            valueBought:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-71>
                            valueSold:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-72>
                            sodTtlEquity:
                              type: string
                              description: Optional start-of-day total equity.
                              x-parser-schema-id: <anonymous-schema-73>
                            sodTtlEquityUpdatedAt:
                              type: string
                              format: date-time
                              description: Optional timestamp for sodTtlEquity.
                              x-parser-schema-id: <anonymous-schema-74>
                            isOptionLevelEnable:
                              type: boolean
                              description: >-
                                Whether options level is enabled for the
                                account.
                              x-parser-schema-id: <anonymous-schema-75>
                            amountAvailableToWithdraw:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-76>
                            fullyPaidUnsettledFunds:
                              type: string
                              description: Decimal value serialized as a string.
                              x-parser-schema-id: <anonymous-schema-77>
                          x-parser-schema-id: AccountSnapshotAccount
                        positions:
                          type: array
                          items: *ref_4
                          x-parser-schema-id: <anonymous-schema-78>
                        orders:
                          type: array
                          items: *ref_5
                          description: Legacy recent orders snapshot.
                          x-parser-schema-id: <anonymous-schema-96>
                        ordersV2:
                          type: array
                          items: *ref_5
                          description: >-
                            Orders v2 cache snapshot. Empty array when
                            unavailable.
                          x-parser-schema-id: <anonymous-schema-139>
                        error:
                          type: string
                          description: >-
                            Optional partial snapshot error, for example failed
                            to fetch: positions.
                          x-parser-schema-id: <anonymous-schema-140>
                      x-parser-schema-id: AccountSnapshotData
                    - *ref_6
                    - *ref_7
                    - type: array
                      description: >-
                        Initial news snapshot returned after a news subscription
                        succeeds.
                      items: *ref_8
                      x-parser-schema-id: NewsSnapshotData
                  description: Snapshot data for the subscribed topic.
                  x-parser-schema-id: <anonymous-schema-38>
              x-parser-schema-id: <anonymous-schema-34>
          x-parser-schema-id: SubscribedResponsePayload
        title: Subscribed
        description: Subscription confirmed with snapshot
        example: |-
          {
            "type": "subscribed",
            "id": "req-002",
            "timestamp": "2024-01-15T10:30:00Z",
            "payload": {
              "status": 200,
              "topic": "account",
              "params": {
                "accountId": "ACC123456"
              },
              "data": {
                "account": {
                  "accountNumber": "ACC123456",
                  "accountType": "MARGIN",
                  "accountClass": "INDIVIDUAL",
                  "optionsLevel": "LEVEL_3",
                  "cashAvailable": "25155.00",
                  "netLiquidity": "50155.00",
                  "marginEquity": "50155.00",
                  "maintenanceExcess": "17508.50",
                  "sma": "25155.00",
                  "maintReq": "7646.50",
                  "netBuyingPower": "25155.00",
                  "stockBuyingPower": "50310.00",
                  "dayTradeBuyingPower": "100620.00",
                  "optionBuyingPower": "25155.00",
                  "totalEquity": "50155.00",
                  "pendingOrdersCount": 0
                },
                "positions": [],
                "orders": [],
                "ordersV2": []
              }
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribedResponse
    bindings: []
    extensions: *ref_0
  - &ref_26
    id: receiveUnsubscribeResponse
    title: Unsubscribe confirmation
    description: Unsubscribe acknowledged
    type: send
    messages:
      - &ref_45
        id: unsubscribeResponse
        contentType: application/json
        payload:
          - name: Unsubscription Confirmed
            description: Server confirms unsubscription
            type: object
            properties:
              - name: type
                type: string
                description: Top-level message type. Always `response` for this ack.
                enumValues:
                  - response
                required: false
              - name: id
                type: string
                description: Request ID from your unsubscribe message.
                required: false
              - name: timestamp
                type: string
                description: Time when the server sent this reply, in RFC3339 format.
                required: false
              - name: payload
                type: object
                description: Status and optional data for the unsubscribe result.
                required: false
                properties:
                  - name: status
                    type: integer
                    description: >-
                      Status code for the unsubscribe request. `200` means
                      success.
                    required: false
                  - name: data
                    type: object
                    required: false
                    properties:
                      - name: unsubscribed
                        type: boolean
                        required: false
                      - name: topic
                        type: string
                        required: false
                      - name: accountId
                        type: string
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          description: Unsubscribe confirmation from server.
          properties:
            type:
              type: string
              enum:
                - response
              description: Top-level message type. Always `response` for this ack.
              x-parser-schema-id: <anonymous-schema-168>
            id:
              type: string
              description: Request ID from your unsubscribe message.
              x-parser-schema-id: <anonymous-schema-169>
            timestamp:
              type: string
              description: Time when the server sent this reply, in RFC3339 format.
              x-parser-schema-id: <anonymous-schema-170>
            payload:
              type: object
              description: Status and optional data for the unsubscribe result.
              properties:
                status:
                  type: integer
                  description: >-
                    Status code for the unsubscribe request. `200` means
                    success.
                  x-parser-schema-id: <anonymous-schema-172>
                data:
                  type: object
                  properties:
                    unsubscribed:
                      type: boolean
                      x-parser-schema-id: <anonymous-schema-174>
                    topic:
                      type: string
                      x-parser-schema-id: <anonymous-schema-175>
                    accountId:
                      type: string
                      x-parser-schema-id: <anonymous-schema-176>
                  x-parser-schema-id: <anonymous-schema-173>
              x-parser-schema-id: <anonymous-schema-171>
          x-parser-schema-id: UnsubscribeResponsePayload
        title: Unsubscription Confirmed
        description: Server confirms unsubscription
        example: |-
          {
            "type": "response",
            "id": "req-006",
            "timestamp": "2024-01-15T10:30:00Z",
            "payload": {
              "status": 200,
              "data": {
                "unsubscribed": true,
                "topic": "account",
                "accountId": "ACC123456"
              }
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: unsubscribeResponse
    bindings: []
    extensions: *ref_0
  - &ref_27
    id: receivePong
    title: Pong
    description: Ping response
    type: send
    messages:
      - &ref_46
        id: pongResponse
        contentType: application/json
        payload:
          - name: Pong
            description: Keep-alive pong response
            type: object
            properties:
              - name: type
                type: string
                description: Message type. Always `pong` (reply to ping).
                enumValues:
                  - pong
                required: false
              - name: id
                type: string
                description: Request ID copied from your ping, if you sent one.
                required: false
              - name: timestamp
                type: string
                description: Time when the server sent this `pong`, in RFC3339 format.
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          description: Pong response from server.
          properties:
            type:
              type: string
              enum:
                - pong
              description: Message type. Always `pong` (reply to ping).
              x-parser-schema-id: <anonymous-schema-16>
            id:
              type: string
              description: Request ID copied from your ping, if you sent one.
              x-parser-schema-id: <anonymous-schema-17>
            timestamp:
              type: string
              description: Time when the server sent this `pong`, in RFC3339 format.
              x-parser-schema-id: <anonymous-schema-18>
          x-parser-schema-id: PongPayload
        title: Pong
        description: Keep-alive pong response
        example: |-
          {
            "type": "pong",
            "id": "ping-001",
            "timestamp": "2024-01-15T10:30:00Z"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: pongResponse
    bindings: []
    extensions: *ref_0
sendOperations:
  - *ref_9
  - *ref_10
  - *ref_11
  - *ref_12
receiveOperations:
  - *ref_13
  - *ref_14
  - *ref_15
  - *ref_16
  - *ref_17
  - *ref_18
  - *ref_19
  - *ref_20
  - *ref_21
  - *ref_22
  - *ref_23
  - *ref_24
  - *ref_25
  - *ref_26
  - *ref_27
sendMessages:
  - *ref_28
  - *ref_29
  - *ref_30
  - *ref_31
receiveMessages:
  - *ref_32
  - *ref_33
  - *ref_34
  - *ref_35
  - *ref_36
  - *ref_37
  - *ref_38
  - *ref_39
  - *ref_40
  - *ref_41
  - *ref_42
  - *ref_43
  - *ref_44
  - *ref_45
  - *ref_46
extensions:
  - id: x-parser-unique-object-id
    value: accountUpdatesStream
securitySchemes: []

````