从图片自动识别股票并加入股票池。触发条件:用户发送股票截图/图片并要求加入股票池。功能:(1) 使用RapidOCR识别图片中的股票代码、名称、涨幅、价格;(2) 自动去重;(3) 按FIFO原则最多管理30只股票;(4) 保存到manual_stock_list.json。
从图片识别股票代码并自动加入股票池。
/Users/wy/.openclaw/media/inbound/{uuid}.jpgstone_quant/manual_stock_list.jsonpython
from rapidocr_onnxruntime import RapidOCR
import cv2
ocr = RapidOCR()
img = cv2.imread(img_path)
result, _ = ocr(img)
stocks = []
for bbox, text, conf in result:
if text.isdigit() and len(text) == 6:
code = text
# 下一条通常是名称
stocks.append(code)
json
{
"stocks": [
{"code": "600010", "name": "包钢股份", "add_time": "22:30", "source": "图片识别"}
]
}