From 6659c4524c7b014ada6ac2a6a714f7a751859262 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 28 Feb 2026 15:34:24 +0000 Subject: [PATCH] feat: market_data_collector add funding_rate collection for all 4 symbols --- backend/market_data_collector.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/backend/market_data_collector.py b/backend/market_data_collector.py index 0c6af9c..d808cd7 100644 --- a/backend/market_data_collector.py +++ b/backend/market_data_collector.py @@ -135,12 +135,22 @@ class MarketDataCollector: } 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: tasks = [ ("long_short_ratio", self.collect_long_short_ratio(session, symbol)), ("top_trader_position", self.collect_top_trader_position(session, symbol)), ("open_interest_hist", self.collect_open_interest_hist(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)