Skip to main content

Module rate_limiter

Module rate_limiter 

Source
Expand description

Rate limiter module for API request throttling Rate limiter module for controlling API request rates

This module provides rate limiting functionality using the governor crate to ensure compliance with IG Markets API rate limits.

§Enforced budget

RateLimiter holds one governor token bucket per RateLimitClass, all derived from the single RateLimiterConfig passed to RateLimiter::new:

  • NonTrading honors the configured budget exactly: max_requests requests per period_seconds, with burst_size burst capacity. The per-cell replenishment interval is period_seconds / max_requests.
  • Trading uses a stricter, fixed budget derived from IG’s published per-app trading limit (~1 request/second), independent of the configured budget so a permissive config cannot loosen it.
  • Historical uses its own conservative bucket because historical price fetches also draw down a weekly data-point allowance.

The buckets are independent, so bulk non-trading traffic can never queue order placement behind it.

Structs§

RateLimiter
Rate limiter for controlling API request rates

Enums§

RateLimitClass
Rate-limit class for an IG endpoint.