增加资金费率
This commit is contained in:
@@ -6,6 +6,7 @@ from datetime import datetime
|
||||
from .binance import binance_client
|
||||
from .config import settings
|
||||
from .exceptions import BinanceRateLimitedError
|
||||
from .funding_store import enrich_items_with_funding
|
||||
from .periods import to_ms
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -38,14 +39,15 @@ def format_volume(vol: float) -> str:
|
||||
return f"{vol:.0f}"
|
||||
|
||||
|
||||
def _finalize_top(stats: list[SymbolStats]) -> list[dict]:
|
||||
async def _finalize_top(stats: list[SymbolStats]) -> list[dict]:
|
||||
stats.sort(key=lambda x: x.quote_volume, reverse=True)
|
||||
top = stats[: settings.top_n]
|
||||
for i, s in enumerate(top, 1):
|
||||
s.rank = i
|
||||
s.is_high_volume = s.quote_volume >= settings.volume_threshold
|
||||
s.is_high_change = abs(s.price_change_pct) >= settings.change_threshold
|
||||
return [s.to_dict() for s in top]
|
||||
items = [s.to_dict() for s in top]
|
||||
return await enrich_items_with_funding(items)
|
||||
|
||||
|
||||
def _aggregate_klines(klines: list, start_ms: int, end_ms: int) -> tuple[float, float, float]:
|
||||
@@ -87,7 +89,7 @@ async def aggregate_from_ticker24hr() -> list[dict]:
|
||||
)
|
||||
)
|
||||
logger.info("ticker24h mode: %d symbols, 1 API call", len(stats))
|
||||
return _finalize_top(stats)
|
||||
return await _finalize_top(stats)
|
||||
|
||||
|
||||
async def _fetch_symbol_stats(
|
||||
@@ -177,7 +179,7 @@ async def aggregate_period_klines(
|
||||
)
|
||||
results = await asyncio.gather(*tasks)
|
||||
stats = [r for r in results if r is not None and r.quote_volume > 0]
|
||||
return _finalize_top(stats)
|
||||
return await _finalize_top(stats)
|
||||
|
||||
|
||||
async def aggregate_period(
|
||||
|
||||
Reference in New Issue
Block a user