stop-management

A command that manages protective stop actions for all open MEICAgent trades across configured symbols.

In plain words
What is it for?
Use it during each loop to check working stop orders, record filled leg exits, and apply the configured stop-management rules using current market data.
Why use it?
It handles software-triggered closing orders and trade-state updates when option-combination stops are filled, cancelled, or need action.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/joncovington/meicagent/stop-management
Clone the repo
git clone --depth 1 https://github.com/joncovington/MEICAgent

Made for: Claude Code.

Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,346 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.02346
Opus 5 $0.00000 $0.01173
Sonnet 5 $0.00000 $0.00469
Haiku 4.5 $0.00000 $0.00235

Measured 2d ago against content hash 6ce51767da8b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

stop-management scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/stop-management.md · 63 lines

How it starts

The opening of the file, as written. The whole thing — 63 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Run the MEICAgent stop management step. Executes every loop iteration for all open trades across every configured symbol in one pass (not scoped to one symbol) — each trade record already carries its own symbol, so every rule below that references "the symbol" means that specific trade's symbol, not a single configured default.

Requires: open trades list and current market data (underlying price, option chain) already gathered this iteration.

  1. Detect and chase unfilled stop-close orders — tastytrade doesn't support exchange-level multi-leg stop orders for combos, so put_stop_order_id/call_stop_order_id on an open or partial IC identify a software-triggered closing order placed in a prior iteration (Step 5 below), not a resting exchange stop. For each open/partial IC with one of these order IDs set, check working orders:

    • Order no longer working (filled): the side is closed. Confirm the fill price from the order/transaction history, update put_stop_cost/call_stop_cost with the actual fill, and record the leg now: python src/db.py record_leg_exit --ic_order_id "<id>" --side put|call --status stopped --exit_time "<iso>" --exit_reason "<reason>" --exit_price <actual_fill_price> --pnl <leg_pnl>. Clear the stored order ID.
    • Order still working (unfilled): the quote moved away since it was placed. Cancel it (python src/tt.py close_position --order_id <id>), recompute the closing price from fresh quotes using the same formula as Step 5 ((short_ask − long_bid) × stop_limit_current), resubmit a new Day limit, and update the stored order ID to the new order. Do not call record_leg_exit yet — that only happens once a fill is confirmed, so P&L isn't recorded against an order that never actually executed.
  2. Cancel stale pending entries — any IC in pending or partial_entry status with entry_time more than 10 minutes ago:

    • Cancel the working order: python src/tt.py close_position --order_id <id>
    • If partially filled (one spread filled, one not), close the filled spread immediately to remove unhedged exposure.
    • Update status to cancelled.
  3. Confirm fills — for any IC in pending status, check working orders. If the order is no longer listed, confirm the fill:

    • Update status to open, set fill_confirmed_at.
    • put_stop_order_id/call_stop_order_id stay unset at this point — tastytrade doesn't support exchange-level combo stops, so these fields are only populated later, in Step 5, when a software stop actually places a closing order.
  4. No profit target — MEIC does not close iron condors at a percentage of profit. A spread is only ever exited by a per-side stop (Step 5), a time-based/event force-close or physical-settlement close (Step 7), or — for cash-settled symbols — left to expire and settled at the close (Step 7). Do not close an IC early just because it has become cheap/profitable. (This is distinct from ORB debit spreads, which have their own orb_profit_target_pct.)

  5. Monitor software stops (per-side) — for each open IC, manage the call spread and put spread independently:

    Per-side cost computation:

    • call_spread_cost_mid = short_call_mid − long_call_mid (positive = cost to close the short call spread)
    • put_spread_cost_mid = short_put_mid − long_put_mid (positive = cost to close the short put spread, note: put mids are positive)

    Per-side stop trigger: each side's stop fires when its cost equals or exceeds net_credit (the total IC credit). This means a single bad side can cost up to the full collected premium before being stopped — protecting capital at net breakeven while allowing the other side to continue decaying.

    • If call_spread_cost_mid ≥ stop_trigger_current × net_credit and no call_stop_order_id is already working (i.e. this side isn't already being chased per Step 1):
      • Close the call spread only (BTC short call + STC long call) at (short_call_ask − long_call_bid) × stop_limit_current as a Day limit. The stop_limit_current cushion (default 1.02, config stop_limit_ratio) prices the limit slightly past the marketable crossing price so it fills promptly even if the quote ticks against you before the order reaches the exchange.
      • Update call_stop_cost and exit_reason for the call side. Set IC status to partial (put spread still open). Record the new order's ID into call_stop_order_id (python src/db.py update_trade --ic_order_id "<id>" --call_stop_order_id <order_id>).
      • Do not call record_leg_exit yet — Step 1 confirms the fill and records the leg next iteration (or immediately if you can confirm the fill within this same iteration).
      • The put spread continues to run independently; re-evaluate it on every subsequent iteration.
    • If put_spread_cost_mid ≥ stop_trigger_current × net_credit and no put_stop_order_id is already working:
      • Close the put spread only (BTC short put + STC long put) at (short_put_ask − long_put_bid) × stop_limit_current as a Day limit, same cushion rationale as above.
      • Update put_stop_cost and exit_reason for the put side. Set IC status to partial. Record the new order's ID into put_stop_order_id.
      • Do not call record_leg_exit yet — same as above, Step 1 confirms and records the fill.
      • The call spread continues to run independently.
    • If both sides have triggered in the same iteration (uncommon), close the full IC in one combo order, record its ID into both put_stop_order_id and call_stop_order_id, and let Step 1 confirm and record both legs next iteration.

Read the full file on GitHub · 63 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 63 lines · 0 tokens per session scan A 6ce51767da8b

Subscribe to this mod's changes

stop-management is a command published in the GitHub repository joncovington/MEICAgent (4 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,346 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.