fix: persist sell prices to DB and add WF filter bootstrap
- price_db: add sell_prices table (ensure/upsert/load/delete) - trader: restore _last_sell_prices from DB on startup so re-entry block survives restarts; persist each sell price immediately - market: retry chunk requests up to 3 times with backoff on 429 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,15 +29,27 @@ def get_top_tickers() -> list[str]:
|
||||
if not all_tickers:
|
||||
return []
|
||||
|
||||
# 100개씩 나눠서 조회 (URL 길이 제한)
|
||||
# 100개씩 나눠서 조회 (URL 길이 제한, 429 재시도 포함)
|
||||
chunk_size = 100
|
||||
ticker_data = []
|
||||
for i in range(0, len(all_tickers), chunk_size):
|
||||
chunk = all_tickers[i:i + chunk_size]
|
||||
params = {"markets": ",".join(chunk)}
|
||||
resp = requests.get(_TICKER_URL, params=params, timeout=5)
|
||||
resp.raise_for_status()
|
||||
ticker_data.extend(resp.json())
|
||||
for attempt in range(3):
|
||||
try:
|
||||
resp = requests.get(_TICKER_URL, params=params, timeout=5)
|
||||
if resp.status_code == 429:
|
||||
wait = 2 ** attempt # 1s → 2s → 4s
|
||||
logger.warning(f"429 Rate Limit, {wait}s 대기 후 재시도 ({attempt+1}/3)")
|
||||
time.sleep(wait)
|
||||
continue
|
||||
resp.raise_for_status()
|
||||
ticker_data.extend(resp.json())
|
||||
break
|
||||
except Exception as e:
|
||||
if attempt == 2:
|
||||
raise
|
||||
time.sleep(1)
|
||||
|
||||
# 스테이블코인 제외
|
||||
EXCLUDE = {"KRW-USDT", "KRW-USDC", "KRW-DAI", "KRW-BUSD"}
|
||||
|
||||
Reference in New Issue
Block a user