정신이 나가지 않게 암호화폐 거래소 API 레이트 제한 다루기

발행: (2026년 3월 17일 PM 03:25 GMT+9)
2 분 소요
원문: Dev.to

Source: Dev.to

거래소별 Rate Limit 규칙

  • Binance – IP 기반, 1200 weight/분
  • OKX – 엔드포인트당, 60 요청/2 초
  • Bybit – 티어 기반, 120 요청/분
  • Kraken – 시간이 지남에 따라 감소하는 호출 카운터

Adaptive Rate Limiter 구현

import time

class AdaptiveRateLimiter:
    def __init__(self, base_delay=0.5):
        self.delay = base_delay
        self.consecutive_429s = 0

    def wait(self):
        time.sleep(self.delay)

    def on_success(self):
        self.consecutive_429s = 0
        self.delay = max(self.delay * 0.9, 0.1)

    def on_rate_limit(self):
        self.consecutive_429s += 1
        self.delay = min(self.delay * 2, 60)

모범 사례

  • 거래소별 큐 – 거래소마다 별도의 rate limiter를 사용하고 공유하지 않음.
  • HTTP 429 응답에 대한 지수 백오프 적용, 최대 60 초로 제한.
  • 적극적인 캐싱 – 예를 들어 수수료 데이터는 매분 변하지 않음.
  • API가 지원하는 경우 배치 요청 사용 (예: Binance 배치 엔드포인트).

자세한 기술 내용은 kkinvesting.io 를 방문하세요.

0 조회
Back to Blog

관련 글

더 보기 »