增加资金费率

This commit is contained in:
dekun
2026-05-22 14:00:19 +08:00
parent d7f7259ee0
commit 71ed38b32d
13 changed files with 603 additions and 14 deletions
+24
View File
@@ -212,6 +212,30 @@ 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_premium_index_all(self) -> dict[str, dict]:
data = await self._get("/fapi/v1/premiumIndex")
if isinstance(data, dict):
items = [data]
else:
items = data or []
return {str(x["symbol"]).upper(): x for x in items if x.get("symbol")}
async def get_funding_rate_history(self, symbol: str, limit: int = 90) -> list[dict]:
raw = await self._get(
"/fapi/v1/fundingRate",
{"symbol": symbol.upper(), "limit": min(limit, 1000)},
)
rows = []
for r in raw or []:
rows.append(
{
"time": int(r["fundingTime"]),
"rate": float(r["fundingRate"]),
"mark_price": float(r.get("markPrice", 0) or 0),
}
)
return rows
async def get_daily_klines(self, symbol: str, limit: int = 300) -> list[dict]:
raw = await self._get(
"/fapi/v1/klines",