Этот коммит содержится в:
Виктор
2026-05-08 03:26:19 +09:00
родитель 0e3f5d2811
Коммит 25ca75704d
+25
Просмотреть файл
@@ -0,0 +1,25 @@
from typing import Any
import httpx
class CoinExClient:
def __init__(self, api_base: str) -> None:
self.api_base = api_base.rstrip('/')
async def get_kline(self, market: str, period: str = '1min', limit: int = 100) -> dict[str, Any]:
params = {
'market': market.upper(),
'period': period,
'limit': max(1, min(limit, 1000)),
}
async with httpx.AsyncClient(timeout=10.0) as client:
response = await client.get(f'{self.api_base}/spot/kline', params=params)
response.raise_for_status()
return response.json()
async def get_ticker(self, market: str) -> dict[str, Any]:
params = {'market': market.upper()}
async with httpx.AsyncClient(timeout=10.0) as client:
response = await client.get(f'{self.api_base}/spot/ticker', params=params)
response.raise_for_status()
return response.json()