增加k线图

This commit is contained in:
dekun
2026-05-22 13:47:27 +08:00
parent ee621976db
commit 74f98af40d
13 changed files with 543 additions and 8 deletions
+19
View File
@@ -212,5 +212,24 @@ class BinanceFuturesClient:
sym_set = set(symbols)
return {t["symbol"]: float(t["price"]) for t in tickers if t["symbol"] in sym_set}
async def get_daily_klines(self, symbol: str, limit: int = 300) -> list[dict]:
raw = await self._get(
"/fapi/v1/klines",
{"symbol": symbol.upper(), "interval": "1d", "limit": min(limit, 1500)},
)
candles = []
for k in raw or []:
candles.append(
{
"time": int(k[0]),
"open": float(k[1]),
"high": float(k[2]),
"low": float(k[3]),
"close": float(k[4]),
"volume": float(k[5]),
}
)
return candles
binance_client = BinanceFuturesClient()