# Crypto Trade Post-Mortem from Exchange Fills (PnL, Exits)

> Read-only forensics on a crypto trade: settle which exit really fired from the exchange's own fills, prove PnL against venue fills to 1e-6, find orphaned conditional orders, and explain entries that never happened per venue.

Crypto Trade Post-Mortem from Exchange Fills (PnL, Exits) is a paid AI agent skill on Agensi by Claude Workflow Lab, in Trading & Investing. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $7 (one-time purchase)
- Creator: [Claude Workflow Lab](https://www.agensi.io/creators/creator-1578)
- Category: [Trading & Investing](https://www.agensi.io/skills/trading-investing)
- Version: 1.0.0
- Last updated: 2026-12-03
- Security: scan passed (2026-12-03); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/crypto-trade-post-mortem-from-exchange-fills-pnl-exits
- Tags: trading, research, testing, postmortem, forensics, pnl, gate, okx

## What it does

- Identifies which specific trigger or manual order closed a position using exchange-side IDs
- Calculates exact PnL by accounting for fills, fees, and currency conversions across different venues
- Detects orphaned orders and leftover coins that your bot might have missed or left behind
- Explains why orders failed to trigger by checking price ticks against exchange protection rules
- Reveals when bot labels like STOP LOSS are just guesses and points to the real reason for a close

## Who it's for

- **Crypto traders and fund managers:** Find out exactly why a trade closed or why a signal failed to fire on certain exchanges. Try: "Why was I stopped out of my BTC position on Gate.io this morning?"
- **Trading bot developers and maintainers:** Debug discrepancies between your logs and actual exchange behavior to fix hidden bugs. Try: "Find out why the take-profit for this trade was placed but never executed."
- **Account managers and bookkeepers:** Verify PnL to six decimal places and find missing funds or orphaned orders. Try: "Prove the PnL for yesterday's ETH trades against my exchange fills."

## About this skill

When a close alert says STOP LOSS you should be able to check it. This skill gives an agent a read-only method to settle what really happened on a trade from the exchange's own records, not from your bot's label.

What is inside:
- **SKILL.md** - the method: pull the venue's fills and conditional-order history, identify the exit by the order's text tag or conditional id, check whether the close-reason label and reported PnL are true (and why a nearest-price attribution routine can guess wrong and leave an orphaned conditional behind), reconcile PnL against fills to 1e-6 including fees, and look for leftover coins or orders on the account.
- **references/entry-never-happened.md** - a per-venue checklist for "why did this signal open nothing here": permissions, leverage and margin mode, symbol filters, minimum notional, and refusals that look like bugs.
- **scripts/fills_pnl.py** - recomputes PnL from fills.
- **scripts/price_order_time.py** - places a price on the order timeline to show what the market did around each order.
- **scripts/gate_close_attribution.sh** - read-only Gate close attribution.

For traders and developers who run their own bots across several exchanges. Needs Python 3 and read-only keys. It never places or cancels an order. Also part of the Crypto Trading Ops Playbooks pack at a lower per-skill price.

## Requires

- Binance
- Python 3 (standard library only) and bash
- Git

Access to your service logs and the position-closed message. Access to your service logs and the position-closed message.

## Known limitations

This skill is read-only and cannot cancel orders or move funds. It requires read-only API access to your exchange accounts.

## Technical details

Built for forensic analysis of Gate.io, OKX, Bitget, and Binance futures/spot trades. It uses shell scripts and Python for PnL reconciliation and Snowflake ID decoding. Requires read-only API keys in environment variables. Analyzes client-order-ids (e.g., Gate's 'text' field) to distinguish between service-sent orders and exchange-triggered conditionals. Compares fills against public tick data and mark/index candles to identify price-deviation protection triggers. Matches trade logs with venue fills to identify netting errors in one-way hold modes.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Crypto Trade Post-Mortem from Exchange Fills (PnL, Exits) skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### Why should I use this instead of just looking at my bot's trade alerts?

This skill compares your trading bot's logs against the exchange's actual records to find out why a trade really closed. It identifies if a stop-loss truly fired, why a take-profit order might have been ignored, and if your reported profits match what the exchange actually paid out.

### What do I need to have ready for this skill to work?

You need to provide your AI agent with read-only access to your exchange accounts, specifically for platforms like Binance, OKX, Bitget, or Gate.io. The skill also requires access to your bot's trade logs or database so it can compare the two sets of data.

### What kind of report will I receive after the investigation?

The skill produces a clear report showing which specific exit rule triggered the close and your exact profit or loss down to the cent. It also lists any orphaned or leftover orders that are still open on the exchange so you can decide whether to close them manually.

### Can this help me understand why a trade failed to open on certain exchanges?

It can explain why a signal might have opened a position on one exchange but not another, often caused by price limits or connection issues. It also checks for leftovers, such as small amounts of coins or orders that remained because the exchange force-converted your collateral.

### How do I tell my agent to start a forensic investigation?

You can ask your agent to investigate a specific trade by giving it the pair name and the time it happened, or by sharing a trade alert that looks incorrect. For example, you could ask, "Check why this stop-loss fired on Binance but not on OKX," or "Verify the exact PnL for my last BTC trade."

### Will this skill automatically fix my stuck orders or close bad trades?

This skill is strictly read-only and will never place, change, or cancel orders for you. If it finds a leftover order that shouldn't be there, it will report it to you so you can handle the manual fix yourself.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
