# stock_llm **Repository Path**: benjamin2018/stock_llm ## Basic Information - **Project Name**: stock_llm - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-12 - **Last Updated**: 2026-03-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # A-Share Simulation System ## Prerequisites - Java 11+ (Detected at: `C:\Program Files\Eclipse Adoptium\jdk-11.0.28.6-hotspot`) - Maven 3.6+ (Optional, Wrapper included) - Node.js 16+ ## Quick Start (Windows) Double-click the following scripts in the project root: 1. **run_backend.bat** - Starts the Spring Boot backend (wait for "Started StockTradeApplication in ..."). 2. **run_frontend.bat** - Starts the Vue 3 frontend. Access the application at `http://localhost:5173`. ## 配置(.env / 环境变量) 项目默认使用 MySQL(stockdb)。建议在项目根目录创建 `.env`(已被 .gitignore 忽略),写入: ```env STOCK_DB_JDBC_URL=jdbc:mysql://localhost:3306/stockdb?useSSL=false&allowPublicKeyRetrieval=true STOCK_DB_USER=root STOCK_DB_PASSWORD=12345 LLM_API_KEY=你的key LLM_API_URL=https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions LLM_MODEL=qwen3.5-flash ``` `run_backend.bat` 会自动加载 `.env`(若变量已在系统环境里存在则不会覆盖)。 ## Manual Run ### 1. Backend (Spring Boot) Open a terminal in the `backend` directory and run: ```bash cd backend # PowerShell $env:JAVA_HOME = 'C:\Program Files\Eclipse Adoptium\jdk-11.0.28.6-hotspot' .\mvnw.cmd spring-boot:run ``` The backend will start on `http://localhost:8080`. ### 2. Frontend (Vue 3) Open a new terminal in the `frontend` directory and run: ```bash cd frontend npm install npm run dev ``` ## Features - **K-Line Chart**: Visualizes mock stock data (e.g., Moutai 600519). - **Trade**: Buy and Sell stocks with simulated funds. - **Assets**: View current balance and stock holdings. - **Data Persistence**: In-memory (H2 Database), resets on restart. ## API(Postman 调用) 后端默认地址:`http://localhost:8080` ### 1) 规则选股(不需要大模型,可调参,可返回逐条命中/淘汰原因) **POST** `/api/stock/filter/rules` `params` 参数说明(通用): - `limit`:返回候选数量上限(默认 60;响应里最多预览 100 条) - `includeRejected`:是否返回淘汰样例 `rejectedPreview`(默认 true) - `rejectedLimit`:淘汰样例返回数量上限(默认 50) `params` 参数说明(t_trading:做T/短线活跃): - `minAmplitude`:振幅下限(单位:%) - `minTurnover`:换手率下限(单位:%) - `minMarketCap`:总市值下限(单位:亿) - `maxPe`:PE 上限(TTM;<=0 或缺失会按实现规则处理) - `maxPb`:PB 上限 - `maxPriceChange20d`:近 20 日涨幅上限(单位:%),用于“低位/未大涨”过滤 - `maxPos120d`:120 日位置上限(0-100),越小越偏“低位” - `minVolumeRatio`:量比下限(5 日均量 / 20 日均量) - `requireHotConcept`:是否要求命中至少 1 个热点概念(true/false;热点数据来自 concept_boards+stock_concepts) `params` 参数说明(value:价值投资): - `maxPe`:PE 上限 - `maxPb`:PB 上限 - `minRoe`:ROE 下限(单位:%) - `maxDebt`:资产负债率上限(单位:%) `params` 参数说明(trend:趋势投资): - `minTrendScore`:趋势评分下限(越大越强,具体由同步脚本/指标计算产出) - `minRsi`:RSI 下限(单位:数值 0-100;缺失时按实现规则处理) - `maxRsi`:RSI 上限(单位:数值 0-100) - `requireCloseAboveMa20`:是否要求收盘价 >= MA20(true/false) - `requireMa20AboveMa60`:是否要求 MA20 >= MA60(true/false) 请求体(示例:做T + 热点): ```json { "mode": "t_trading", "query": "热点 做T 低位", "params": { "minAmplitude": 6, "minTurnover": 2, "minMarketCap": 30, "maxPe": 80, "maxPb": 8, "maxPriceChange20d": 3, "maxPos120d": 35, "minVolumeRatio": 1.2, "requireHotConcept": true, "limit": 60, "includeRejected": true, "rejectedLimit": 30 } } ``` 请求体(示例:价值投资): ```json { "mode": "value", "query": "价值投资 低估 高ROE", "params": { "maxPe": 20, "maxPb": 3, "minRoe": 12, "maxDebt": 70, "limit": 60, "includeRejected": true, "rejectedLimit": 30 } } ``` 请求体(示例:趋势投资): ```json { "mode": "trend", "query": "趋势 均线 多头", "params": { "minTrendScore": 2, "minRsi": 45, "maxRsi": 80, "requireCloseAboveMa20": true, "requireMa20AboveMa60": true, "limit": 60, "includeRejected": true, "rejectedLimit": 30 } } ``` 响应(核心字段): - `appliedParams`:最终生效阈值(默认值 + 入参覆盖) - `candidates[]`:候选预览(最多 100 条),每条包含 `explain` - `rejectedPreview[]`:淘汰样例(最多 rejectedLimit 条),每条包含 `explain` `explain` 结构说明: - 非 mix:`explain` 为数组,每项包含 `rule / passed / op / threshold / actual / note` - mix:`explain` 为数组(按 strategy 分组),每组包含 `strategy / passed / rules[]` ### 2) 规则选股 + 大模型分析(先规则后 LLM,可调参) **POST** `/api/stock/filter/rules/llm` `params` 额外参数: - `analyzeTopN`:送入大模型分析的候选数量(默认 20;会从规则候选里取前 N 支) 请求体(示例): ```json { "mode": "value", "query": "价值投资 低估 高ROE", "model": "qwen-plus", "params": { "maxPe": 20, "maxPb": 3, "minRoe": 12, "maxDebt": 70, "limit": 60, "analyzeTopN": 15 } } ``` 响应(核心字段): - `analysisCandidates[]`:送入 LLM 的候选(带 explain) - `resultText`:LLM 输出文本 - `totalMs`:总耗时 ### 3) 纯大模型选股(原有接口) **GET** `/api/stock/filter/llm?query=...&model=...` **GET** `/api/stock/filter/llm/trace?query=...&model=...`(包含候选预览与耗时,便于验收/排障)