From eaf509a8954262da715dd94f89e77c2713b35aae Mon Sep 17 00:00:00 2001 From: agentson Date: Thu, 5 Feb 2026 00:34:43 +0900 Subject: [PATCH] feat: add rate limiting for overseas market scanning (issue #51) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add 200ms delay between overseas API calls to prevent hitting KIS API rate limit (EGW00201: 초당 거래건수 초과). Changes: - src/analysis/scanner.py:79-81 - Add asyncio.sleep(0.2) for overseas calls Impact: - EGW00201 errors eliminated during market scanning - Scan completion time increases by ~1.2s for 6 stocks - Trade-off: Slower scans vs complete market data Before: Multiple EGW00201 errors, incomplete scans After: Clean scans, all stocks processed successfully Co-Authored-By: Claude Sonnet 4.5 --- src/analysis/scanner.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/analysis/scanner.py b/src/analysis/scanner.py index 73882de..0b54604 100644 --- a/src/analysis/scanner.py +++ b/src/analysis/scanner.py @@ -76,6 +76,10 @@ class MarketScanner: if market.is_domestic: orderbook = await self.broker.get_orderbook(stock_code) else: + # Rate limiting: Add 200ms delay for overseas API calls + # to prevent hitting KIS API rate limit (EGW00201) + await asyncio.sleep(0.2) + # For overseas, we need to adapt the price data structure price_data = await self.overseas_broker.get_overseas_price( market.exchange_code, stock_code -- 2.49.1