/algo-trading-skills:multi-broker-rate-limit-handlingfrom algo-trading-skills
Implements multi-window token bucket rate limiting with strict tier priorities and structural 429 handling for algorithmic trading API integrations. Useful when multiple strategies multiply call volume against broker accounts.
Ships in algo-trading-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Use this when integrating any broker's REST API for anything beyond a handful of manual calls, or when several strategies/instruments multiply call volume against one broker account. Brokers meter requests differently — some per endpoint class, some against a single account-wide counter, most across several stacked time windows at once — and a single global rate limiter is wrong in both directions: it throttles risk-critical calls that had headroom, and it fails to protect the endpoint whose limit is actually binding.
The skill covers four mechanisms: multi-window token buckets so a per-minute or per-day counter is respected as well as the per-second one, strict tier priority so a kill-switch cancel is never queued behind a quote burst, structural 429 classification so a retry never duplicates a live order, and Retry-After-aware full-jitter backoff so a 429 does not escalate into a ban.
historical-data-backfill-rate-limit-management.sec-rule-15c3-5-risk-controls-us.order-placement-idempotency.references/standards.md has verified figures and sources for the six brokers above.status_code, or a response object carrying one. If the SDK only raises opaque strings, wrap it before it reaches the limiter.Register each budget with all of its windows.
register_endpoint_windows(broker, category, [(10, 1.0), (200, 60.0), (100_000, 86_400.0)]) for a Fyers-shaped limit.Declare account-wide caps separately from endpoint caps.
register_account_bucket(); it is consumed in addition to the endpoint budget.Classify every outbound call by criticality tier before it enters admission control.
Do not assume the order endpoint has spare headroom for Tier 0 — verify it.
Give Tiers 1–3 strict-priority admission, not a sorted queue.
max_wait_sec and raises RateLimitWaitTimeout rather than spinning. A status poll that can no longer be answered in time should surface as an error to reconciliation, not block forever.Classify a throttle structurally, then back off with full jitter and honour Retry-After.
"429" in str(exc) matches order id 429123 and limit price 429.50. A false positive retries a call the broker may already have executed. Classify on status_code, and re-raise anything unclassifiable unretried.Retry-After (RFC 9110 §10.2.3 — delay-seconds or HTTP-date) always wins over the computed value.Retry-After beyond max_retry_after_sec means the broker wants minutes; escalate and let the caller decide, rather than parking a worker.Log which endpoint, tier and window each rejection hit. snapshot() reports calls and 429s per tier plus the binding window. This is what lets you lower polling frequency before production 429s rather than discovering the limit live during market hours.
Full step-by-step procedure with broker-specific detail: see
references/workflows.md. Verified per-broker limits with sources: seereferences/standards.md. Printable pre-flight checklist: seeassets/checklist.md.
min(cap, base * 2**n + jitter) returns exactly cap for every client once the exponential term passes the cap, so a throttled fleet retries in lockstep at the moment the herd is largest. Use full jitter across the whole interval.order-placement-idempotency's reconciliation needs an answer.Retry-After. A self-computed delay shorter than the broker's stated reset window is precisely what escalates a 429 into an IP or key ban."quotes" where you registered "quote" — inheriting a permissive default instead of Kite's real 1 req/sec is a ban waiting to happen. Run with strict=True in production.Exception("Order 429123 rejected: insufficient margin") must produce exactly one attempt and zero retries; an exception with status_code = 429 must be retried.full_jitter_backoff(8, base=1, cap=16) all fall in $[0, 16)$ with mean $\approx 8$ and more than 50 distinct values. (Additive jitter returns exactly 16.000 on all 400.)Retry-After: a numeric header is honoured exactly; an HTTP-date 120 s out parses to $\approx$ 120 s; a past date clamps to 0; malformed values fall back to jitter, never to an immediate retry; a value beyond max_retry_after_sec escalates without sleeping.RateLimitWaitTimeout naming the binding window, rather than blocking.python -m unittest discover -s skills/multi-broker-rate-limit-handling/scripts and confirm all tests pass.token-lifecycle-live-probingorder-placement-idempotencykill-switch-and-drawdown-circuit-breakershistorical-data-backfill-rate-limit-managementbroker-side-order-throttle-detectionorder-to-trade-ratio-fee-penalty-avoidanceWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub himanshuj16/algo-trading-skills --plugin algo-trading-broker-integration36 skills in this plugin
/alpaca-paper-live-key-separationUse when a bot connects to the Alpaca Trading API and must never cross paper keys with the live endpoint; pins the base URL per environment, checks the key prefix, probes /v2/account and requires an explicit ALLOW_LIVE_TRADING flag./api-key-least-privilege-audit-toolUse before deploying a live bot, to audit existing broker API keys for scopes they do not need. Flags withdrawal, transfer and admin rights that turn a leaked execution key into theft./broker-account-margin-call-handlingUse when a bot trades a Reg T, portfolio or futures margin account and must act before the broker liquidates: tiered maintenance-margin warnings cross-checked against broker excess liquidity, initial-margin order gating and liquidity-aware de-leveraging.Other plugins' skills for the same job