feat: market_data_collector add funding_rate collection for all 4 symbols

This commit is contained in:
root 2026-02-28 15:34:24 +00:00
parent 83dc456119
commit 6659c4524c

View File

@ -135,12 +135,22 @@ class MarketDataCollector:
} }
self.save_indicator(symbol, "coinbase_premium", ts, payload) self.save_indicator(symbol, "coinbase_premium", ts, payload)
async def collect_funding_rate(self, session: aiohttp.ClientSession, symbol: str) -> None:
endpoint = "https://fapi.binance.com/fapi/v1/fundingRate"
data = await self.fetch_json(session, endpoint, {"symbol": symbol, "limit": 1})
if not data:
raise RuntimeError("empty response")
item = data[0]
ts = int(item.get("fundingTime") or int(time.time() * 1000))
self.save_indicator(symbol, "funding_rate", ts, item)
async def collect_symbol(self, session: aiohttp.ClientSession, symbol: str) -> None: async def collect_symbol(self, session: aiohttp.ClientSession, symbol: str) -> None:
tasks = [ tasks = [
("long_short_ratio", self.collect_long_short_ratio(session, symbol)), ("long_short_ratio", self.collect_long_short_ratio(session, symbol)),
("top_trader_position", self.collect_top_trader_position(session, symbol)), ("top_trader_position", self.collect_top_trader_position(session, symbol)),
("open_interest_hist", self.collect_open_interest_hist(session, symbol)), ("open_interest_hist", self.collect_open_interest_hist(session, symbol)),
("coinbase_premium", self.collect_coinbase_premium(session, symbol)), ("coinbase_premium", self.collect_coinbase_premium(session, symbol)),
("funding_rate", self.collect_funding_rate(session, symbol)),
] ]
results = await asyncio.gather(*(t[1] for t in tasks), return_exceptions=True) results = await asyncio.gather(*(t[1] for t in tasks), return_exceptions=True)