Skip to content

feat: expand async client to the full resource tree (#142)#150

Merged
martinkersner merged 1 commit into
mainfrom
feat/async-client-full
Jul 3, 2026
Merged

feat: expand async client to the full resource tree (#142)#150
martinkersner merged 1 commit into
mainfrom
feat/async-client-full

Conversation

@martinkersner

Copy link
Copy Markdown
Member

Follow-up to the async pilot (#149) — mirrors the entire sync surface in async, as requested.

Restructure + coverage

datamaxi/aio is now a package:

  • _core.pyAsyncAPI, AsyncResource
  • cex.py — candle, ticker, fee, wallet_status, announcement, token, symbol
  • funding_rate.py, forex.py, premium.py, liquidation.py, open_interest.py, margin_borrow.py, index_price.py
  • telegram.py (AsyncTelegram), naver.py (AsyncNaver) — standalone top-level clients
  • __init__.pyAsyncDatamaxi full 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

  • Each method is async def + await self.request_endpoint(...) with the same op_ids, params (incl. **{"from":...,"to":...}), validation, and return shaping as sync.
  • Pagination next_request closures are async (async def ... return await self.<method>(...)).
  • pandas / convert_data_to_data_frame imports stay lazy; typed response models reused for return hints.
  • The whole tree shares one AsyncAPI/httpx client (verified). AsyncTelegram/AsyncNaver build their own, matching sync.
  • No sync code changed. httpx is still the optional [async] extra; import datamaxi doesn't load it.

Judgment calls (from the port)

  • AsyncTelegram/AsyncNaver subclass AsyncResource but override __init__ to build their own transport + add context-manager/__repr__ — cleanest way to be standalone yet reuse request_endpoint/last_response.
  • Sync's cosmetic __module__/__qualname__ reassignments (a few resources set them in __init__) weren't replicated — the async resources have no __init__; behavior is unaffected.

Tests

  • New tests/test_async_resources.py (10) via one path-routing httpx.MockTransport: a representative method per resource (raw / pandas=False returns) + the async pagination closures (announcement, telegram, funding history) are awaitable.
  • Combined with the pilot's test_async.py, every async resource is exercised.
  • pytest -m "not integration": 172 passed, 11 skipped.
  • black + flake8 clean; sync import datamaxi still doesn't load httpx.

Known failures

None.

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.
@martinkersner martinkersner merged commit e3b011a into main Jul 3, 2026
5 checks passed
@martinkersner martinkersner deleted the feat/async-client-full branch July 3, 2026 08:40
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