feat: read a whole market's depth in one call from Python - #133
Conversation
Time Submission Status
Submit or update total time with: Add time on top of previous submission with: See available commands to help comply with our Guidelines. |
|
Warning Review limit reached
Next review available in: 31 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
834d8b2 to
2b46c35
Compare
|
@holdex pr submit-time 3h |
2b46c35 to
4683cb2
Compare
get_full_market_depth(query_id)returns aggregated volume per price level forboth outcomes from one read, each level tagged with the outcome it rests on.
Related, no closing keyword:
#4445 is the Problem this action was written for and is already closed, by the
sdk-go and sdk-js PRs that consumed it. Python's consolidated book was reading
through it from the moment the preceding PR landed the sdk-go pin, so the job
story is satisfied without this. What is left is the direct accessor, which is
API parity rather than the problem.
Why
get_market_depthanswers for one outcome, so comparing the two sides of amarket takes two calls at two independent points in time. An order landing
between them appears on one side and not the other, and the pair then describes
a market state that never existed. One statement is one snapshot, and that whole
class of artifact goes away.
The node has carried
get_full_market_depthsince trufnetwork/node#1413 and itis live on mainnet. sdk-js and sdk-go both expose it. Python was the last SDK
reading a market two calls at a time.
What is in it
get_full_market_depth(query_id)onTNClient, returningFullDepthLevelrows —
outcome,price,buy_volume,sell_volume. Same aggregation asget_market_depth, for the whole market instead of one outcome. Rows arriveYES first then NO, price ascending within each.
GetFullMarketDepthinbindings/bindings.go, delegating to sdk-go.survives. The tag is the only thing separating a YES level from the NO level at
the same price, so the fixture puts a sell at 60 on each side — lose the tag
and the two rows are indistinguishable.
same book, plus the live discovery scan switched over to it: "is this market
two-sided?" is exactly the question this action exists to answer, so it now
costs one read per market rather than two.
Testing
go build ./...andgo vet ./bindings/clean, bindings rebuilt withmake gopy_build.tests/test_order_book.pypasses against a local node (44 tests).TN_LIVE_NODE_URL=https://gateway.mainnet.truf.network pytest tests/test_order_book_live.py— 5 passed against mainnet, including the new equivalence check.
The equivalence check is the one that matters. If the two reads ever disagreed on
anything but timing, every consolidated ladder built on the new one would be
wrong while the per-outcome reads stayed right, and nothing offline would notice.
It re-reads to confirm the market held still before asserting, so a moving book
skips rather than fails.
What is not in it
get_market_depthis untouched and stays the right call when you want oneoutcome — a depth chart, or a bot quoting a single side.
get_consolidated_order_bookneeds no change: it already reads through thisaction inside sdk-go, from the pin #132 brought in. This adds the direct
accessor for callers who want the raw both-outcome depth, which is what sdk-js
and sdk-go each expose alongside their consolidated method.
Note on the base branch
Was stacked on #132 while that was open. #132 has since merged, so this now
targets
mainand carries a single commit.