Repository navigation
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
quote/getTicker,getDepth,getKline,getMultiContractKline,getMultiDayKline,getAccurateOpenInterest,getMarketStatus,funding/getLatestFundingRate,getFundingRatePage,index/getIndexPriceConfig,getMarketTradingSchedule), GET requests getaccountIdin the query plus the private-request HMAC headers; the signature covers the sorted query string includingaccountId. Every other public route stays anonymous./api/v1/public/wshandshake is signed like the private one (accountIdandtimestampin the query, HMAC headers).market_data_identity=False(Client,WebSocketManager) turns it off.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 intests/test_market_data_identity.pypin 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:
🤖 Generated with Claude Code