improve signed reads, crypto hardening, and scraper transport

This commit is contained in:
k
2026-06-14 21:43:43 +08:00
parent 54884f3e24
commit 78fb63be8e
27 changed files with 1326 additions and 202 deletions
+13 -14
View File
@@ -4,7 +4,6 @@ import logging
from datetime import datetime, timezone
from typing import Optional
import httpx
import websockets
from app.config import settings
@@ -127,19 +126,19 @@ async def fetch_historical(asset: str, symbol: str, interval: str = "1m", limit:
"""Fetch historical klines from Binance REST API to pre-fill price_store."""
url = f"{settings.binance_rest_url}/api/v3/klines?symbol={symbol.upper()}&interval={interval}&limit={limit}"
try:
async with httpx.AsyncClient(timeout=15) as client:
resp = await client.get(url)
resp.raise_for_status()
for row in resp.json():
candle = {
"time": row[0], # open time ms
"open": float(row[1]),
"high": float(row[2]),
"low": float(row[3]),
"close": float(row[4]),
"volume": float(row[5]),
}
price_store.update(asset, candle)
from app.services.http_client import get_client
resp = await get_client().get(url, timeout=15)
resp.raise_for_status()
for row in resp.json():
candle = {
"time": row[0], # open time ms
"open": float(row[1]),
"high": float(row[2]),
"low": float(row[3]),
"close": float(row[4]),
"volume": float(row[5]),
}
price_store.update(asset, candle)
logger.info("Loaded %d historical %s candles for %s", limit, interval, asset)
except Exception as exc:
logger.error("Failed to fetch historical data for %s: %s", asset, exc)