Skip to content

Commit 353877c

Browse files
committed
feat: extend typed response models to all documented data endpoints (#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.
1 parent 615ecb6 commit 353877c

11 files changed

Lines changed: 412 additions & 33 deletions

File tree

datamaxi/__init__.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@
2525
CandleResponse,
2626
TickerData,
2727
TickerResponse,
28+
AnnouncementRow,
29+
AnnouncementResponse,
30+
TokenUpdateRow,
31+
TokenUpdateResponse,
32+
WalletStatusRow,
33+
ForexRow,
34+
FundingRateRow,
35+
FundingHistoryResponse,
36+
LatestFundingRate,
37+
PremiumDetail,
38+
PremiumRow,
39+
PremiumResponse,
40+
TelegramChannel,
41+
TelegramChannelsResponse,
42+
TelegramMessage,
43+
TelegramMessagesResponse,
44+
NaverTrendRow,
2845
)
2946

3047
__all__ = [
@@ -52,4 +69,21 @@
5269
"CandleResponse",
5370
"TickerData",
5471
"TickerResponse",
72+
"AnnouncementRow",
73+
"AnnouncementResponse",
74+
"TokenUpdateRow",
75+
"TokenUpdateResponse",
76+
"WalletStatusRow",
77+
"ForexRow",
78+
"FundingRateRow",
79+
"FundingHistoryResponse",
80+
"LatestFundingRate",
81+
"PremiumDetail",
82+
"PremiumRow",
83+
"PremiumResponse",
84+
"TelegramChannel",
85+
"TelegramChannelsResponse",
86+
"TelegramMessage",
87+
"TelegramMessagesResponse",
88+
"NaverTrendRow",
5589
]

datamaxi/naver/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Any, List, Union
22
import pandas as pd
33
from datamaxi.api import Resource
4+
from datamaxi.resources.responses import NaverTrendRow
45
from datamaxi.lib.utils import check_required_parameter
56
from datamaxi.lib.constants import BASE_URL
67

@@ -31,7 +32,9 @@ def symbols(self) -> List[str]:
3132
"""
3233
return self.request_endpoint("naver_trend_symbols")
3334

34-
def trend(self, symbol: str, pandas: bool = True) -> Union[List, pd.DataFrame]:
35+
def trend(
36+
self, symbol: str, pandas: bool = True
37+
) -> Union[pd.DataFrame, List[NaverTrendRow]]:
3538
"""Get Naver trend for given token symbol
3639
3740
`GET /api/v1/naver-trend`

datamaxi/resources/cex_announcement.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from typing import Any, Dict, Optional, Tuple, Callable
1+
from typing import Any, Optional, Tuple, Callable
22
from datamaxi.api import Resource
3+
from datamaxi.resources.responses import AnnouncementResponse
34
from datamaxi.lib.constants import ASC, DESC, SortOrder
45

56

@@ -23,7 +24,7 @@ def __call__(
2324
key: Optional[str] = None,
2425
exchange: Optional[str] = None,
2526
category: Optional[str] = None,
26-
) -> Tuple[Dict[str, Any], Callable]:
27+
) -> Tuple[AnnouncementResponse, Callable]:
2728
"""Get exchange announcements
2829
2930
`GET /api/v1/cex/announcements`

datamaxi/resources/cex_token.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from typing import Any, Dict, Optional, Tuple, Callable
1+
from typing import Any, Optional, Tuple, Callable
22
from datamaxi.api import Resource
3+
from datamaxi.resources.responses import TokenUpdateResponse
34

45

56
class CexToken(Resource):
@@ -19,7 +20,7 @@ def updates(
1920
page: int = 1,
2021
limit: int = 1000,
2122
type: Optional[str] = None,
22-
) -> Tuple[Dict[str, Any], Callable]:
23+
) -> Tuple[TokenUpdateResponse, Callable]:
2324
"""Get token update data
2425
2526
`GET /api/v1/cex/token/updates`

datamaxi/resources/cex_wallet_status.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from typing import Any, List, Dict, Union
1+
from typing import Any, List, Union
22
import pandas as pd
33
from datamaxi.api import Resource
4+
from datamaxi.resources.responses import WalletStatusRow
45
from datamaxi.lib.utils import check_required_parameters
56
from datamaxi.lib.utils import check_required_parameter
67

@@ -22,7 +23,7 @@ def __call__(
2223
exchange: str,
2324
asset: str,
2425
pandas: bool = True,
25-
) -> Union[Dict, pd.DataFrame]:
26+
) -> Union[pd.DataFrame, List[WalletStatusRow]]:
2627
"""Fetch transfer status data
2728
2829
`GET /api/v1/wallet-status`

datamaxi/resources/forex.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from typing import Any, List, Dict, Union
1+
from typing import Any, List, Union
22
import pandas as pd
33
from datamaxi.api import Resource
4+
from datamaxi.resources.responses import ForexRow
45
from datamaxi.lib.utils import check_required_parameter
56

67

@@ -23,7 +24,7 @@ def __call__(
2324
self,
2425
symbol: str,
2526
pandas: bool = True,
26-
) -> Union[Dict, pd.DataFrame]:
27+
) -> Union[pd.DataFrame, ForexRow]:
2728
"""Fetch forex data
2829
2930
`GET /api/v1/forex`

datamaxi/resources/funding_rate.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
from typing import Any, Callable, Tuple, List, Dict, Union
1+
from typing import Any, Callable, Tuple, List, Union
22
import pandas as pd
33
from datamaxi.api import Resource
44
from datamaxi.lib.utils import check_required_parameter
55
from datamaxi.lib.utils import check_required_parameters
66
from datamaxi.resources.utils import convert_data_to_data_frame
7+
from datamaxi.resources.responses import FundingHistoryResponse, LatestFundingRate
78
from datamaxi.lib.constants import ASC, DESC, SortOrder
89

910

@@ -29,7 +30,7 @@ def history(
2930
toDateTime: str = None,
3031
sort: SortOrder = DESC,
3132
pandas: bool = True,
32-
) -> Union[Tuple[Dict, Callable], Tuple[pd.DataFrame, Callable]]:
33+
) -> Union[Tuple[pd.DataFrame, Callable], Tuple[FundingHistoryResponse, Callable]]:
3334
"""Fetch historical funding rate data
3435
3536
`GET /api/v1/funding-rate/history`
@@ -105,7 +106,7 @@ def latest(
105106
exchange: str = None,
106107
symbol: str = None,
107108
pandas: bool = True,
108-
) -> Union[Dict, pd.DataFrame]:
109+
) -> Union[pd.DataFrame, LatestFundingRate]:
109110
"""Fetch latest funding rate data
110111
111112
`GET /api/v1/funding-rate/latest`

datamaxi/resources/premium.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Any, List, Union, Optional
22
import pandas as pd
33
from datamaxi.api import Resource
4+
from datamaxi.resources.responses import PremiumResponse
45
from datamaxi.lib.constants import Market, SortOrder
56

67

@@ -43,7 +44,7 @@ def __call__( # noqa: C901
4344
token_exclude: str = None,
4445
query: str = None,
4546
pandas: bool = True,
46-
) -> Union[List, pd.DataFrame]:
47+
) -> Union[pd.DataFrame, PremiumResponse]:
4748
"""Fetch premium data
4849
4950
`GET /api/v1/premium`

0 commit comments

Comments
 (0)