Logo von Broker Account Margin Call Handling

Broker Account Margin Call Handling

Community
HimanshuJ16
broker-account-margin-call-handling

Verwenden Sie diese Skill, wenn ein Bot mit einem Reg-T-, Portfolio- oder Futures-Marginkonto handelt und eingreifen muss, bevor der Broker Positionen liquidiert. Der Skill umfasst gestaffelte Warnungen zur Maintenance Margin, die mit der verfügbaren Liquidität beim Broker abgeglichen werden, eine Prüfung der Initial Margin vor der Orderaufgabe und einen liquiditätsbewussten Abbau des Hebels.

Add to TypingMind

Übersicht

HerausgeberHimanshuJ16
RepositoryAlgo-Trading-Skills
Skill-Namebroker-account-margin-call-handling
Sterne
50
Forks
7
Mitgelieferte Dateien
5
LizenzApache-2.0
Links
  • Anweisungen in Markdown

    Eine SKILL.md-Datei, die das Modell bei Bedarf lädt. So werden nur dann Token verbraucht, wenn eine Anfrage tatsächlich dazu passt.

  • Funktioniert mit jedem LLM

    KI-Skills bestehen aus reinem Markdown, nicht aus anbieterspezifischem Code. Daher funktionieren sie mit GPT, Claude, Gemini, Grok oder einem lokalen Modell.

  • Mitgelieferte Dateien: 5

    Skripte, Vorlagen und Referenzmaterial, die das Modell bei der Arbeit lesen kann. Die Dateien sind schreibgeschützt und werden niemals ausgeführt.

  • Open Source

    Von HimanshuJ16 auf GitHub veröffentlicht. Prüfen Sie vor der Installation die Quelldateien.

Installation

Installieren Sie den KI-Skill Broker Account Margin Call Handling in TypingMind, um ihn mit jedem LLM zu nutzen, oder fügen Sie ihn einem anderen Agenten hinzu, der SKILL.md lesen kann.

1

In TypingMind installieren

TypingMind installiert einen Skill direkt aus seinem GitHub-Ordner. Dabei liest die App SKILL.md, bündelt die Ressourcendateien und speichert das Ergebnis lokal.

  1. Öffnen Sie die App und gehen Sie zu Plugins → Skills.
  2. Wählen Sie „Von GitHub installieren“.
  3. Fügen Sie die unten angegebene URL des Skill-Ordners ein und bestätigen Sie.
    https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/broker-account-margin-call-handling
  4. Aktivieren Sie den Skill in jedem Chat, in dem er verfügbar sein soll.
Plugins → Skills → Skill hinzufügen → Über GitHub-URL. Fügen Sie dann die Ordner-URL ein und klicken Sie auf „Weiter“.
2

In einem anderen Agenten installieren

Jeder Agent, der das Agent-Skills-Format unterstützt, kann diesen Skill nutzen. Kopieren Sie den Ordner in das Skill-Verzeichnis des jeweiligen Agenten.

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-account-margin-call-handling .claude/skills/broker-account-margin-call-handling
Starten Sie Claude Code nach dem Kopieren neu, damit der neue Skill erkannt wird.

In TypingMind verwenden

Aktivieren Sie Broker Account Margin Call Handling in einem beliebigen Chat in TypingMind. Den Rest übernimmt das Modell. Name und Beschreibung des Skills stehen im System-Prompt. Sobald eine Anfrage passt, lädt das Modell selbstständig die vollständigen Anweisungen — Sie müssen den Skill nie manuell aufrufen, und er verbraucht erst Token, wenn er tatsächlich genutzt wird.

Das Modell lädt Broker Account Margin Call Handling automatisch, sobald eine passende Anfrage gestellt wird.

Funktioniert mit jedem KI-Modell

KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher ist Broker Account Margin Call Handling nicht an das Modell gebunden, für das der Skill geschrieben wurde. Installieren Sie ihn einmal in TypingMind und nutzen Sie ihn mit GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder einem selbst betriebenen lokalen Modell — alles mit Ihren eigenen API-Schlüsseln.

  • Wird nur bei Bedarf geladen

    Der System-Prompt enthält nur den Namen und die Beschreibung. Die Anweisungen werden bei der ersten passenden Anfrage geladen. Ein ungenutzter Skill verursacht daher keine Kosten.

  • Modell im laufenden Chat wechseln

    Da der Skill aus Anweisungen statt aus Code besteht, funktioniert er auch nach einem Modellwechsel — das nächste Modell liest dieselbe SKILL.md-Datei.

Skill-Anweisungen

Dies ist der Inhalt von SKILL.md, den das Modell lädt. Lesen Sie ihn vor der Installation — ein Skill besteht aus Anweisungen, denen Ihr Modell folgt.

When to Use

Invoke this whenever an algorithmic trading bot operates on a margin account (Reg T, Portfolio Margin, or futures margin). When adverse market moves push maintenance margin requirements toward or past account equity, brokers liquidate positions at market prices, and they choose which ones. Acting first — cancelling resting orders, blocking new leverage, and unwinding on your own schedule with liquidity limits — is the difference between a controlled reduction and a forced one.

Use it to run three gates: a tiered house ratio as early warning, a broker-cushion check that catches deficiency the house ratio can miss, and a pre-trade veto on orders that would consume margin you do not have.

When NOT to Use

  • As a substitute for the broker's own numbers. The engine grades a snapshot you supply. If your feed is stale, the grade is stale. Poll excess_liquidity and available_funds from the broker; do not derive them from NLV.
  • As a guaranteed way to beat the broker to liquidation. IBKR does not make margin calls — it liquidates in real time, without prior notice, and may do so without the account ever displaying a margin warning. If you are already at BREACH you may have no window at all. The pre-breach tiers are where this skill earns its keep.
  • To size liquidations under Portfolio Margin or SPAN without re-pricing. The planner assumes margin is separable per position. Under portfolio-level regimes, closing one leg of a hedge can raise total margin — see Workflow step 5.
  • On a cash account, or for exchange margin-shortfall penalty accounting, which is a separate settlement-side concern.

Prerequisites

  • Broker real-time account data: net_liquidation_value, initial_margin, maintenance_margin, and critically excess_liquidity and available_funds.
  • A pre-trade margin impact source. Estimating it is the weak link — get it from the broker. At IBKR that is an Order.whatIf = true submission, whose OrderState returns initMarginChange and maintMarginChange.
  • An open-order cancellation interface.
  • Per-position average_daily_volume. It is a required field, not an optional one: it caps how much of a position the plan will sell, and a guessed value defeats the cap.
  • An execution path for liquidation slices (TWAP/VWAP or equivalent).

Workflow

  1. Evaluate account health with evaluate_margin_health(snapshot). It escalates on the worse of two signals:

    • the house ratio $M = \text{maintenance margin} / \text{NLV}$, against your configured tiers, and
    • excess_liquidity < 0, the broker's own cushion, which is authoritative. Unusable input (NaN, infinity, negative margin) raises MarginDataError rather than grading the account. A margin engine that reports NORMAL because its feed broke is worse than one that stops.
  2. Act on the tier. Defaults are house policy, not regulation — set them for your book:

    • NORMAL ($M < 0.85$): trade normally.
    • WARNING ($0.85 \le M < 0.95$): block new leverage-increasing orders; alert.
    • CRITICAL ($0.95 \le M < 1.0$): cancel all resting orders to release reserved margin.
    • BREACH ($M \ge 1.0$, or negative excess liquidity): de-leverage now. For calibration, IBKR's own warning fires at roughly a 90.9% maintenance/ELV ratio, between the 85% and 95% defaults.
  3. Handle non-positive equity as a different problem. If NLV $\le 0$ the ratio is undefined — the engine returns math.inf and the action HALT_AND_ESCALATE rather than DE_LEVERAGE_IMMEDIATELY. There is no target margin to de-leverage toward against non-positive equity; stop trading and involve a human.

  4. Gate every new order through guard_new_order(snapshot, margin_impact, initial_margin_impact=...). Pass initial_margin_impact whenever you have it: new positions are opened against initial margin (Reg T requires 50% on a long margin equity purchase) not maintenance margin (FINRA 4210's 25% minimum), so a maintenance-only projection is the weaker constraint and can pass an order the broker refuses. The guard returns True or raises — it never returns False, so treat any exception as a hard veto.

  5. Plan de-leveraging with plan_deleveraging(snapshot, positions), which orders by short-option tail risk, then margin density, then liquidity, and caps each slice at max_participation_rate of ADV. Then re-price the plan before acting on it if you are on Portfolio Margin or SPAN — the planner's linear "units × margin per unit" model does not hold when margin is computed on portfolio-level stressed loss, and unwinding a hedge leg can increase the requirement. Send each slice through the broker's own pre-trade check first.

  6. Expect the plan to be incomplete under illiquidity. The ADV cap can leave the plan short of the required reduction. That is the intended trade-off — dumping the position would crush its price, lower NLV and trigger a second deficiency — but it means you must check whether the plan actually clears the deficit and escalate when it does not.

Full step-by-step procedure with broker-specific detail: see references/workflows.md. Broker triggers, cushion definitions and regulatory reference points: see references/standards.md. Printable pre-flight checklist: see assets/checklist.md.

Common Pitfalls

  • Trusting the house ratio alone. maintenance_margin / NLV uses NLV; the broker's cushion uses Equity with Loan Value, which excludes non-margin-eligible value and can be much lower. An account can read 70% and healthy while excess_liquidity is already negative and liquidation is underway.
  • Letting NaN through a threshold chain. Every comparison against NaN is False, so a NaN ratio falls past >= breach, >= critical and >= warning into the healthy branch. A broken feed must fail closed.
  • Checking new orders against maintenance margin. Positions are opened against initial margin, which is roughly double under Reg T.
  • Flooring NLV to avoid dividing by zero. It manufactures a finite ratio from an undefined one and, if the deficit is computed from the floored value, understates the deficit by exactly the amount of negative equity.
  • Exempting "de-leveraging" orders without checking they de-leverage. A bypass flag that is trusted unconditionally lets a margin-increasing order through every gate.
  • Unordered thresholds. Setting warning above critical makes the WARNING tier unreachable — the account jumps straight to CRITICAL and the early gate never fires.
  • Passive waiting for broker liquidation, taking market-order slippage on positions someone else chose.
  • Illiquidity spirals: dumping an illiquid asset at once, crushing the bid, lowering NLV, and triggering a secondary call.
  • Ignoring tail risk: unwinding long equity first while naked short options stay open through a volatility spike.
  • Ignoring the clock. Where the broker force-closes intraday products on a schedule (Zerodha squares off MIS positions around 15:20 IST), being margin-healthy is not enough.

Verification

  • Run the unit suite and confirm every test passes: python -m unittest discover -s skills/broker-account-margin-call-handling/scripts
  • Feed a snapshot with a healthy ratio but negative excess_liquidity and confirm the state is MARGIN_CALL_BREACH with broker_deficiency set — this is the failure mode most likely to be missed in production.
  • Feed NaN in each snapshot field in turn and confirm MarginDataError every time; a NORMAL result from any of them is a fail-open bug.
  • Check each tier at its exact boundary (85.0%, 95.0%, 100.0%), not just mid-band.
  • Submit a snapshot with $M = 0.88$ and confirm WARNING.
  • Submit an order whose initial_margin_impact exceeds available_funds and confirm the veto, even when the maintenance projection alone would have passed.
  • Replay a historical drawdown that actually breached, and confirm the tiers would have fired early enough to matter given your broker's liquidation behaviour.

Related Skills

  • kill-switch-and-drawdown-circuit-breakers
  • options-margin-span-calculation-global
  • correlation-aware-exposure-limits
  • margin-utilization-circuit-breaker

Mitgelieferte Dateien

Das Modell liest diese Dateien bei Bedarf, während der Skill geladen ist. Sie werden als lesbare Dateien bereitgestellt und niemals ausgeführt.

Häufig gestellte Fragen

Was macht der KI-Skill Broker Account Margin Call Handling?

Verwenden Sie diese Skill, wenn ein Bot mit einem Reg-T-, Portfolio- oder Futures-Marginkonto handelt und eingreifen muss, bevor der Broker Positionen liquidiert. Der Skill umfasst gestaffelte Warnungen zur Maintenance Margin, die mit der verfügbaren Liquidität beim Broker abgeglichen werden, eine Prüfung der Initial Margin vor der Orderaufgabe und einen liquiditätsbewussten Abbau des Hebels.

Warum Broker Account Margin Call Handling in TypingMind nutzen?

Weil Sie den Skill einmal installieren und mit jedem Modell verwenden können. Broker Account Margin Call Handling besteht aus reinem Markdown statt aus anbieterspezifischem Code. So funktioniert derselbe Skill mit GPT-5, Claude, Gemini, Grok oder einem lokalen Modell – und Sie können das Modell mitten im Chat wechseln, ohne dass der Skill seine Funktion verliert. TypingMind verwendet Ihre eigenen API-Schlüssel. Sie bezahlen die Anbieter daher direkt statt über ein Abonnement pro Nutzerplatz, und Ihre Skills und Chats bleiben in Ihrem eigenen Speicher.

Wie installiere ich Broker Account Margin Call Handling in TypingMind?

Öffnen Sie in TypingMind Plugins → Skills → Von GitHub installieren und fügen Sie https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/broker-account-margin-call-handling ein. TypingMind liest die Datei SKILL.md, bündelt die zugehörigen Dateien und installiert alles als Skill, den Sie für jeden Chat einzeln aktivieren können.

Welche KI-Modelle können Broker Account Margin Call Handling nutzen?

Jedes Modell, das Sie mit TypingMind verbinden. KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher können GPT, Claude, Gemini, Grok und lokale Modelle diesen Skill laden, wenn eine Anfrage dazu passt.

Wie viele KI-Modelle kann ich mit Broker Account Margin Call Handling verwenden?

So viele Sie möchten. In TypingMind können Sie Broker Account Margin Call Handling mit jedem Modell verwenden, das Skills unterstützt, etwa mit GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama. Dabei nutzen Sie Ihre eigenen API-Schlüssel.

Ist der KI-Skill Broker Account Margin Call Handling kostenlos?

Ja. Der Skill wird von HimanshuJ16 auf GitHub unter der Lizenz Apache-2.0 veröffentlicht. Sie bezahlen nur Ihren eigenen KI-Anbieter für die verwendeten Token.

Was sind KI-Skills?

Ein KI-Skill ist ein wiederverwendbares Anweisungspaket, das einem KI-Modell vermittelt, wie es eine bestimmte Aufgabe erledigt. Es folgt dem offenen Format Agent Skills: Die Datei SKILL.md enthält den Namen und die Beschreibung des Skills. Hinzu kommen bei Bedarf Skripte, Vorlagen oder Referenzdateien für das Modell. Das Modell liest die Anweisungen nur, wenn Ihre Anfrage zum Skill passt. Ein installierter Skill verursacht daher erst Kosten, wenn er verwendet wird.

Wie unterscheiden sich KI-Skills von Plugins oder MCP-Servern?

Ein Plugin oder MCP-Server stellt einem Modell neue aufrufbare Tools bereit – Code, der auf einem System ausgeführt wird und ein Ergebnis zurückgibt. Ein KI-Skill vermittelt dem Modell stattdessen Wissen und Vorgehensweisen: wie es eine Aufgabe angeht, welche Schritte es befolgt und wie eine gute Ausgabe aussieht. Skills bestehen aus reinem Markdown und kommen daher ohne Server, API-Schlüssel und Laufzeitumgebung aus. Sie funktionieren mit jedem Modell.

Alle anzeigen

Jetzt eigenen KI-Arbeitsbereich einrichten

Abonnieren Sie unseren Newsletter und erfahren Sie mehr über neue Funktionen und kommende Gewinnspiele 👇