Rate limits
Limits protect the desk and keep every key within the exchange's order-rate rules. Read your current limits from GET /api/v1/me, watch the headers on every response, and back off when told to.
Limits#
A request must pass every limit it touches. These are the defaults; the desk can change your key's limits within fixed bounds, and limits in GET /api/v1/me always shows the values in force.
| Limit | Per second | Per minute | Per day | Applies to |
|---|---|---|---|---|
| Key, writes | 10 | 400 | 5,000 | POST /signals, /signals/batch, /signals/{id}/cancel |
| Key, reads | 10 | 300 | None | Every signed GET, and POST /signals/test |
| Trader, writes, all keys together | 10 | 1,000 | 20,000 | Writes from all of one trader's keys |
| Desk-wide, writes | 50 | 3,000 | None | Writes from all traders together |
| Client IP, before authentication | 30 | 900 | None | Every request to /api/v1, including /time and failed ones |
SEBI's framework for algorithmic trading by retail investors treats order flow above 10 orders per second as requiring a registered algorithm. MQuant enforces 10 signals per second as a hard ceiling on every key and every trader; no key can be set above it.
- Per-second limits use a sliding one-second window. Per-minute limits reset at the start of each clock minute. Per-day limits reset at midnight IST.
- A batch costs one write per item. An invalid request still costs one unit, because limits are checked before the body is validated.
GET /api/v1/timecounts only against the per-IP limit. IPv6 clients are limited per/64.
What the desk can change#
| Key limit | Default | Highest the desk can set |
|---|---|---|
signals_per_second | 10 | 10 |
signals_per_minute | 400 | 1,000 |
signals_per_day | 5,000 | 20,000 |
reads_per_second | 10 | 20 |
reads_per_minute | 300 | 1,200 |
Rate limit headers#
Responses to requests that pass authentication carry these headers, including validation errors. Responses rejected before that point, such as 401 and 403, do not.
| Header | Meaning |
|---|---|
X-RateLimit-Limit | Your key's per-minute limit for this class: reads_per_minute on reads, signals_per_minute on writes. |
X-RateLimit-Remaining | Requests left in the current minute for this class. |
X-RateLimit-Reset | Unix epoch seconds when the current minute window ends. |
X-RateLimit-Day-Remaining | Write responses only: signals left today on this key. |
Retry-After | On every 429: whole seconds to wait before trying again. |
HTTP/1.1 202 Accepted
X-Request-Id: req_6b1f0c9a2e7d4b3a8c5f1e0d
X-MQ-API-Version: 1
X-RateLimit-Limit: 400
X-RateLimit-Remaining: 361
X-RateLimit-Reset: 1796184060
X-RateLimit-Day-Remaining: 4962When you are limited#
Four codes come with 429 Too Many Requests. All of them carry Retry-After.
| Code | Cause | Retry-After is |
|---|---|---|
rate_limited | A per-second, per-minute or per-day limit on your key, your trader, the desk or your address. | Time until the limit frees up |
key_temporarily_blocked | Your key was rate limited repeatedly. | Time left on the block |
ip_temporarily_blocked | Your address was rate limited repeatedly. | Time left on the block |
auth_locked | Too many failed signatures from your address. | Time left on the lock |
Temporary blocks#
Hammering a limit makes things worse. If one key collects 20 rate_limited responses within 60 seconds, it earns a strike and is blocked (429 key_temporarily_blocked). Each further strike on the same IST day blocks for longer:
| Strike in the same IST day | Block |
|---|---|
| 1st | 2 minutes |
| 2nd | 10 minutes |
| 3rd | 1 hour |
| 4th and later | 24 hours |
- A client address that collects 60
rate_limitedresponses within 60 seconds is blocked the same way (429 ip_temporarily_blocked). - Failed authentication: 20
auth_failedresponses from one address within 15 minutes lock that address for 15 minutes (429 auth_locked). Your key is never locked by failures, so nobody can lock you out by guessing. - Blocks expire on their own. Only the desk can lift one early.
Retries and backoff#
- On
429, wait the number of seconds inRetry-After. Never retry sooner, and never retry in a tight loop: that is how a key gets blocked. - On a timeout, a dropped connection, a
500or a503, retry with exponential backoff and jitter: about 0.5 s, 1 s, 2 s, 4 s, capped at 30 s. - Every retry of a send uses the same body and
client_signal_id, with a fresh timestamp, nonce and signature. If the first attempt was stored, you get it back withreplayed: trueinstead of a duplicate. See Idempotency. - Do not retry other
4xxresponses without changing the request. - Give up after a few attempts and alert a person. Do not retry a
key_temporarily_blockedthat asks you to wait hours. - Pace yourself before the limit: if
X-RateLimit-Remainingis low, slow down, and spread a burst of signals over a few seconds rather than firing them in one.
BODY='{"client_signal_id":"reliance-0001","exchange":"NSE","symbol":"RELIANCE","instrument_type":"EQ","side":"BUY","quantity":10,"order_type":"LIMIT","price":"1250.50","product":"CNC"}'
for attempt in 1 2 3 4; do
REPLY=$(./mq.sh POST /api/v1/signals "$BODY") || REPLY="HTTP 000"
STATUS=$(printf '%s' "$REPLY" | tail -n 1 | awk '{print $2}')
case "$STATUS" in
200|202) printf '%s\n' "$REPLY"; break ;;
429|5*|000) sleep $(( attempt * 2 )) ;;
*) printf '%s\n' "$REPLY" >&2; exit 1 ;;
esac
doneimport random
import time
import requests
from mquant_signals import MQuantError
def backoff(attempt):
return min(30.0, 0.5 * 2 ** (attempt - 1)) * random.uniform(0.5, 1.0)
def send_signal(mq, signal, attempts=4):
for attempt in range(1, attempts + 1):
try:
return mq.post("/api/v1/signals", signal)
except MQuantError as error:
retryable = error.status >= 500 or (error.status == 429 and error.retry_after <= 60)
if attempt == attempts or not retryable:
raise
wait = error.retry_after if error.status == 429 else backoff(attempt)
except requests.RequestException:
if attempt == attempts:
raise
wait = backoff(attempt)
time.sleep(wait)import { MQuantError } from './mquant-signals.mjs'
const backoffMs = (attempt) => Math.min(30000, 500 * 2 ** (attempt - 1)) * (0.5 + Math.random() / 2)
export async function sendSignal(mq, signal, attempts = 4) {
for (let attempt = 1; ; attempt++) {
let wait
try {
return await mq.post('/api/v1/signals', signal)
} catch (error) {
const status = error instanceof MQuantError ? error.status : 0
const retryable = status === 0 || status >= 500 || (status === 429 && error.retryAfter <= 60)
if (attempt >= attempts || !retryable) throw error
wait = status === 429 ? error.retryAfter * 1000 : backoffMs(attempt)
}
await new Promise((resolve) => setTimeout(resolve, wait))
}
}The Python and Node clients on Code examples already include this logic as send_signal() and sendSignal().