The safeBuffer works by reserving a portion of your exchange’s allowed API quota, ensuring MagicTradeBot doesn’t accidentally exceed the limit.
⚙️ How It Works
- Define your maximum allowed requests per second:
maxRequestsPerSecond: 10
- Set a safe buffer percentage:
safeBuffer: 0.2 # reserve 20% of the quota
- Calculate effective request rate:
Effective requests per second = maxRequestsPerSecond × (1 - safeBuffer)
= 10 × (1 - 0.2)
= 8 requests/sec
- The bot will only use 8 requests per second, leaving 2 requests/sec as a buffer for traffic spikes.
⚖️ Why It Matters
- Absorbs sudden bursts of API calls
- Prevents accidental rate-limit violations
- Ensures stable trading and data fetching
- Protects your exchange account from temporary or permanent bans
🚀 Summary
safeBuffer reduces API risk by:
- Reserving a portion of your allowed quota
- Limiting effective API usage below the maximum
- Allowing safe operation during high activity periods
Example: With maxRequestsPerSecond: 10 and safeBuffer: 0.2, the bot safely uses 8 requests/sec.