feat: extend typed response models to all documented data endpoints (#141)#147
Merged
Merged
Conversation
…141) Follow-up to the candle/ticker pilot: add TypedDicts for announcement, token updates, wallet status, forex, funding rate (history + latest), premium (incl. ~75-field detail, total=False), telegram channels/messages, and naver trend; annotate each method's pandas=False return with the matching model (envelope / bare list / single object per the actual return shape). Fields sourced from the live API docs. Typed str to match the API's string-on-the-wire serialization, with two verified native exceptions: premium booleans (t/sms/tms) and naver trend v (int). Hint-only; no runtime cost or behavior change. All models exported from the top level. Endpoints returning raw request_endpoint() dicts without published field schemas (liquidation, open_interest, margin_borrow, index_price, cex.symbol) are intentionally left untyped rather than guessed.
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.
Follow-up to the candle/ticker pilot (#146) — types the rest of the data endpoints, per your ask to "do it for all."
Added models (
datamaxi/resources/responses.py)AnnouncementRow/Response,TokenUpdateRow/Response,WalletStatusRow,ForexRow,FundingRateRow+FundingHistoryResponse,LatestFundingRate,PremiumDetail(~75 fields,total=False) +PremiumRow+PremiumResponse,TelegramChannel(s)Response,TelegramMessage(s)Response,NaverTrendRow. All exported from the top level.Each method's return annotation matches its actual
pandas=Falseshape:{"data":[...]}→*Response(premium; announcement/token/telegram as the first tuple element; funding history)List[Row](wallet status, naver)Row(forex, funding latest)Type conventions (documented in the module)
strto match this API's string-on-the-wire serialization (verified on candle/ticker/funding), with two verified native exceptions: premium booleanst/sms/tms→bool, and naver-trendv→int(its payload shows a native10).PremiumDetailistotal=False— AMM-only fields (chain, pool address) are absent for most pairs.Deliberately NOT typed
liquidation,open_interest,margin_borrow,index_price, andcex.symbol.*return rawrequest_endpoint()dicts and have no published field schema (no docs URL, placeholder-only test mocks). I left them untyped rather than invent field shapes. These are the natural candidates for a future codegen-based pass.Tests
tests/test_response_models.py: field-set assertions for every new model (guards transcription drift) + the native-type exceptions (v:int, premiumbools,PremiumDetail.__total__ is False).pytest -m "not integration": 151 passed, 11 skipped.Caveat (restating)
Hand-authored models can drift if the backend changes; the drift-proof endgame remains emitting them from the upstream OpenAPI codegen. Field names/types reflect the docs as of today — flag any the backend actually returns differently (e.g. if telegram counts are native ints, I'll switch those).
Known failures
None.