Skip to content

feat(market-data): send the account identity with market data - #16

Open
Edgex-Fly wants to merge 1 commit into
edgex-Tech:mainfrom
Edgex-Fly:feat/member-market-data-identity
Open

Edgex-Fly wants to merge 1 commit into
edgex-Tech:mainfrom
Edgex-Fly:feat/member-market-data-identity

Conversation

@Edgex-Fly

Copy link
Copy Markdown
Contributor

Problem

Some accounts trade a contract on an order book of their own. The gateway serves that book, labelled as the listed contract, only when the market-data request carries the account's identity. The Python SDK sent public market data without an identity the gateway accepts, so such an account read the general book while its orders rested on another one.

Change

When the client is configured with an account ID and all three HMAC credentials (API key, passphrase, secret), the identity is sent by default:

  • HTTP: only on the public V2 market-data routes the gateway reads identity on (quote/getTicker, getDepth, getKline, getMultiContractKline, getMultiDayKline, getAccurateOpenInterest, getMarketStatus, funding/getLatestFundingRate, getFundingRatePage, index/getIndexPriceConfig, getMarketTradingSchedule), GET requests get accountId in the query plus the private-request HMAC headers; the signature covers the sorted query string including accountId. Every other public route stays anonymous.
  • Public WebSocket: the /api/v1/public/ws handshake is signed like the private one (accountId and timestamp in the query, HMAC headers).
  • Without an account ID or with incomplete credentials, behaviour is unchanged (anonymous). market_data_identity=False (Client, WebSocketManager) turns it off.
  • README section "Market Data Identity" documents the routes, the default, failure behaviour (bad credentials fail instead of falling back) and the opt-out.

Default-on was chosen because a client that has an account wants that account's book; for accounts without their own book the gateway returns the same data as for an anonymous caller.

Tests

pytest tests --ignore=tests/integration: 59 passed. New tests in tests/test_market_data_identity.py pin the expected query and HMAC headers per route, check unmapped routes stay anonymous, the anonymous cases, the opt-out, and the signed public WebSocket handshake.

Testnet evidence

Read-only market data on testnet, a member account whose orders rest on its own book, contract ETHUSDC, no orders placed:

  • HTTP ticker and depth with the SDK identity on equal a hand-built request in the reference web client's credential format (member view) and differ from the anonymous response (member book: open interest 0.09 vs 1649.35, depth empty vs 15 levels).
  • With the identity off, or with no credentials, HTTP and public WebSocket ticker/depth equal the anonymous view.
  • The public WebSocket with identity pushes the member view; the contract is labelled as the listed contract in every view.
  • All checks passed (13 Go / 14 Python).

🤖 Generated with Claude Code

Some accounts trade a contract on an order book of their own, and the
gateway picks the book from the caller's identity. The SDK requested
public market data without a usable identity, so such an account read
the general book while its orders rested on another one.

With an account ID and full HMAC credentials, the public market-data
HTTP routes now carry accountId plus the private-request HMAC headers,
and the public WebSocket handshake is signed like the private one.
Without credentials nothing changes; market_data_identity=False turns
the identity off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant