agentleFS
lungraylungray/investment-workflow-skill/skills/portfolio-parser/SKILL.md

portfolio-parser

Skill2 starsChanged 4 months agoMITView on GitHub

Use to extract holdings from screenshots, PDF, Word, Excel/CSV, Markdown, or text; parsing only.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Keep the existing top-level fields for compatibility: base_currency, source_files, confidence, holdings, cash_cny, bonds_cny, …

    line 25
  2. Very specific:

    No schema-version migration is required for old JSON.

    line 40
  3. Distinctive:

    Never invent quantity, cost, market value, P/L, cash, or eligibility.

    line 45
  4. Distinctive:

    Do not infer spendable cash from account assets minus stock value.

    line 48
  5. Very specific:

    If review fails, correct a copy of holdings.json, record concrete warnings/parse notes, and use the workflow's --holdings-json …

    line 62

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Portfolio Parser

Parse holdings into auditable JSON. Do not fetch market data, evaluate investment quality, or recommend trades.

Supported inputs

  • Images: local RapidOCR first, Tesseract fallback.
  • PDF: pdftotext; OCR only when text extraction is unavailable for scanned material.
  • CSV/xlsx, docx, Markdown, and plain text through the deterministic local parser.
  • Legacy .doc and .xls require conversion; do not pretend they parsed successfully.

Output contract

Keep the existing top-level fields for compatibility: base_currency, source_files, confidence, holdings, cash_cny, bonds_cny, missing_fields, and warnings.

Each holding preserves symbol, raw_symbol, name, market, eligible_scope, quantity, CNY cost/value/P&L fields, native last price, weight, raw rows, and parse notes. Unknown values are null.

The additive validation object contains:

{
  "status": "pass|review_required|fail",
  "checks": [
    {"id": "required_fields", "status": "pass|review_required|fail", "message": "..."}
  ]
}

No schema-version migration is required for old JSON; missing validation is treated as needing review by the orchestrator.

Parsing discipline

  1. Preserve raw rows/text for auditability.
  2. Never invent quantity, cost, market value, P/L, cash, or eligibility.
  3. User cost is CNY unless explicitly labelled otherwise. Hong Kong last price is native HKD.
  4. A Hong Kong code identifies the market, not current Stock Connect eligibility; leave eligibility unknown unless separately verified downstream.
  5. Do not infer spendable cash from account assets minus stock value. Wealth-management holdings and bonds are not cash.
  6. Duplicate positions are combined only when the source clearly describes the same holding.

OCR hard gate

Image OCR always returns review_required until a human/vision review confirms the original screenshot. Check:

  • complete stock-name count, including the first row;
  • 持仓 versus 可用 quantity;
  • waterfall/adjacent-row field bleed;
  • positive quantity and plausible cost/P&L;
  • quantity × native price × FX ≈ CNY market value when all inputs exist;
  • row sums against displayed total market value/P&L when present.

If review fails, correct a copy of holdings.json, record concrete warnings/parse notes, and use the workflow's --holdings-json --confirm-holdings-reviewed path. Do not re-OCR a manually corrected file.

CLI

python \
  skills/portfolio-parser/scripts/parse_portfolio.py \
  <holding-file>... -o <holdings.json>

See references/mobile-broker-screenshot-ocr.md and the workflow handbook.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.