# Portfolio Ledger Doctor: fix your trade history first

> Find transfers booked as sales, missing splits, oversells and net dividends in your CSV ledger; fix with consent and an undo log.

Portfolio Ledger Doctor: fix your trade history first is a paid AI agent skill on Agensi by Ignasi, in Finance & Accounting. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $5 (one-time purchase)
- Creator: [Ignasi](https://www.agensi.io/creators/ignasi)
- Category: [Finance & Accounting](https://www.agensi.io/skills/finance-accounting)
- Version: 1.0.0
- Last updated: 2026-11-23
- Security: scan passed (2026-11-23); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/portfolio-ledger-doctor-fix-your-trade-history-first
- Tags: trading-investing, portfolio, tax, csv, crypto

## About this skill

A return or a tax gain is a replay of your transaction list. When the list is wrong the number is wrong and still looks confident. The mistakes that matter sit where two brokers' statements meet, and no single statement shows them. This skill gives your agent the method and a scanner to find them, show what each one does to your numbers, and fix only what you have approved.

### What it does

Reads a CSV ledger strictly (a bad row refuses the file, with line numbers), lists findings most-reliable first, and for each one gives the signature, the evidence that would confirm it, the fix, and its before/after effect on holdings, realized gain and dividends. Apply writes a new file and an undo log; undo restores the original byte for byte.

Nine checks: transfer between brokers imported as sale + buy (doubled position, phantom gain); ISIN-vs-symbol double positions; missing splits, reverse splits and retired `.OLD` lines; oversell with a cause trace (duplicate, fee, split, transfer, unexplained); return of capital booked as dividend; crypto fees left in the coins; dividends imported net; duplicates from re-imports; currency and pence-vs-pounds slips.

### What you get

| File | Holds |
|---|---|
| SKILL.md | Contract, procedure, fix order, hard rules |
| references/checks.md | Signature, confirmation, fix, effect and traps per check |
| references/confirming.md | Which document settles each finding |
| scripts/ledger_doctor.py | scan / apply / undo, Python 3.9+ standard library, offline |
| templates/ | Proposal block and closing report |
| examples/ | Ledger with planted errors, its real scan output, a malformed file |

### Who it's for

Self-directed investors with more than one broker or an exchange account, anyone about to file a tax return from broker exports, and people building portfolio tooling who want the failure signatures spelled out.

### Scope

Covered: the nine checks on a multi-broker CSV ledger, stocks and crypto. Not covered: the script is offline, so it does not check prices against splits (the reference explains how, by hand), look up ISINs, convert currencies or compute tax. Map your broker's export into the column shape first. Low-confidence findings are questions for your statements, not verdicts.

Not investment, tax or accounting advice.

## Requires

- Python 3.9+ (standard library only)

A CSV ledger with date, action, symbol, qty, price (currency, fee, broker recommended).

## Known limitations

Offline: does not check prices against splits, resolve ISINs, convert FX or compute tax. Split and dividend findings are low/medium confidence until confirmed outside the ledger. Partial broker transfers (quantities differ) are not auto-matched. One currency-agnostic replay; a symbol in two currencies is flagged, not split.

## 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 Portfolio Ledger Doctor: fix your trade history first 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

### Does it change my file?

No. Scan is read-only. Apply writes a new file plus an undo log; undo restores your original text exactly, and refuses if the fixed file changed since.

### Which brokers are supported?

It reads a generic CSV (date, action, symbol, qty, price, currency, fee, broker). Map your export into that shape first; the skill is broker-neutral.

### Does it need internet or an API key?

No. It is offline standard-library Python. The reference explains which checks you should confirm with outside data such as a split calendar.

### Will it compute my taxes?

No. It finds and fixes ledger errors so the numbers a tax tool reads are right. It reports effect on realized gain per currency, in the ledger's own currencies.

### How reliable are the findings?

Each has a confidence from the rows alone. High means the evidence is in the rows (e.g. an arrival priced at the departing basis); low is a question to settle with a statement.

---

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.
