feat: add rate limiting for overseas market scanning (issue #51) #53

Merged
jihoson merged 1 commits from feature/issue-51-api-rate-limiting into main 2026-02-05 00:45:39 +09:00
Collaborator

Summary

  • Eliminates EGW00201 rate limit errors when scanning overseas markets
  • Adds 200ms delay between overseas API calls
  • Simple, effective solution that prevents incomplete market data

Changes

  • src/analysis/scanner.py:79-81 - Add asyncio.sleep(0.2) for overseas API calls

Before/After

Before:

WARNING: get_overseas_price failed (500): {"rt_cd":"1","msg_cd":"EGW00201","msg1":"초당 거래건수를 초과하였습니다."}
WARNING: Failed to scan AAPL (US_NASDAQ): ...
WARNING: Failed to scan MSFT (US_NASDAQ): ...
WARNING: Failed to scan GOOGL (US_NASDAQ): ...

Result: 0/6 stocks scanned successfully

After:

INFO: Scanning NASDAQ market (6 stocks)
INFO: NASDAQ scan complete: 6 scanned

Result: 6/6 stocks scanned successfully, no EGW00201 errors

Performance Impact

  • Scan time increase: ~1.2s for 6 stocks (200ms × 6)
  • Trade-off: Slightly slower scans vs complete market data
  • Benefit: Eliminates missed trading opportunities from incomplete scans

Test Results

  • All 8 scanner tests pass
  • Manual testing confirms EGW00201 errors eliminated
  • Scans complete successfully with full market data

Implementation Notes

  • Chose Option 1 from issue #51 (simplest approach)
  • Delay only applies to overseas markets (domestic unaffected)
  • Can be tuned if KIS API limits change in future
  • Future enhancement: Semaphore-based rate limiting if needed

Closes #51

🤖 Generated with Claude Code

## Summary - Eliminates EGW00201 rate limit errors when scanning overseas markets - Adds 200ms delay between overseas API calls - Simple, effective solution that prevents incomplete market data ## Changes - **src/analysis/scanner.py:79-81** - Add `asyncio.sleep(0.2)` for overseas API calls ## Before/After **Before:** ``` WARNING: get_overseas_price failed (500): {"rt_cd":"1","msg_cd":"EGW00201","msg1":"초당 거래건수를 초과하였습니다."} WARNING: Failed to scan AAPL (US_NASDAQ): ... WARNING: Failed to scan MSFT (US_NASDAQ): ... WARNING: Failed to scan GOOGL (US_NASDAQ): ... ``` Result: 0/6 stocks scanned successfully **After:** ``` INFO: Scanning NASDAQ market (6 stocks) INFO: NASDAQ scan complete: 6 scanned ``` Result: 6/6 stocks scanned successfully, no EGW00201 errors ## Performance Impact - **Scan time increase**: ~1.2s for 6 stocks (200ms × 6) - **Trade-off**: Slightly slower scans vs complete market data - **Benefit**: Eliminates missed trading opportunities from incomplete scans ## Test Results - All 8 scanner tests pass - Manual testing confirms EGW00201 errors eliminated - Scans complete successfully with full market data ## Implementation Notes - Chose **Option 1** from issue #51 (simplest approach) - Delay only applies to overseas markets (domestic unaffected) - Can be tuned if KIS API limits change in future - Future enhancement: Semaphore-based rate limiting if needed Closes #51 🤖 Generated with [Claude Code](https://claude.com/claude-code)
agentson added 1 commit 2026-02-05 00:35:07 +09:00
feat: add rate limiting for overseas market scanning (issue #51)
Some checks failed
CI / test (pull_request) Has been cancelled
eaf509a895
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 <noreply@anthropic.com>
jihoson merged commit 58f1106dbd into main 2026-02-05 00:45:39 +09:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jihoson/The-Ouroboros#53