# klinedecoder **Repository Path**: aierwiki/klinedecoder ## Basic Information - **Project Name**: klinedecoder - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-01-17 - **Last Updated**: 2026-01-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 股票技术分析 GRPO训练 - 数据准备 基于GRPO算法训练股票技术分析LLM的数据准备工具。 ## 目录结构 ``` klinedecoder/ ├── docs/ # 文档 │ └── grpo_stock_llm_training_plan.md # 训练方案设计文档 ├── src/ │ └── data_preparation/ # 数据准备模块 │ ├── tushare_fetcher.py # Tushare数据获取 │ ├── talib_calculator.py # 技术指标计算 │ ├── prompt_formatter.py # Prompt格式化 │ ├── sample_generator.py # 样本生成 │ ├── prepare_data.py # 主流程脚本 │ └── config.yaml # 配置文件 ├── output/ │ ├── raw/ # 原始数据缓存 │ └── samples/ # 生成的训练样本 └── requirements.txt # 依赖包 ``` ## 快速开始 ### 1. 安装依赖 ```bash pip install -r requirements.txt ``` **注意**: TA-Lib需要额外安装C库: ```bash # macOS brew install ta-lib # Ubuntu/Debian sudo apt-get install libta-lib-dev # 然后安装python包 pip install TA-Lib ``` ### 2. 环境准备 Baostock是免费开源的,无需token或API key。 如果需要使用其他数据源(如tushare),可配置相应token: ```bash export TUSHARE_TOKEN="your_token_here" # 可选 ``` ### 3. 运行数据准备 ```bash cd src/data_preparation # 测试模式(处理10只股票) python prepare_data.py --test # 完整流程 python prepare_data.py --config config.yaml --stage all # 分阶段执行 python prepare_data.py --stage fetch # 仅获取数据 python prepare_data.py --stage generate # 仅生成样本 ``` ## 配置说明 编辑 `src/data_preparation/config.yaml`: ```yaml data: market: 'hs300' # 股票池 start_date: '20200101' # 开始日期 end_date: '20241231' # 结束日期 sample: observation_window: 20 # 观察窗口(天) prediction_window: 10 # 预测窗口(天) sample_interval: 5 # 采样间隔(天) ``` ## 输出格式 生成的训练样本为JSONL格式,每行一个JSON对象: ```json { "prompt": "请分析以下股票的技术面...", "ground_truth": { "max_rise_pct": 5.9, "max_fall_pct": 4.3 }, "metadata": { "ts_code": "000001.SZ", "sample_date": "20240115", "current_price": 12.75 } } ``` ## 模块说明 - **tushare_fetcher**: 从Tushare获取日线/周线/月线数据 - **talib_calculator**: 计算MA、MACD、RSI、KDJ等技术指标 - **prompt_formatter**: 将数据格式化为markdown表格 - **sample_generator**: 滑动窗口采样,计算ground truth - **prepare_data**: 主流程,整合所有模块 ## 开发计划 - [x] 数据获取模块 - [x] 技术指标计算 - [x] Prompt格式化 - [x] 样本生成 - [ ] SFT数据准备(DeepSeek蒸馏) - [ ] GRPO训练代码 ## 参考文档 详细设计方案见: [docs/grpo_stock_llm_training_plan.md](docs/grpo_stock_llm_training_plan.md)