Logo: Backpressure Drop Degrade Policy

Backpressure Drop Degrade Policy

Communautéit
HimanshuJ16
backpressure-drop-degrade-policy

Benotzt dëst, wann e begrenzte Tick-Puffer iwwer länger Zäit voll ass an Dir pro Stream eng Politik fir d'Verwerfen, d'Proufentnam oder d'Leeschtungsreduktioun festleeë musst, amplaz de blockéierende Standard vun enger Queue-Bibliothéik ze iwwerhuelen. Fir kuerzfristeg Spëtzte kuckt tick-buffering-burst-handling.

Add to TypingMind

Iwwersiicht

EditeurHimanshuJ16
RepositoryAlgo-Trading-Skills
Skill-Nummbackpressure-drop-degrade-policy
Stären
50
Forks
7
Matgeliwwert Dateien
5
LizenzApache-2.0
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 5 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    HimanshuJ16 huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Backpressure Drop Degrade Policy an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/backpressure-drop-degrade-policy
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

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/backpressure-drop-degrade-policy .claude/skills/backpressure-drop-degrade-policy
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Backpressure Drop Degrade Policy an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Backpressure Drop Degrade Policy automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Backpressure Drop Degrade Policy net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

When to Use

Invoke this once tick-buffering-burst-handling has established bounded buffers — this skill defines what happens when a buffer is persistently at capacity, i.e., sustained backpressure rather than a momentary burst. Every real-time trading system eventually falls behind producers; the difference between a robust system and a fragile one is whether that moment is handled by a deliberate, chosen policy or by whatever the underlying queue/library happens to do by default (often "block the producer" — the worst outcome, since it propagates the slowdown back to the WebSocket read loop).

When NOT to Use

  • For momentary bursts. A short spike that a bounded buffer absorbs is a buffering problem, not a policy problem — see tick-buffering-burst-handling.
  • When the consumer is merely slow-to-start. Fix the consumer or scale it out before deciding what to throw away; a drop policy applied to a fixable bottleneck permanently degrades data quality to paper over a solvable issue.
  • As a substitute for capacity planning. If a stream is always at its watermark, the policy is masking undersized infrastructure — see capacity-planning-for-symbol-universe-growth.
  • For order/execution acknowledgements. Those are not a droppable telemetry stream; reconciliation, not sampling, is the correct response to falling behind.

Prerequisites

  • Bounded buffers already in place (see tick-buffering-burst-handling)
  • A per-data-type criticality classification: which data can be dropped, sampled, or degraded, and which cannot

The Caller's Contract

handle_full() returns a BackpressureDecision. Check decision.accepted.

A NEVER_DROP stream at capacity returns accepted=False with the item in decision.rejected_item — the manager cannot store it for you and will not pretend it did. Treating that return as "handled" silently discards risk-critical data, which is precisely the failure this skill exists to prevent. Wire on_never_drop_overflow to your emergency path, or set strict_never_drop=True to raise.

Workflow

  1. Classify each data stream by what backpressure response is acceptable:
    • Drop-oldest: for streams where only the latest state matters (e.g., latest LTP for a position-monitoring display) — safe to discard stale ticks in favor of the newest.
    • Sample/throttle: for streams feeding non-critical downstream consumers (e.g., a dashboard chart) — admit 1 of every N items under load, leaving the existing backlog intact. Throttling admission is not the same as flushing the buffer: discarding half the queue on every overflow destroys far more data than the load actually requires.
    • Degrade to lower-resolution data: for streams that can fall back to a coarser representation (e.g., tick-level to 1-second OHLC) under sustained load.
    • Never drop: for streams tied directly to risk decisions (e.g., position/margin updates feeding the kill-switch). If they cannot keep up, that is a system health emergency requiring an alert and an explicit rejection the caller must handle — not a quiet policy application.
  2. Declare every stream's policy explicitly. An undeclared stream raises UnknownStreamError by default rather than falling back to a drop policy — a mistyped risk-stream name must not silently become a data-loss path.
  3. Call observe() on every push, not just on overflow. handle_full() alone cannot warn you early, because by the time it runs the queue is already full — for a NEVER_DROP stream that is already too late.
  4. Never let a "never drop" stream share a queue/thread pool with a "safe to drop" stream — resource contention means the safe-to-drop stream's load can degrade the never-drop stream's latency. Isolate by criticality tier, mirroring the tier separation in multi-broker-rate-limit-handling.
  5. Emit an explicit alert (not just a log line) when any "never drop" stream approaches capacity. Pass a real out-of-band alert_fn; the default only writes a log warning.
  6. Record, per backpressure event, which policy fired and what was dropped/degraded/throttled, so post-session review can assess whether the chosen policies matched what actually happened.

Full step-by-step procedure with broker-specific detail: see references/workflows.md. Broker/framework coverage table for this skill: see references/standards.md. Printable pre-flight checklist: see assets/checklist.md.

Common Pitfalls

  • Ignoring the return value. If handle_full() returns "nothing to do" for both a successful drop-oldest and a rejected risk item, the caller cannot distinguish them and the risk item is lost. Check accepted.
  • A bounded deque is already an implicit policy. collections.deque(maxlen=N) silently discards from the opposite end when you append to a full deque — Python documents this. If you append directly, you have chosen drop-oldest by accident. Route pushes through the manager.
  • Compound queue operations are not atomic. deque guarantees individual appends and pops are thread-safe, but reading len(queue) and then popping that many times races with a concurrent consumer and raises IndexError: pop from an empty deque — crashing the producer thread, which is usually the WebSocket read loop. Guard every pop.
  • Defaulting an unknown stream. Applying a "safe to drop" policy to a risk-relevant stream, usually because position/margin updates were lumped in with general market data or a stream name was mistyped.
  • Flushing the backlog in the name of "sampling." Discarding a fixed fraction of the queue per overflow event is a different, far more destructive behavior than reducing update frequency.
  • Silent degradation with no alerting — a system that quietly downgrades from tick-level to OHLC-level processing may be technically "working" while producing materially different signals than the strategy was validated against, and nobody notices until live performance diverges from backtest.
  • Zero-filling missing tick fields. Substituting 0.0 for an absent price corrupts every OHLC bar built from it. Reject the tick instead.
  • Misleading telemetry. A drop rate computed against overflow events rather than total pushes reads near 100% under load and tells you nothing; a rate of 0.0 when nothing was observed reads as healthy when it means "no data".
  • Treating backpressure policy as a one-time decision rather than something to revisit as strategies and data volumes change.

Verification

  • Run python -m unittest discover -s skills/backpressure-drop-degrade-policy/scripts — 100% pass rate (38 tests).
  • Under sustained simulated overload (replay at multiples of peak historical tick rate), confirm risk-critical streams return accepted=False and trigger the defined alert rather than silently discarding.
  • Confirm an undeclared stream name raises UnknownStreamError instead of being assigned a drop policy.
  • Confirm the overflow path does not raise when a consumer drains the queue concurrently.
  • Confirm dashboard/non-critical streams throttle admission while leaving the existing backlog intact.
  • Confirm get_metrics_summary() reports drop rates against observed pushes, and None (not 0.0) when nothing was observed.

Related Skills

  • producer-consumer-tick-pipeline
  • tick-buffering-burst-handling
  • kill-switch-and-drawdown-circuit-breakers
  • graceful-degradation-priority-during-partial-outage
  • capacity-planning-for-symbol-universe-growth

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Backpressure Drop Degrade Policy?

Benotzt dëst, wann e begrenzte Tick-Puffer iwwer länger Zäit voll ass an Dir pro Stream eng Politik fir d'Verwerfen, d'Proufentnam oder d'Leeschtungsreduktioun festleeë musst, amplaz de blockéierende Standard vun enger Queue-Bibliothéik ze iwwerhuelen. Fir kuerzfristeg Spëtzte kuckt tick-buffering-burst-handling.

Firwat Backpressure Drop Degrade Policy op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Backpressure Drop Degrade Policy besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Backpressure Drop Degrade Policy an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/backpressure-drop-degrade-policy an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Backpressure Drop Degrade Policy benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Backpressure Drop Degrade Policy benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Backpressure Drop Degrade Policy domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Backpressure Drop Degrade Policy gratis?

Jo. HimanshuJ16 huet de Skill ënner der Lizenz Apache-2.0 op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇