feat: expand async client to the full resource tree (#142)#150
Merged
Conversation
Follow-up to the candle+ticker pilot. Restructure datamaxi/aio into a package and mirror the entire sync surface in async: - _core.py: AsyncAPI, AsyncResource (moved from __init__) - cex.py: candle, ticker, fee, wallet_status, announcement, token, symbol - funding_rate, forex, premium, liquidation, open_interest, margin_borrow, index_price; AsyncTelegram + AsyncNaver as standalone top-level clients - AsyncDatamaxi exposes the full tree over one shared AsyncAPI/httpx client Every method is async def + await request_endpoint, preserving sync op_ids, params, validation, and return shaping; pagination next_request closures are async; pandas/convert imports stay lazy. No sync code changed. httpx remains the optional [async] extra. Tests (test_async_resources.py, httpx.MockTransport): one method per resource + async pagination closures. Suite: 172 passed.
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 async pilot (#149) — mirrors the entire sync surface in async, as requested.
Restructure + coverage
datamaxi/aiois now a package:_core.py—AsyncAPI,AsyncResourcecex.py— candle, ticker, fee, wallet_status, announcement, token, symbolfunding_rate.py,forex.py,premium.py,liquidation.py,open_interest.py,margin_borrow.py,index_price.pytelegram.py(AsyncTelegram),naver.py(AsyncNaver) — standalone top-level clients__init__.py—AsyncDatamaxifull tree + re-exports +__all__Every sync public method is mirrored (~50 methods):
cex.{candle,ticker,fee,wallet_status,announcement,token,symbol}.*,funding_rate.{history,latest,exchanges,symbols},forex,premium,liquidation.{__call__,feed,heatmap,map,stats,symbol_history},open_interest.{__call__,list,overview,summary,history_aggregated},margin_borrow,index_price,AsyncTelegram.{channels,messages},AsyncNaver.{symbols,trend}.How it stays faithful
async def+await self.request_endpoint(...)with the same op_ids, params (incl.**{"from":...,"to":...}), validation, and return shaping as sync.next_requestclosures are async (async def ... return await self.<method>(...)).convert_data_to_data_frameimports stay lazy; typed response models reused for return hints.AsyncAPI/httpx client (verified).AsyncTelegram/AsyncNaverbuild their own, matching sync.[async]extra;import datamaxidoesn't load it.Judgment calls (from the port)
AsyncTelegram/AsyncNaversubclassAsyncResourcebut override__init__to build their own transport + add context-manager/__repr__— cleanest way to be standalone yet reuserequest_endpoint/last_response.__module__/__qualname__reassignments (a few resources set them in__init__) weren't replicated — the async resources have no__init__; behavior is unaffected.Tests
tests/test_async_resources.py(10) via one path-routinghttpx.MockTransport: a representative method per resource (raw /pandas=Falsereturns) + the async pagination closures (announcement, telegram, funding history) are awaitable.test_async.py, every async resource is exercised.pytest -m "not integration": 172 passed, 11 skipped.import datamaxistill doesn't load httpx.Known failures
None.