Skip to content

Rate limits ​

Request frequency, historical quota and subscription quota are separate limits. Passing one does not imply passing the others.

Entry and business limits ​

  • Entry limits apply per IP: quote, trading, crypto and simulated-trading APIs each allow at most 100 requests per minute from the same IP.
  • The quote gateway also applies its current business policy, which may count per user, user/endpoint, user/endpoint group, endpoint or globally. Connections and application instances may share counters.
  • Rules can apply together. Any exhausted limit can reject a request. Current policy determines thresholds and windows; the entry IP limit is not an account’s available request budget.
  • For historical K-lines, only a valid page_token exempts rules designated for first-page requests. Global, endpoint and other user rules still apply. next_time alone counts as a first-page request.

Detecting rate limits ​

Quote business rate limits generally return HTTP 200. For the legacy envelope, inspect ret_code=-11 and error.code=rate_limited. For endpoints using the new envelope, inspect code=-11 and message. Checking HTTP 429 alone is insufficient.

Retry-After gives the suggested delay in seconds. A pending reservation for the same historical target also returns -11, with error.code=history_quota_busy and a 1-second delay. -12 history_quota_exceeded means no slot is available for a new historical target; wait for release. -13 quota_unavailable means a dependency is unavailable, not that usage is zero.

json
{
  "ret_code": -11,
  "ret_msg": "rate limit exceeded",
  "error": {
    "code": "rate_limited",
    "message": "too many requests, retry after 2s"
  }
}

Query and retry guidance ​

Batch queries, cache static data and avoid concurrent duplicate requests. For safely retryable GET queries, the following example handles entry HTTP 429 and quote business rate limits. Do not apply it directly to order placement or other writes.

python
import time
import requests


def get_with_backoff(url, headers, params=None, attempts=3):
    for attempt in range(attempts):
        response = requests.get(url, headers=headers, params=params, timeout=15)
        payload = response.json() if response.status_code == 200 else {}
        retryable = response.status_code == 429 or (
            response.status_code == 200
            and payload.get("ret_code", payload.get("code")) in (-11, -13)
        )
        if not retryable or attempt == attempts - 1:
            response.raise_for_status()
            return payload
        delay = response.headers.get("Retry-After", "")
        time.sleep(max(1, int(delay)) if delay.isdigit() else 2 ** attempt)

Always inspect the returned business code.