Logo de Broker Side Order Throttle Detection

Broker Side Order Throttle Detection

Comunidade
HimanshuJ16
broker-side-order-throttle-detection

Use quando uma plataforma enfileira mensagens de ordem excedentes em vez de rejeitá-las, fazendo com que o congestionamento apareça apenas como latência nas confirmações. Detecta limitação de taxa não declarada com base na latência média móvel exponencialmente ponderada (EWMA) do tempo de ida e volta das confirmações (ACK) e regula o envio com recuo AIMD.

Visão geral

Publicado porHimanshuJ16
RepositórioAlgo-Trading-Skills
Nome da habilidadebroker-side-order-throttle-detection
Estrelas
50
Forks
7
Arquivos incluídos
5
LicençaApache-2.0
Links
  • Instruções em Markdown

    Um arquivo SKILL.md que o modelo carrega sob demanda, consumindo tokens apenas quando uma solicitação é realmente relevante para a habilidade.

  • Funciona com qualquer LLM

    As habilidades de IA são escritas em Markdown simples, não em código específico de um provedor. Por isso, funcionam com GPT, Claude, Gemini, Grok ou um modelo local.

  • Arquivos incluídos: 5

    Scripts, templates e referências que o modelo pode ler enquanto trabalha. Os arquivos são somente para leitura e nunca são executados.

  • Código aberto

    Publicada por HimanshuJ16 no GitHub. Leia os arquivos da habilidade antes de instalá-la.

Instalação

Instale a habilidade de IA Broker Side Order Throttle Detection no TypingMind para usá-la com qualquer LLM ou adicione-a a outro agente que leia SKILL.md.

1

Instalar no TypingMind

O TypingMind instala uma habilidade diretamente da pasta dela no GitHub — lê o arquivo SKILL.md, reúne os arquivos de recursos em um pacote e armazena o resultado localmente.

  1. Abra o app e vá para Plugins → Habilidades.
  2. Escolha "Instalar do GitHub".
  3. Cole a URL abaixo, que aponta para a pasta da habilidade, e confirme.
    https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/broker-side-order-throttle-detection
  4. Ative a habilidade em cada chat em que quiser disponibilizá-la.
Plugins → Habilidades → Adicionar habilidade → Via URL do GitHub. Depois, cole a URL da pasta e pressione Continuar.
2

Instalar em outro agente

Qualquer agente que leia o formato Agent Skills pode usar esta habilidade — copie a pasta para o diretório de habilidades desse agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/HimanshuJ16/Algo-Trading-Skills.git /tmp/Algo-Trading-Skills
mkdir -p .claude/skills
cp -r /tmp/Algo-Trading-Skills/skills/broker-side-order-throttle-detection .claude/skills/broker-side-order-throttle-detection
Reinicie Claude Code após copiar para que a nova habilidade seja reconhecida.

Use no TypingMind

Ative Broker Side Order Throttle Detection em qualquer chat do TypingMind e o modelo cuida do resto. O nome e a descrição da habilidade ficam no prompt do sistema e, assim que uma solicitação relevante aparece, o modelo carrega as instruções completas automaticamente — sem precisar de acionamento manual e sem consumir tokens até que ela seja realmente usada.

O modelo carrega Broker Side Order Throttle Detection automaticamente assim que uma solicitação é relevante para essa habilidade.

Funciona com qualquer modelo de IA

Habilidades de IA são instruções em Markdown simples, não código específico de um provedor. Por isso, Broker Side Order Throttle Detection não fica vinculada ao modelo para o qual foi criada. Instale-a uma vez no TypingMind e use-a com GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou um modelo local executado por conta própria — tudo com suas próprias chaves de API.

  • Carregada apenas quando necessário

    O prompt do sistema contém apenas o nome e a descrição. As instruções são buscadas na primeira solicitação relevante, então uma habilidade sem uso não gera custo.

  • Troque de modelo durante a conversa

    Como a habilidade é composta de instruções, não de código, trocar de modelo não afeta seu funcionamento — o próximo modelo lê o mesmo arquivo SKILL.md.

Instruções da habilidade

Este é o conteúdo de SKILL.md que o modelo carrega. Leia antes de instalar — uma habilidade é um conjunto de instruções que seu modelo seguirá.

When to Use

Invoke this skill when a bot dispatches order flow to a venue that queues or paces excess messages instead of rejecting them, so congestion never appears as an error code and shows up only as acknowledgment latency.

The Interactive Brokers TWS API is the reference case: it "is designed to accept up to fifty messages per second coming from the client side," and beyond that rate messages are queued and delayed rather than refused. The +PACEAPI connect option makes TWS pace the client at 50/s instead of disconnecting it. In neither case does the client receive a signal — the only observable is ACK RTT rising.

Use it to establish a latency baseline that a sustained throttle cannot quietly move, to detect acknowledgments that never arrive at all, and to slow dispatch until the condition clears.

When NOT to Use

  • When the venue tells you. Binance returns HTTP 429 on a rate-limit breach and HTTP 418 once an IP is auto-banned for continuing to send after 429s, both carrying a Retry-After header; the IBKR Web API returns 429 and may put the IP in a 10-minute penalty box. An explicit response is authoritative and a latency inference is not — obey Retry-After and do not let this detector shorten it. See multi-broker-rate-limit-handling.
  • As a pre-trade message limit. MiFID II RTS 6 Article 15(1)(d) requires "maximum messages limits, which prevent sending an excessive number of messages to order books pertaining to the submission, modification or cancellation of an order." That is a hard counter against a known limit, enforced before dispatch. A latency-derived backoff is not a substitute; see matching-engine-throttle-and-message-gapping-detection.
  • On order flow too sparse to build a baseline. Roughly 20+ acknowledgments are needed before the anomaly test means anything. Below that the skill reports WARMUP and only the absolute ceiling and the ACK timeout can fire.
  • To attribute the delay. Rising ACK RTT is equally consistent with a local GC pause, a saturated NIC, a congested uplink or a venue-side matching-engine slowdown. The skill establishes that dispatch should slow down, not who caused it.

Prerequisites

  • Submission and acknowledgment timestamps taken from the same monotonic clock (time.monotonic()), in one process. Wall-clock timestamps can step backwards under NTP correction and produce negative round trips.
  • A measured ACK RTT distribution for your own deployment, to calibrate max_absolute_rtt_ms. The 500 ms default is a placeholder, not a standard.
  • A dispatch loop that can actually honour a backoff, and a separate path for risk-critical cancels that must never be delayed by it.

Workflow

  1. Register every submission, not just every acknowledgment. Call register_order_submission(order_id, t_sub) at dispatch. A detector fed only by completed ACKs sees only the orders that were not throttled into silence — the sample stream is survivorship-biased, and the worst throttle produces no sample at all.

  2. Record acknowledgments and compute RTT. On ACK, call record_order_ack(order_id, t_sub, t_ack); RTT is (t_ack - t_sub) x 1000 ms. A non-finite or time-reversed timestamp raises ThrottleDataError — do not clamp it to 0 ms. A fabricated 0 ms sample pulls the baseline down and makes the next healthy acknowledgments look anomalous.

  3. Maintain the baseline, excluding throttled samples. Update the exponentially weighted mean and variance (Finch 2009, eq. 143) only from samples not classified as throttled. Admitting the anomaly is what lets a sustained throttle train the baseline onto itself and go quiet while still in force.

  4. Classify against the pre-update baseline.

    • RTT >= max_absolute_rtt_ms → SILENT_THROTTLE, regardless of warmup.
    • baseline warm and z >= z_score_threshold → SILENT_THROTTLE.
    • baseline not yet warm → WARMUP (report it; do not report it as healthy).
    • z >= elevated_z_threshold → ELEVATED_LATENCY.
    • otherwise → NORMAL.

    where z = (RTT - EWMA) / sqrt(max(EWMVar, min_variance_clamp)). Evaluate every threshold against the baseline as it stood before this sample, so the reported mean, deviation and z-score reconcile and the decision is auditable.

  5. Sweep for acknowledgments that never came. Call sweep_pending_acks(now) at least as often as ack_timeout_ms. Any order older than the timeout is reported ACK_TIMEOUT — the most severe state — once, then dropped from the pending table so repeated sweeps do not re-escalate the same stall.

  6. Apply AIMD backoff. On a congestion signal, decrease dispatch rate multiplicatively (multiply the delay by backoff_multiplier, clamped to max_backoff_ms). On a healthy acknowledgment, increase dispatch rate additively (subtract backoff_additive_decrease_ms, to a floor of zero). Chiu & Jain (1989) is the control law being applied.

  7. Decide what recovery means, explicitly. By default the baseline stays frozen for as long as throttling persists, so a sustained throttle keeps alarming and keeps the backoff at its ceiling until a human intervenes. If the latency shift is genuinely permanent (a re-route, a venue migration), set rebaseline_after_consecutive to re-anchor after N consecutive throttled samples — accepting that the detector will then go quiet at the new level.

Full procedure: see references/workflows.md. Parameter reference and sourcing: see references/standards.md. Printable pre-flight checklist: see assets/checklist.md.

Common Pitfalls

  • Letting the throttle train its own baseline. If throttled samples are folded into the EWMA, a persistent 300 ms throttle against a 15 ms baseline reads NORMAL within about four samples and the backoff decays to zero while the broker is still queuing every order. Sustained throttling is the normal case during a volatility event, not the exotic one — exclude throttled samples from the baseline.
  • Measuring only the orders that came back. The worst silent throttle is an acknowledgment that never arrives. It generates no RTT sample, so a detector without a pending-order timeout keeps reporting the last healthy state indefinitely.
  • Clamping a negative round trip to zero. max(0.0, t_ack - t_sub) turns a backwards clock step or an out-of-order callback into a "perfect" 0 ms acknowledgment that drags the baseline down. Under the same clamp a NaN timestamp also becomes 0 ms, because max(0.0, nan) returns 0.0 — the detector is then quietly mis-calibrated with nothing logged. Reject both.
  • Trusting a z-score computed on a one-sample baseline. The first acknowledgment initialises the mean to itself with zero variance. If it landed inside a throttle, the poisoned baseline is the reference for the whole session. Report WARMUP until enough samples have accumulated, while keeping the absolute ceiling live.
  • Confusing network jitter with broker throttling. An isolated packet delay is not systemic congestion. The variance floor plus a warmup requirement is what separates them.
  • Overriding an explicit Retry-After. A latency inference is weaker evidence than the venue's own answer. When both are present the venue wins.
  • Backing off risk-critical cancels. The recommended delay is for new order flow. Applying it to a kill-switch cancel means the backoff has become the risk.

Verification

  • Establish a 15 ms baseline, then feed a sustained 300 ms RTT (above baseline, below the 500 ms ceiling) and confirm every sample stays SILENT_THROTTLE, the backoff climbs to max_backoff_ms, and the baseline mean is unchanged at 15 ms.
  • Feed a single 600 ms spike during warmup and confirm SILENT_THROTTLE still fires.
  • Register an order, never acknowledge it, sweep past ack_timeout_ms, and confirm one ACK_TIMEOUT report and no second report on the next sweep.
  • Confirm a NaN timestamp and a t_ack < t_sub pair each raise ThrottleDataError and leave the baseline untouched.
  • Confirm z_score in the report equals (latest_rtt_ms - ewma_rtt_ms) / ewmsd_rtt_ms.
  • Drive concurrent acknowledgments from multiple threads and confirm no samples are lost.
  • Run python -m unittest discover -s skills/broker-side-order-throttle-detection/scripts and confirm a 100% pass rate.

Related Skills

  • multi-broker-rate-limit-handling
  • matching-engine-throttle-and-message-gapping-detection
  • tick-buffering-burst-handling
  • structured-logging-for-post-incident-forensics

Arquivos incluídos

O modelo lê esses arquivos sob demanda enquanto a habilidade está carregada. Eles são disponibilizados para leitura e nunca são executados.

Perguntas frequentes

O que a habilidade de IA Broker Side Order Throttle Detection faz?

Use quando uma plataforma enfileira mensagens de ordem excedentes em vez de rejeitá-las, fazendo com que o congestionamento apareça apenas como latência nas confirmações. Detecta limitação de taxa não declarada com base na latência média móvel exponencialmente ponderada (EWMA) do tempo de ida e volta das confirmações (ACK) e regula o envio com recuo AIMD.

Por que usar Broker Side Order Throttle Detection no TypingMind?

Porque basta instalar uma vez para usar com qualquer modelo. A habilidade Broker Side Order Throttle Detection é escrita em Markdown simples, e não em código específico de um provedor, então a mesma habilidade funciona com GPT-5, Claude, Gemini, Grok ou um modelo local — e é possível trocar de modelo no meio do chat sem que ela deixe de funcionar. No TypingMind, você usa suas próprias chaves de API e paga diretamente aos provedores, em vez de pagar uma assinatura por licença de usuário. Suas habilidades e chats permanecem no seu próprio armazenamento.

Como instalar Broker Side Order Throttle Detection no TypingMind?

Abra Plugins → Habilidades → Instalar do GitHub no TypingMind e cole https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/broker-side-order-throttle-detection. O TypingMind lê o arquivo SKILL.md, reúne os arquivos da habilidade e a instala para que possa ser ativada em cada chat.

Quais modelos de IA podem usar Broker Side Order Throttle Detection?

Qualquer modelo conectado no TypingMind. As habilidades de IA são instruções em Markdown simples, e não código específico de um provedor. Assim, GPT, Claude, Gemini, Grok e modelos locais podem carregar esta habilidade quando uma solicitação corresponder a ela.

Quantos modelos de IA posso usar com Broker Side Order Throttle Detection?

Quantos quiser. Desde que o modelo ofereça suporte a habilidades, é possível usar Broker Side Order Throttle Detection com ele — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e outros — tudo no TypingMind com suas próprias chaves de API.

A habilidade de IA Broker Side Order Throttle Detection é gratuita?

Sim. A habilidade é publicada no GitHub por HimanshuJ16 sob a licença Apache-2.0. O pagamento é feito apenas ao seu provedor de IA pelos tokens usados.

O que são habilidades de IA?

Uma habilidade de IA é um conjunto reutilizável de instruções que ensina um modelo de IA a realizar uma tarefa específica. Ela segue o formato aberto Agent Skills: um arquivo SKILL.md com nome e descrição, além de scripts, templates ou arquivos de referência de que o modelo possa precisar. O modelo lê as instruções apenas quando sua solicitação corresponde à habilidade, então uma habilidade instalada não gera custos até ser usada.

Qual é a diferença entre habilidades de IA e plugins ou servidores MCP?

Um plugin ou servidor MCP oferece ao modelo novas ferramentas que ele pode acionar — código que é executado em algum lugar e retorna um resultado. Já uma habilidade de IA dá ao modelo o conhecimento e as orientações de que ele precisa: como abordar uma tarefa, quais etapas seguir e como deve ser um bom resultado. As habilidades são escritas em Markdown simples, por isso não precisam de servidor, chave de API nem ambiente de execução, e funcionam com qualquer modelo.

Ver lista completa

Crie seu próprio espaço de trabalho com IA agora

Inscreva-se na nossa newsletter para receber avisos sobre novos recursos e futuros sorteios 👇