{
  "asyncapi": "3.1.0",
  "info": {
    "title": "Edel Markets product WebSocket contract",
    "version": "realtime-contract/v1",
    "description": "Realtime market and account channel schemas for Edel Markets. Confirm channel availability in your integration environment.",
    "contact": {
      "name": "Edel",
      "url": "https://edel.finance"
    }
  },
  "defaultContentType": "application/json",
  "channels": {
    "market.trades": {
      "address": "market.trades",
      "title": "Market Trades",
      "summary": "public market realtime updates.",
      "description": "Public executed-trade updates. No authentication is required. Subscribe and use supported stream replay; this channel has no REST snapshot.",
      "messages": {
        "RealtimeMarketTradePayload": {
          "$ref": "#/components/messages/RealtimeMarketTradePayload"
        }
      },
      "x-edel-auth": "none",
      "x-edel-snapshot-source": "no REST snapshot -- subscribe and replay from the stream",
      "x-edel-source-status": "live"
    },
    "market.book": {
      "address": "market.book",
      "title": "Market Book",
      "summary": "public market realtime updates.",
      "description": "Complete projected order-book snapshots containing the top price levels. No authentication is required. Replace the previous levels after validating sequence metadata; messages are not additive price-level deltas.",
      "messages": {
        "RealtimeMarketBookPayload": {
          "$ref": "#/components/messages/RealtimeMarketBookPayload"
        }
      },
      "x-edel-auth": "none",
      "x-edel-snapshot-source": "GET /v1/markets/{marketId}/book",
      "x-edel-source-status": "projection"
    },
    "market.ticker": {
      "address": "market.ticker",
      "title": "Market Ticker",
      "summary": "public market realtime updates.",
      "description": "The latest executed trade with 24-hour volume, change, high and low derived from one-minute candle data. No authentication is required. The newest ticker is replayed when a subscription is accepted.",
      "messages": {
        "RealtimeMarketTickerPayload": {
          "$ref": "#/components/messages/RealtimeMarketTickerPayload"
        }
      },
      "x-edel-auth": "none",
      "x-edel-snapshot-source": "GET /v1/markets/{marketId}/stats",
      "x-edel-source-status": "derived"
    },
    "market.price": {
      "address": "market.price",
      "title": "Market Price",
      "summary": "public market realtime updates.",
      "description": "Market price observations, including the price fields and provider information defined by the payload. No authentication is required. Subscribe and use supported stream replay; this channel has no REST snapshot.",
      "messages": {
        "RealtimeMarketPricePayload": {
          "$ref": "#/components/messages/RealtimeMarketPricePayload"
        }
      },
      "x-edel-auth": "none",
      "x-edel-snapshot-source": "no REST snapshot -- subscribe and replay from the stream",
      "x-edel-source-status": "live"
    },
    "market.funding": {
      "address": "market.funding",
      "title": "Market Funding",
      "summary": "public market realtime updates.",
      "description": "Updates from settled funding periods. No authentication is required. Use the payload fields to distinguish the reported funding state from an estimated future payment.",
      "messages": {
        "RealtimeMarketFundingPayload": {
          "$ref": "#/components/messages/RealtimeMarketFundingPayload"
        }
      },
      "x-edel-auth": "none",
      "x-edel-snapshot-source": "GET /v1/markets/{marketId}/stats",
      "x-edel-source-status": "live"
    },
    "market.status": {
      "address": "market.status",
      "title": "Market Status",
      "summary": "public market realtime updates.",
      "description": "Projected market-status updates. No authentication is required. Only statuses currently used by markets produce updates.",
      "messages": {
        "RealtimeMarketStatusPayload": {
          "$ref": "#/components/messages/RealtimeMarketStatusPayload"
        }
      },
      "x-edel-auth": "none",
      "x-edel-snapshot-source": "GET /v1/markets/{marketId}",
      "x-edel-source-status": "projection"
    },
    "market.candles": {
      "address": "market.candles",
      "title": "Market Candles",
      "summary": "public market realtime updates.",
      "description": "Index and trade candle updates derived from price observations and executed trades. No authentication is required. Select the required series when subscribing; mark candles are unavailable.",
      "messages": {
        "RealtimeMarketCandlePayload": {
          "$ref": "#/components/messages/RealtimeMarketCandlePayload"
        }
      },
      "x-edel-auth": "none",
      "x-edel-snapshot-source": "GET /v1/markets/{marketId}/candles",
      "x-edel-source-status": "live"
    },
    "account.orders": {
      "address": "account.orders",
      "title": "Account Orders",
      "summary": "private account realtime updates.",
      "description": "Order lifecycle updates for the authenticated account. Authenticate with an account-bound realtime ticket before subscribing.",
      "messages": {
        "RealtimeAccountOrderPayload": {
          "$ref": "#/components/messages/RealtimeAccountOrderPayload"
        }
      },
      "x-edel-auth": "realtime ticket, sent in an auth frame before subscribing",
      "x-edel-snapshot-source": "GET /v1/accounts/{accountId}/orders",
      "x-edel-source-status": "live"
    },
    "account.fills": {
      "address": "account.fills",
      "title": "Account Fills",
      "summary": "private account realtime updates.",
      "description": "The authenticated account\u2019s side of executed fills. Authenticate with an account-bound realtime ticket before subscribing.",
      "messages": {
        "RealtimeAccountFillPayload": {
          "$ref": "#/components/messages/RealtimeAccountFillPayload"
        }
      },
      "x-edel-auth": "realtime ticket, sent in an auth frame before subscribing",
      "x-edel-snapshot-source": "GET /v1/accounts/{accountId}/fills",
      "x-edel-source-status": "live"
    },
    "account.durability": {
      "address": "account.durability",
      "title": "Account Durability",
      "summary": "private account realtime updates.",
      "description": "Off-chain durability progress for account-related records, including cash changes, funding settlement and trade activity. Frames identify the sequence source and covering group and storage-chain digests where provided. Authenticate with an account-bound realtime ticket before subscribing. Durability progress is distinct from Canton settlement confirmation.",
      "messages": {
        "RealtimeAccountDurabilityPayload": {
          "$ref": "#/components/messages/RealtimeAccountDurabilityPayload"
        }
      },
      "x-edel-auth": "realtime ticket, sent in an auth frame before subscribing",
      "x-edel-snapshot-source": "no REST snapshot -- subscribe and replay from the stream",
      "x-edel-source-status": "live"
    },
    "account.positions": {
      "address": "account.positions",
      "title": "Account Positions",
      "summary": "private account realtime updates.",
      "description": "Position updates and risk-state changes for the authenticated account. Some updates contain position data with partial risk evidence; others indicate a risk-state change requiring reconciliation. Apply only the fields established by the payload and preserve incomplete state explicitly. Authenticate with an account-bound realtime ticket before subscribing.",
      "messages": {
        "RealtimeAccountPositionPayload": {
          "$ref": "#/components/messages/RealtimeAccountPositionPayload"
        }
      },
      "x-edel-auth": "realtime ticket, sent in an auth frame before subscribing",
      "x-edel-snapshot-source": "GET /v1/accounts/{accountId}/positions",
      "x-edel-source-status": "live"
    },
    "account.pnl": {
      "address": "account.pnl",
      "title": "Account Pnl",
      "summary": "private account realtime updates.",
      "description": "Position-related realized and unrealized PnL updates for the authenticated account. Authenticate with an account-bound realtime ticket before subscribing.",
      "messages": {
        "RealtimeAccountPnlPayload": {
          "$ref": "#/components/messages/RealtimeAccountPnlPayload"
        }
      },
      "x-edel-auth": "realtime ticket, sent in an auth frame before subscribing",
      "x-edel-snapshot-source": "no REST snapshot -- subscribe and replay from the stream",
      "x-edel-source-status": "live"
    },
    "account.margin": {
      "address": "account.margin",
      "title": "Account Margin",
      "summary": "private account realtime updates.",
      "description": "Margin updates for the authenticated account. Payloads may contain exact margin values or indicate a changed risk-state digest. A digest alone is not a complete margin snapshot. Authenticate with an account-bound realtime ticket before subscribing.",
      "messages": {
        "RealtimeAccountMarginPayload": {
          "$ref": "#/components/messages/RealtimeAccountMarginPayload"
        }
      },
      "x-edel-auth": "realtime ticket, sent in an auth frame before subscribing",
      "x-edel-snapshot-source": "GET /v1/accounts/{accountId}",
      "x-edel-source-status": "digest"
    },
    "account.balance": {
      "address": "account.balance",
      "title": "Account Balance",
      "summary": "private account realtime updates.",
      "description": "Signed balance changes from credited deposits and settled withdrawals. The resulting cashAtoms value is provided by the account snapshot; do not infer a complete current balance from a change alone. Authenticate with an account-bound realtime ticket before subscribing.",
      "messages": {
        "RealtimeAccountBalancePayload": {
          "$ref": "#/components/messages/RealtimeAccountBalancePayload"
        }
      },
      "x-edel-auth": "realtime ticket, sent in an auth frame before subscribing",
      "x-edel-snapshot-source": "GET /v1/accounts/{accountId}",
      "x-edel-source-status": "live"
    },
    "account.withdrawals": {
      "address": "account.withdrawals",
      "title": "Account Withdrawals",
      "summary": "private account realtime updates.",
      "description": "Withdrawal lifecycle updates for the authenticated account. Each update reports a status change and the terminal reason where provided. Authenticate with an account-bound realtime ticket before subscribing.",
      "messages": {
        "RealtimeAccountWithdrawalPayload": {
          "$ref": "#/components/messages/RealtimeAccountWithdrawalPayload"
        }
      },
      "x-edel-auth": "realtime ticket, sent in an auth frame before subscribing",
      "x-edel-snapshot-source": "no REST snapshot -- subscribe and replay from the stream",
      "x-edel-source-status": "live"
    },
    "account.reconciliation": {
      "address": "account.reconciliation",
      "title": "Account Reconciliation",
      "summary": "private account realtime updates.",
      "description": "Account reconciliation information. This channel is currently unavailable. An account-bound realtime ticket is required for private subscriptions.",
      "messages": {
        "RealtimeAccountReconciliationPayload": {
          "$ref": "#/components/messages/RealtimeAccountReconciliationPayload"
        }
      },
      "x-edel-auth": "realtime ticket, sent in an auth frame before subscribing",
      "x-edel-snapshot-source": "no REST snapshot -- subscribe and replay from the stream",
      "x-edel-source-status": "unavailable"
    },
    "account.alerts": {
      "address": "account.alerts",
      "title": "Account Alerts",
      "summary": "private account realtime updates.",
      "description": "Account alert information. This channel is currently unavailable. An account-bound realtime ticket is required for private subscriptions.",
      "messages": {
        "RealtimeAccountAlertPayload": {
          "$ref": "#/components/messages/RealtimeAccountAlertPayload"
        }
      },
      "x-edel-auth": "realtime ticket, sent in an auth frame before subscribing",
      "x-edel-snapshot-source": "no REST snapshot -- subscribe and replay from the stream",
      "x-edel-source-status": "unavailable"
    },
    "account.earnings": {
      "address": "account.earnings",
      "title": "Account Earnings",
      "summary": "private account realtime updates.",
      "description": "Projected affiliate earnings for the authenticated account. Subscriptions require the affiliate capability to be enabled and current; otherwise they return source_unavailable. Authenticate with an account-bound realtime ticket before subscribing.",
      "messages": {
        "RealtimeAccountEarningsPayload": {
          "$ref": "#/components/messages/RealtimeAccountEarningsPayload"
        }
      },
      "x-edel-auth": "realtime ticket, sent in an auth frame before subscribing",
      "x-edel-snapshot-source": "GET /v1/accounts/{accountId}/affiliate/earnings",
      "x-edel-source-status": "projection"
    }
  },
  "operations": {
    "receiveMarketTrades": {
      "action": "receive",
      "summary": "Receive market.trades data.",
      "channel": {
        "$ref": "#/channels/market.trades"
      },
      "messages": [
        {
          "$ref": "#/channels/market.trades/messages/RealtimeMarketTradePayload"
        }
      ]
    },
    "receiveMarketBook": {
      "action": "receive",
      "summary": "Receive market.book data.",
      "channel": {
        "$ref": "#/channels/market.book"
      },
      "messages": [
        {
          "$ref": "#/channels/market.book/messages/RealtimeMarketBookPayload"
        }
      ]
    },
    "receiveMarketTicker": {
      "action": "receive",
      "summary": "Receive market.ticker data.",
      "channel": {
        "$ref": "#/channels/market.ticker"
      },
      "messages": [
        {
          "$ref": "#/channels/market.ticker/messages/RealtimeMarketTickerPayload"
        }
      ]
    },
    "receiveMarketPrice": {
      "action": "receive",
      "summary": "Receive market.price data.",
      "channel": {
        "$ref": "#/channels/market.price"
      },
      "messages": [
        {
          "$ref": "#/channels/market.price/messages/RealtimeMarketPricePayload"
        }
      ]
    },
    "receiveMarketFunding": {
      "action": "receive",
      "summary": "Receive market.funding data.",
      "channel": {
        "$ref": "#/channels/market.funding"
      },
      "messages": [
        {
          "$ref": "#/channels/market.funding/messages/RealtimeMarketFundingPayload"
        }
      ]
    },
    "receiveMarketStatus": {
      "action": "receive",
      "summary": "Receive market.status data.",
      "channel": {
        "$ref": "#/channels/market.status"
      },
      "messages": [
        {
          "$ref": "#/channels/market.status/messages/RealtimeMarketStatusPayload"
        }
      ]
    },
    "receiveMarketCandles": {
      "action": "receive",
      "summary": "Receive market.candles data.",
      "channel": {
        "$ref": "#/channels/market.candles"
      },
      "messages": [
        {
          "$ref": "#/channels/market.candles/messages/RealtimeMarketCandlePayload"
        }
      ]
    },
    "receiveAccountOrders": {
      "action": "receive",
      "summary": "Receive account.orders data.",
      "channel": {
        "$ref": "#/channels/account.orders"
      },
      "messages": [
        {
          "$ref": "#/channels/account.orders/messages/RealtimeAccountOrderPayload"
        }
      ]
    },
    "receiveAccountFills": {
      "action": "receive",
      "summary": "Receive account.fills data.",
      "channel": {
        "$ref": "#/channels/account.fills"
      },
      "messages": [
        {
          "$ref": "#/channels/account.fills/messages/RealtimeAccountFillPayload"
        }
      ]
    },
    "receiveAccountDurability": {
      "action": "receive",
      "summary": "Receive account.durability data.",
      "channel": {
        "$ref": "#/channels/account.durability"
      },
      "messages": [
        {
          "$ref": "#/channels/account.durability/messages/RealtimeAccountDurabilityPayload"
        }
      ]
    },
    "receiveAccountPositions": {
      "action": "receive",
      "summary": "Receive account.positions data.",
      "channel": {
        "$ref": "#/channels/account.positions"
      },
      "messages": [
        {
          "$ref": "#/channels/account.positions/messages/RealtimeAccountPositionPayload"
        }
      ]
    },
    "receiveAccountPnl": {
      "action": "receive",
      "summary": "Receive account.pnl data.",
      "channel": {
        "$ref": "#/channels/account.pnl"
      },
      "messages": [
        {
          "$ref": "#/channels/account.pnl/messages/RealtimeAccountPnlPayload"
        }
      ]
    },
    "receiveAccountMargin": {
      "action": "receive",
      "summary": "Receive account.margin data.",
      "channel": {
        "$ref": "#/channels/account.margin"
      },
      "messages": [
        {
          "$ref": "#/channels/account.margin/messages/RealtimeAccountMarginPayload"
        }
      ]
    },
    "receiveAccountBalance": {
      "action": "receive",
      "summary": "Receive account.balance data.",
      "channel": {
        "$ref": "#/channels/account.balance"
      },
      "messages": [
        {
          "$ref": "#/channels/account.balance/messages/RealtimeAccountBalancePayload"
        }
      ]
    },
    "receiveAccountWithdrawals": {
      "action": "receive",
      "summary": "Receive account.withdrawals data.",
      "channel": {
        "$ref": "#/channels/account.withdrawals"
      },
      "messages": [
        {
          "$ref": "#/channels/account.withdrawals/messages/RealtimeAccountWithdrawalPayload"
        }
      ]
    },
    "receiveAccountReconciliation": {
      "action": "receive",
      "summary": "Receive account.reconciliation data.",
      "channel": {
        "$ref": "#/channels/account.reconciliation"
      },
      "messages": [
        {
          "$ref": "#/channels/account.reconciliation/messages/RealtimeAccountReconciliationPayload"
        }
      ]
    },
    "receiveAccountAlerts": {
      "action": "receive",
      "summary": "Receive account.alerts data.",
      "channel": {
        "$ref": "#/channels/account.alerts"
      },
      "messages": [
        {
          "$ref": "#/channels/account.alerts/messages/RealtimeAccountAlertPayload"
        }
      ]
    },
    "receiveAccountEarnings": {
      "action": "receive",
      "summary": "Receive account.earnings data.",
      "channel": {
        "$ref": "#/channels/account.earnings"
      },
      "messages": [
        {
          "$ref": "#/channels/account.earnings/messages/RealtimeAccountEarningsPayload"
        }
      ]
    }
  },
  "x-edel-websocket-path": "/streams/v1/ws",
  "x-edel-contract-path": "/streams/v1/contract",
  "x-edel-catalog-path": "/streams/v1/catalog",
  "x-edel-heartbeat-interval-ms": 10000,
  "x-edel-reconnect": {
    "gapErrorCode": "sequence_gap",
    "resyncErrorCode": "resync_required",
    "snapshotRequired": true
  },
  "components": {
    "messages": {
      "RealtimeAccountAlertPayload": {
        "name": "RealtimeAccountAlertPayload",
        "title": "Account Alerts data",
        "summary": "A data message for account.alerts.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeAccountAlertPayloadMessage"
        }
      },
      "RealtimeAccountBalancePayload": {
        "name": "RealtimeAccountBalancePayload",
        "title": "Account Balance data",
        "summary": "A data message for account.balance.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeAccountBalancePayloadMessage"
        }
      },
      "RealtimeAccountDurabilityPayload": {
        "name": "RealtimeAccountDurabilityPayload",
        "title": "Account Durability data",
        "summary": "A data message for account.durability.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeAccountDurabilityPayloadMessage"
        }
      },
      "RealtimeAccountEarningsPayload": {
        "name": "RealtimeAccountEarningsPayload",
        "title": "Account Earnings data",
        "summary": "A data message for account.earnings.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeAccountEarningsPayloadMessage"
        }
      },
      "RealtimeAccountFillPayload": {
        "name": "RealtimeAccountFillPayload",
        "title": "Account Fills data",
        "summary": "A data message for account.fills.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeAccountFillPayloadMessage"
        }
      },
      "RealtimeAccountMarginPayload": {
        "name": "RealtimeAccountMarginPayload",
        "title": "Account Margin data",
        "summary": "A data message for account.margin.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeAccountMarginPayloadMessage"
        }
      },
      "RealtimeAccountOrderPayload": {
        "name": "RealtimeAccountOrderPayload",
        "title": "Account Orders data",
        "summary": "A data message for account.orders.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeAccountOrderPayloadMessage"
        }
      },
      "RealtimeAccountPnlPayload": {
        "name": "RealtimeAccountPnlPayload",
        "title": "Account Pnl data",
        "summary": "A data message for account.pnl.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeAccountPnlPayloadMessage"
        }
      },
      "RealtimeAccountPositionPayload": {
        "name": "RealtimeAccountPositionPayload",
        "title": "Account Positions data",
        "summary": "A data message for account.positions.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeAccountPositionPayloadMessage"
        }
      },
      "RealtimeAccountReconciliationPayload": {
        "name": "RealtimeAccountReconciliationPayload",
        "title": "Account Reconciliation data",
        "summary": "A data message for account.reconciliation.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeAccountReconciliationPayloadMessage"
        }
      },
      "RealtimeAccountWithdrawalPayload": {
        "name": "RealtimeAccountWithdrawalPayload",
        "title": "Account Withdrawals data",
        "summary": "A data message for account.withdrawals.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeAccountWithdrawalPayloadMessage"
        }
      },
      "RealtimeMarketBookPayload": {
        "name": "RealtimeMarketBookPayload",
        "title": "Market Book data",
        "summary": "A data message for market.book.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeMarketBookPayloadMessage"
        }
      },
      "RealtimeMarketCandlePayload": {
        "name": "RealtimeMarketCandlePayload",
        "title": "Market Candles data",
        "summary": "A data message for market.candles.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeMarketCandlePayloadMessage"
        }
      },
      "RealtimeMarketFundingPayload": {
        "name": "RealtimeMarketFundingPayload",
        "title": "Market Funding data",
        "summary": "A data message for market.funding.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeMarketFundingPayloadMessage"
        }
      },
      "RealtimeMarketPricePayload": {
        "name": "RealtimeMarketPricePayload",
        "title": "Market Price data",
        "summary": "A data message for market.price.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeMarketPricePayloadMessage"
        }
      },
      "RealtimeMarketStatusPayload": {
        "name": "RealtimeMarketStatusPayload",
        "title": "Market Status data",
        "summary": "A data message for market.status.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeMarketStatusPayloadMessage"
        }
      },
      "RealtimeMarketTickerPayload": {
        "name": "RealtimeMarketTickerPayload",
        "title": "Market Ticker data",
        "summary": "A data message for market.ticker.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeMarketTickerPayloadMessage"
        }
      },
      "RealtimeMarketTradePayload": {
        "name": "RealtimeMarketTradePayload",
        "title": "Market Trades data",
        "summary": "A data message for market.trades.",
        "contentType": "application/json",
        "payload": {
          "$ref": "#/components/schemas/RealtimeMarketTradePayloadMessage"
        }
      }
    },
    "schemas": {
      "RealtimeAccountAlertPayload": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "minLength": 1
          },
          "severity": {
            "type": "string",
            "enum": [
              "info",
              "warning",
              "critical"
            ]
          },
          "message": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "code",
          "severity",
          "message",
          "accountId"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountAlertPayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "account.alerts"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "private"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeAccountAlertPayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountBalancePayload": {
        "type": "object",
        "properties": {
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "asset": {
            "type": "string",
            "minLength": 1
          },
          "changeAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "source": {
            "type": "string",
            "enum": [
              "deposit",
              "settlement",
              "withdrawal",
              "funding"
            ]
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "cashAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "journalSource": {
            "type": "string",
            "enum": [
              "main",
              "trades",
              "risk",
              "market_data",
              "withdrawal_gateway"
            ]
          }
        },
        "required": [
          "accountId",
          "asset",
          "changeAtoms",
          "source",
          "sequence",
          "journalSource"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountBalancePayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "account.balance"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "private"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeAccountBalancePayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountDurabilityPayload": {
        "type": "object",
        "properties": {
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "stage": {
            "type": "string",
            "const": "saved",
            "description": "Always `saved`, meaning durably persisted off-chain. On-chain settlement requires per-record confirmation and is not established by this watermark."
          },
          "source": {
            "type": "string",
            "enum": [
              "main",
              "trades",
              "risk",
              "market_data",
              "withdrawal_gateway"
            ],
            "description": "Identifies the sequence source measured by `savedThroughSequence`. account.orders uses `main` and account.fills uses `trades`. Compare a record only with the watermark for its own source; sequence numbers from different sources are not interchangeable."
          },
          "savedThroughSequence": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "description": "Every record of the named source at or below this sequence is durably stored. A later frame includes earlier progress, allowing a client to recover a missed watermark update. Fill durability depends on both the fill record and the records of its matched orders; track all relevant source watermarks."
          },
          "durableAtEpochMs": {
            "type": "integer",
            "minimum": 0,
            "description": "The time the durability advance was observed, not the time the underlying write completed. Do not calculate durability latency by subtracting an order timestamp from this observation time."
          },
          "nativeCommitment": {
            "type": "object",
            "properties": {
              "committedThroughOrdinal": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "minimum": -9007199254740991,
                "maximum": 9007199254740991,
                "description": "The committed record ordinal when nativeCommitment is present. It matches `savedThroughSequence` and identifies progress in one shared record sequence, rather than independent per-source counters."
              },
              "coveringGroupDigest": {
                "type": "string",
                "pattern": "^sha256:[a-f0-9]{64}$",
                "description": "The group marker digest covering that ordinal."
              },
              "storageChainDigest": {
                "type": "string",
                "pattern": "^sha256:[a-f0-9]{64}$",
                "description": "The storage chain digest at that ordinal."
              }
            },
            "required": [
              "committedThroughOrdinal",
              "coveringGroupDigest",
              "storageChainDigest"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "accountId",
          "stage",
          "source",
          "savedThroughSequence",
          "durableAtEpochMs"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountDurabilityPayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "account.durability"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "private"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeAccountDurabilityPayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountEarningsPayload": {
        "type": "object",
        "properties": {
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "affiliateId": {
            "type": "string",
            "minLength": 1
          },
          "settlementId": {
            "type": "string",
            "minLength": 1
          },
          "feeAsset": {
            "type": "string",
            "minLength": 1
          },
          "periodStartEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "periodEndEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "settledFeeAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "source": {
            "type": "string",
            "enum": [
              "paid_fee_atoms"
            ]
          },
          "throughJournalSequence": {
            "type": "integer",
            "minimum": 0
          },
          "fillCount": {
            "type": "integer",
            "minimum": 0
          },
          "settledAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "acknowledgedShortfall": {
            "type": "object",
            "properties": {
              "journalSequences": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                },
                "minItems": 1
              },
              "reason": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "journalSequences",
              "reason"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "accountId",
          "affiliateId",
          "settlementId",
          "feeAsset",
          "periodStartEpochMs",
          "periodEndEpochMs",
          "settledFeeAtoms",
          "source",
          "throughJournalSequence",
          "fillCount",
          "settledAtEpochMs"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountEarningsPayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "account.earnings"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "private"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeAccountEarningsPayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountFillPayload": {
        "type": "object",
        "properties": {
          "tradeId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "role": {
            "type": "string",
            "enum": [
              "maker",
              "taker"
            ]
          },
          "feePaidAtoms": {
            "type": "string",
            "pattern": "^[0-9]+$"
          },
          "feeRole": {
            "type": "string",
            "enum": [
              "maker",
              "taker"
            ]
          },
          "side": {
            "type": "string",
            "enum": [
              "buy",
              "sell"
            ]
          },
          "priceAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "sizeAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "orderId": {
            "type": "string",
            "minLength": 1
          },
          "counterpartyOrderId": {
            "type": "string",
            "minLength": 1
          },
          "origin": {
            "type": "string",
            "enum": [
              "liquidation",
              "auto_deleverage"
            ]
          }
        },
        "required": [
          "tradeId",
          "accountId",
          "marketId",
          "role",
          "feePaidAtoms",
          "feeRole",
          "side",
          "priceAtoms",
          "sizeAtoms",
          "orderId",
          "counterpartyOrderId"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountFillPayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "account.fills"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "private"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeAccountFillPayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountMarginPayload": {
        "type": "object",
        "properties": {
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "accountRootHash": {
            "type": "string",
            "pattern": "^sha256:[0-9a-f]{64}$"
          },
          "journalSequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "cashBalanceAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "equityAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "availableForOrdersAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "marketDataSequence": {
            "type": "integer",
            "minimum": 0
          },
          "maintenanceRequirementAtoms": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "The maintenance margin the account must hold across all of its positions, in settlement-asset atoms."
          },
          "marginHealthBps": {
            "type": "string",
            "pattern": "^-?[0-9]+$",
            "description": "Equity divided by the maintenance requirement, in basis points. 10000 is exactly at maintenance and is also reported when nothing is at risk. Signed; absent when it cannot be computed."
          },
          "liquidationCandidate": {
            "type": "boolean",
            "description": "True while the account's equity is below its maintenance requirement or it holds bad debt. A candidate cannot withdraw or add risk, and the venue may close its positions."
          },
          "badDebtAtoms": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "A liquidation loss that neither the order book, the insurance fund nor auto-deleveraging covered, in settlement-asset atoms. The account stays blocked while it is above 0. A liquidation fee or an insurance fund cover appears only as a change in the cash balance, never here."
          }
        },
        "required": [
          "accountId",
          "accountRootHash",
          "journalSequence",
          "cashBalanceAtoms",
          "equityAtoms",
          "availableForOrdersAtoms"
        ],
        "additionalProperties": false,
        "description": "The account's margin as the execution engine holds it. Liquidation fees and insurance fund draws are not sent as separate events yet; each appears only as a change in the account's cash balance here."
      },
      "RealtimeAccountMarginPayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "account.margin"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "private"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeAccountMarginPayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountOrderPayload": {
        "type": "object",
        "properties": {
          "orderId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "commandType": {
            "type": "string",
            "minLength": 1
          },
          "cancelReason": {
            "type": "string",
            "enum": [
              "margin_unbacked",
              "risk_evidence_incomplete",
              "market_session_closed",
              "reduce_only_position_unavailable"
            ]
          },
          "side": {
            "type": "string",
            "enum": [
              "buy",
              "sell"
            ]
          },
          "priceAtoms": {
            "type": "string",
            "pattern": "^[0-9]+$"
          },
          "quantityAtoms": {
            "type": "string",
            "pattern": "^[0-9]+$"
          },
          "remainingQuantityAtoms": {
            "type": "string",
            "pattern": "^[0-9]+$"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "partially_filled"
            ]
          },
          "origin": {
            "type": "string",
            "enum": [
              "liquidation",
              "auto_deleverage"
            ]
          }
        },
        "required": [
          "orderId",
          "accountId",
          "marketId",
          "commandType"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountOrderPayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "account.orders"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "private"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeAccountOrderPayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountPnlPayload": {
        "type": "object",
        "properties": {
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "journalSequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "signedBaseAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "entryNotionalAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "entryPriceAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "markPriceAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "unrealizedPnlAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "realizedPnlAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "realizedPnlDeltaAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "marketDataSequence": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "accountId",
          "marketId",
          "journalSequence",
          "signedBaseAtoms",
          "entryNotionalAtoms",
          "entryPriceAtoms",
          "markPriceAtoms",
          "unrealizedPnlAtoms",
          "realizedPnlAtoms",
          "realizedPnlDeltaAtoms"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountPnlPayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "account.pnl"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "private"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeAccountPnlPayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountPositionPayload": {
        "type": "object",
        "properties": {
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "accountRootHash": {
            "type": "string",
            "pattern": "^sha256:[0-9a-f]{64}$"
          },
          "journalSequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "signedBaseAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "entryNotionalAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "entryPriceAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "markPriceAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "unrealizedPnlAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "realizedPnlDeltaAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "riskEvidence": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "const": "complete"
                  }
                },
                "required": [
                  "status"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "const": "incomplete"
                  },
                  "reasonCode": {
                    "type": "string",
                    "enum": [
                      "legacy_unknown",
                      "missing_accepted_mark"
                    ]
                  }
                },
                "required": [
                  "status",
                  "reasonCode"
                ],
                "additionalProperties": false
              }
            ]
          },
          "closed": {
            "type": "boolean",
            "const": true
          },
          "marketDataSequence": {
            "type": "integer",
            "minimum": 0
          },
          "adlIndicator": {
            "type": "integer",
            "minimum": 1,
            "maximum": 5,
            "description": "The position's place in its market's auto-deleveraging queue, from 1 to 5; 5 is reduced first if an opposite position becomes bankrupt beyond what the order book and the insurance fund absorb. For display only. It is refreshed on each liquidation pass, so it can trail the latest mark, and is absent until the market has been ranked."
          }
        },
        "required": [
          "accountId",
          "journalSequence"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountPositionPayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "account.positions"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "private"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeAccountPositionPayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountReconciliationPayload": {
        "type": "object",
        "properties": {
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "classification": {
            "type": "string",
            "enum": [
              "none",
              "warning",
              "withdrawal_blocking",
              "incident"
            ]
          },
          "withdrawalsBlocked": {
            "type": "boolean"
          },
          "reasonCodes": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "severity": {
            "type": "string",
            "enum": [
              "sev1",
              "sev2"
            ]
          }
        },
        "required": [
          "accountId",
          "classification",
          "withdrawalsBlocked",
          "reasonCodes"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountReconciliationPayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "account.reconciliation"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "private"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeAccountReconciliationPayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountWithdrawalPayload": {
        "type": "object",
        "properties": {
          "withdrawalId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "asset": {
            "type": "string",
            "minLength": 1
          },
          "amountAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "status": {
            "type": "string",
            "enum": [
              "requested",
              "margin_reserved",
              "authorized",
              "submitted",
              "settled",
              "rejected",
              "expired",
              "failed"
            ]
          },
          "reasonCode": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "withdrawalId",
          "accountId",
          "asset",
          "amountAtoms",
          "status"
        ],
        "additionalProperties": false
      },
      "RealtimeAccountWithdrawalPayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "account.withdrawals"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "private"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeAccountWithdrawalPayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      },
      "RealtimeMarketBookPayload": {
        "type": "object",
        "properties": {
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "snapshotSequence": {
            "type": "integer",
            "minimum": 0
          },
          "bids": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "priceAtoms": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                },
                "price": {
                  "type": "string",
                  "pattern": "^-?[0-9]+\\.[0-9]+$"
                },
                "sizeAtoms": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                },
                "size": {
                  "type": "string",
                  "pattern": "^-?[0-9]+\\.[0-9]+$"
                }
              },
              "required": [
                "priceAtoms",
                "price",
                "sizeAtoms",
                "size"
              ],
              "additionalProperties": false
            }
          },
          "asks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "priceAtoms": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                },
                "price": {
                  "type": "string",
                  "pattern": "^-?[0-9]+\\.[0-9]+$"
                },
                "sizeAtoms": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                },
                "size": {
                  "type": "string",
                  "pattern": "^-?[0-9]+\\.[0-9]+$"
                }
              },
              "required": [
                "priceAtoms",
                "price",
                "sizeAtoms",
                "size"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "marketId",
          "snapshotSequence",
          "bids",
          "asks"
        ],
        "additionalProperties": false
      },
      "RealtimeMarketBookPayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "market.book"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "public"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeMarketBookPayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      },
      "RealtimeMarketCandlePayload": {
        "type": "object",
        "properties": {
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "series": {
            "type": "string",
            "enum": [
              "trade",
              "index",
              "mark"
            ]
          },
          "timeframe": {
            "type": "string",
            "enum": [
              "1m",
              "3m",
              "5m",
              "15m",
              "30m",
              "1h",
              "2h",
              "4h",
              "8h",
              "12h",
              "1d",
              "3d",
              "1w",
              "1M"
            ]
          },
          "bucketStartEpochMs": {
            "type": "integer",
            "minimum": 0
          },
          "open": {
            "type": "string",
            "minLength": 1
          },
          "high": {
            "type": "string",
            "minLength": 1
          },
          "low": {
            "type": "string",
            "minLength": 1
          },
          "close": {
            "type": "string",
            "minLength": 1
          },
          "volume": {
            "type": "string",
            "minLength": 1
          },
          "source": {
            "type": "string",
            "enum": [
              "trade",
              "index",
              "external"
            ]
          }
        },
        "required": [
          "marketId",
          "series",
          "timeframe",
          "bucketStartEpochMs",
          "open",
          "high",
          "low",
          "close",
          "volume",
          "source"
        ],
        "additionalProperties": false
      },
      "RealtimeMarketCandlePayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "market.candles"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "public"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeMarketCandlePayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      },
      "RealtimeMarketFundingPayload": {
        "type": "object",
        "properties": {
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "checkpointSequence": {
            "type": "integer",
            "minimum": 0
          },
          "fundingTimeEpochMs": {
            "type": "integer",
            "minimum": 0
          },
          "nextFundingTimeEpochMs": {
            "type": "integer",
            "minimum": 0
          },
          "fundingIntervalMs": {
            "type": "integer",
            "minimum": 0
          },
          "status": {
            "type": "string",
            "minLength": 1
          },
          "fundingRateBps": {
            "type": "string",
            "minLength": 1
          },
          "premiumBps": {
            "type": "string",
            "minLength": 1
          },
          "twapPremiumBps": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "marketId",
          "checkpointSequence",
          "fundingTimeEpochMs",
          "nextFundingTimeEpochMs",
          "fundingIntervalMs",
          "status",
          "fundingRateBps",
          "premiumBps"
        ],
        "additionalProperties": false
      },
      "RealtimeMarketFundingPayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "market.funding"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "public"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeMarketFundingPayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      },
      "RealtimeMarketPricePayload": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "market-price/v1"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "epoch": {
            "type": "integer",
            "minimum": 0
          },
          "receivedAtEpochMs": {
            "type": "integer",
            "minimum": 0
          },
          "indexPriceAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "markPriceAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "primaryPriceAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "comparatorPriceAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "primaryProvider": {
            "type": "string",
            "minLength": 1
          },
          "comparatorProvider": {
            "type": "string",
            "minLength": 1
          },
          "confidenceBps": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "version",
          "marketId",
          "epoch",
          "receivedAtEpochMs",
          "indexPriceAtoms",
          "markPriceAtoms",
          "primaryPriceAtoms",
          "comparatorPriceAtoms",
          "primaryProvider",
          "comparatorProvider",
          "confidenceBps"
        ],
        "additionalProperties": false
      },
      "RealtimeMarketPricePayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "market.price"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "public"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeMarketPricePayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      },
      "RealtimeMarketStatusPayload": {
        "type": "object",
        "properties": {
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "cancel_only",
              "paused",
              "halted",
              "reduce_only"
            ]
          },
          "reason": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "marketId",
          "status"
        ],
        "additionalProperties": false
      },
      "RealtimeMarketStatusPayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "market.status"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "public"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeMarketStatusPayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      },
      "RealtimeMarketTickerPayload": {
        "type": "object",
        "properties": {
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "lastTradeId": {
            "type": "string",
            "minLength": 1
          },
          "lastPriceAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "lastSizeAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "volume24hQuoteAtoms": {
            "type": "string",
            "pattern": "^[0-9]+$"
          },
          "openInterestBaseAtoms": {
            "type": "string",
            "pattern": "^[0-9]+$"
          },
          "openInterestQuoteAtoms": {
            "type": "string",
            "pattern": "^[0-9]+$"
          },
          "change24hBps": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "high24hAtoms": {
            "type": "string",
            "pattern": "^[0-9]+$"
          },
          "low24hAtoms": {
            "type": "string",
            "pattern": "^[0-9]+$"
          },
          "predictedFundingRateBps": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          }
        },
        "required": [
          "marketId",
          "lastTradeId",
          "lastPriceAtoms",
          "lastSizeAtoms"
        ],
        "additionalProperties": false
      },
      "RealtimeMarketTickerPayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "market.ticker"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "public"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeMarketTickerPayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      },
      "RealtimeMarketTradePayload": {
        "type": "object",
        "properties": {
          "tradeId": {
            "type": "string",
            "minLength": 1
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "priceAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "sizeAtoms": {
            "type": "string",
            "pattern": "^-?[0-9]+$"
          },
          "takerSide": {
            "type": "string",
            "enum": [
              "buy",
              "sell"
            ]
          },
          "makerOrderId": {
            "type": "string",
            "minLength": 1
          },
          "takerOrderId": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "tradeId",
          "marketId",
          "priceAtoms",
          "sizeAtoms",
          "takerSide",
          "makerOrderId",
          "takerOrderId"
        ],
        "additionalProperties": false
      },
      "RealtimeMarketTradePayloadMessage": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "const": "realtime-stream/v1"
          },
          "messageId": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "const": "data"
          },
          "channel": {
            "type": "string",
            "const": "market.trades"
          },
          "sequence": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "occurredAtEpochMs": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "visibility": {
            "type": "string",
            "const": "public"
          },
          "marketId": {
            "type": "string",
            "minLength": 1
          },
          "accountId": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "enum": [
              "local",
              "development",
              "staging",
              "production"
            ]
          },
          "checkpoint": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "journal",
                  "projection",
                  "system"
                ]
              },
              "journalSequence": {
                "type": "integer",
                "minimum": 0
              },
              "journalRecordHash": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$"
              },
              "readModelSequence": {
                "type": "integer",
                "minimum": 0
              },
              "readModelDigest": {
                "type": "string",
                "pattern": "^sha256:[0-9a-f]{64}$",
                "description": "Identifies the projection state paired with `readModelSequence`; both are required when `kind` is `projection`. Digest coverage is channel-specific and may describe payload data, stored records or a projection checkpoint. Use it to detect changes within the same channel. Do not assume it can be recomputed from the message payload."
              },
              "sourceEventId": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": false
          },
          "payload": {
            "$ref": "#/components/schemas/RealtimeMarketTradePayload"
          }
        },
        "required": [
          "version",
          "messageId",
          "type",
          "channel",
          "sequence",
          "occurredAtEpochMs",
          "visibility",
          "checkpoint",
          "payload"
        ],
        "additionalProperties": false
      }
    }
  }
}
