Files
daily_stock_analysis/docs/image-extract-prompt.md
Alfred 633bdda1e2 [feat] 2.2 智能导入 - 名称解析、图片提取、CSV/Excel 导入、预览确认 (#546)
* feat(#455): Markdown-to-image for dashboard, m2f engine, prefetch controls

- Dashboard report supports markdown-to-image (Telegram/WeChat/Custom/Email)
- MD2IMG_ENGINE=markdown-to-file for better emoji support
- PREFETCH_REALTIME_QUOTES to disable full-market quote prefetch
- Stock name prefetch with allow_realtime=False to reduce network overhead
- Email groups and Custom webhook image routing
- Enhanced failure hint (wkhtmltopdf or m2f)
- Docs: README, full-guide, CHANGELOG, .env.example
- Tests: prefetch_stock_names, pipeline notification routing, prefetch dry_run

Fixes #455

* chore: trigger CI and AI review refresh

* feat: intelligent import P1 - name resolver, image extract, CSV/Excel import, preview UI

- Extract STOCK_NAME_MAP to src/data/stock_mapping.py
- Add name_to_code_resolver (local map, pinyin, AkShare, fuzzy match)
- Add stock_code_utils for shared is_code_like/normalize_code
- Enhance image_stock_extractor: code+name+confidence prompt, multi-key, retry
- Add import_parser for CSV/Excel/clipboard with parse-import API
- Add IntelligentImport component (image+file+paste, dedup, confidence-based check)
- Fix single-column code import, preserve name when code dirty
- Deduplicate codes in parse-import response
- Add unit tests for resolver and import_parser

* fix: resolve TS2339 Property 'id' does not exist on type 'never'

In mergeItems when !existing, use fallback id directly instead of existing?.id
to avoid TypeScript narrowing existing to never in that branch.

* chore: address PR review - deps doc, file size check, json_repair, logging, tests

- docs/full-guide: document pypinyin and openpyxl for 智能导入
- api: add file size check before reading in parse-import
- image_stock_extractor: use json_repair fallback for malformed JSON
- import_parser/name_to_code_resolver: add debug logging
- CHANGELOG: add extract-from-image items field compatibility note
- tests: VISION_MODEL priority, json_repair when JSON invalid

* fix(image-extract): markdown strip bug, fake codes filter, EXTRACT_PROMPT doc, parse_import errors

- Fix markdown strip: only remove opening fence to avoid wiping JSON
- Add JSON to _FAKE_CODES; filter field names in fallback
- Add docs/image-extract-prompt.md; PR template EXTRACT_PROMPT block
- Refine parse_import errors: Excel/CSV actionable hints

* chore(parse_import): add detailed error logs, document AkShare cache

- Log file type, size, error on parse_import failures (JSON, file read, parse)
- Add AkShare name resolver 1h TTL cache note to docs/full-guide.md

* fix(import): handle space-separated pairs and confidence upgrade

* fix(import): address PR #546 review - Excel no-header, fuzzy cutoff, code prefix

- fix(import_parser): use header=None for read_excel; detect header row the same
  way as the CSV path to avoid silently consuming first data row as column names
- fix(name_to_code_resolver): raise difflib cutoff 0.6->0.8 and skip fuzzy
  matching for inputs of length <=2 to prevent false-positive short
  matches (e.g. '中国' matching arbitrary stocks in a 5000+ name pool)
- fix(stock_code_utils): normalize_code and is_code_like now recognise
  exchange-prefix formats SH600519, SZ000001, HK00700 (case-insensitive),
  aligning with data_provider/base.py normalize_stock_code behaviour
- tests: add test_parses_xlsx_without_header to TestParseImportFromBytesExcel;
  add tests/test_stock_code_utils.py covering prefix/suffix/plain/edge cases

---------

Co-authored-by: mumu <42829555+ZhuLinsen@users.noreply.github.com>
2026-03-09 19:21:50 +08:00

1.7 KiB
Raw Permalink Blame History

Image Extract Prompt (Vision LLM)

本文档记录 src/services/image_stock_extractor.pyEXTRACT_PROMPT 的完整内容,便于 PR 审查时评估指令效果。

当修改 EXTRACT_PROMPT 时:请同步更新此文件,并在 PR 描述中展示完整变更before/after以便审查者评估针对 code+name+confidence 提取的优化程度。


当前 Prompt完整

请分析这张股票市场截图或图片,提取其中所有可见的股票代码及名称。

重要若图中同时显示股票名称和代码如自选股列表、ETF 列表),必须同时提取两者,每个元素必须包含 code 和 name 字段。

输出格式:仅返回有效的 JSON 数组,不要 markdown、不要解释。
每个元素为对象:{"code":"股票代码","name":"股票名称","confidence":"high|medium|low"}
- code: 必填股票代码A股6位、港股5位、美股1-5字母、ETF 如 159887/512880
- name: 若图中有名称则必填(如 贵州茅台、银行ETF、证券ETF与代码一一对应仅当图中确实无名称时可省略
- confidence: 必填识别置信度high=确定、medium=较确定、low=不确定

示例(图中同时有名称和代码时):
- 个股600519 贵州茅台、300750 宁德时代
- 港股00700 腾讯控股、09988 阿里巴巴
- 美股AAPL 苹果、TSLA 特斯拉
- ETF159887 银行ETF、512880 证券ETF、512000 券商ETF、512480 半导体ETF、515030 新能源车ETF

输出示例:[{"code":"600519","name":"贵州茅台","confidence":"high"},{"code":"159887","name":"银行ETF","confidence":"high"}]

禁止只返回代码数组如 ["159887","512880"],必须使用对象格式。若未找到任何股票代码,返回:[]