fix: FR collector use premiumIndex API for real-time 5min data
- Changed from /fapi/v1/fundingRate (8h settlement only) to /fapi/v1/premiumIndex (real-time) - Each 5-min poll now stores a new row with current timestamp - Payload includes both fundingRate and lastFundingRate for compat - Fixes: FR data was only 6 rows per 4 days, now ~288/day per coin
This commit is contained in:
parent
526b6359ca
commit
02a769f513
@ -136,13 +136,25 @@ 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:
|
async def collect_funding_rate(self, session: aiohttp.ClientSession, symbol: str) -> None:
|
||||||
endpoint = "https://fapi.binance.com/fapi/v1/fundingRate"
|
endpoint = "https://fapi.binance.com/fapi/v1/premiumIndex"
|
||||||
data = await self.fetch_json(session, endpoint, {"symbol": symbol, "limit": 1})
|
data = await self.fetch_json(session, endpoint, {"symbol": symbol})
|
||||||
if not data:
|
if not data:
|
||||||
raise RuntimeError("empty response")
|
raise RuntimeError("empty response")
|
||||||
item = data[0]
|
# premiumIndex returns a single object (not array)
|
||||||
ts = int(item.get("fundingTime") or int(time.time() * 1000))
|
item = data if isinstance(data, dict) else data[0]
|
||||||
self.save_indicator(symbol, "funding_rate", ts, item)
|
# Use current time as timestamp so every 5-min poll stores a new row
|
||||||
|
ts = int(time.time() * 1000)
|
||||||
|
payload = {
|
||||||
|
"symbol": item.get("symbol"),
|
||||||
|
"markPrice": item.get("markPrice"),
|
||||||
|
"indexPrice": item.get("indexPrice"),
|
||||||
|
"lastFundingRate": item.get("lastFundingRate"),
|
||||||
|
"nextFundingTime": item.get("nextFundingTime"),
|
||||||
|
"interestRate": item.get("interestRate"),
|
||||||
|
"fundingRate": item.get("lastFundingRate"), # compat: signal_engine reads 'fundingRate'
|
||||||
|
"time": ts,
|
||||||
|
}
|
||||||
|
self.save_indicator(symbol, "funding_rate", ts, payload)
|
||||||
|
|
||||||
async def collect_symbol(self, session: aiohttp.ClientSession, symbol: str) -> None:
|
async def collect_symbol(self, session: aiohttp.ClientSession, symbol: str) -> None:
|
||||||
tasks = [
|
tasks = [
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user