-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: 添加 AI 扫描决策间隔配置支持 #338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 添加 AI 扫描决策间隔配置支持 #338
Conversation
Fixed critical bug where 4h kline data was incorrectly stored with 3m kline data, causing data mismatch. Changes: - Changed `m.klineDataMap4h.Store(s, klines)` to `klines4h` - Updated log message to use `len(klines4h)` instead of `len(klines)` This bug would cause 4h kline queries to return 3m data, leading to incorrect technical indicator calculations. Fixes: NoFxAiOS#260 Related: NoFxAiOS#176
## 问题描述 编辑 Trader 配置时,保存提示"AI模型配置不存在或未启用"错误。 ## 根本原因 - 数据库存储的模型 ID 是完整格式(如 `admin_deepseek`) - API 返回时将其转换为 provider 格式(`deepseek`) - 前端 enabledModels 列表中是完整 ID - 导致前端用 `deepseek` 查找 `admin_deepseek` 时失败 ## 修复方案 移除 handleGetTraderConfig 中的模型 ID 转换逻辑, 返回完整的模型 ID,保持与前端模型列表格式一致。 Fixes NoFxAiOS#335
## 功能描述 在创建和编辑 Trader 时,支持配置 AI 扫描决策间隔(scan_interval_minutes),允许用户自定义 AI 决策的频率。 ## 修改内容 ### 后端修改 (api/server.go) 1. **CreateTraderRequest** 添加 `ScanIntervalMinutes` 字段 2. **UpdateTraderRequest** 添加 `ScanIntervalMinutes` 字段和 `SystemPromptTemplate` 字段 3. **handleCreateTrader** 处理扫描间隔默认值(默认 3 分钟) 4. **handleUpdateTrader** 支持更新扫描间隔 5. **handleGetTraderConfig** 返回中添加 `scan_interval_minutes` 字段 ### 前端修改 #### web/src/types.ts - `CreateTraderRequest` 添加 `scan_interval_minutes?` 可选字段 - `TraderConfigData` 添加 `scan_interval_minutes` 必填字段 #### web/src/components/TraderConfigModal.tsx - 本地 `TraderConfigData` 接口添加 `scan_interval_minutes` - 初始状态设置默认值为 3 分钟 - 添加 UI 输入框(范围 1-60 分钟) - Label 优化为 "AI 扫描决策间隔 (分钟)" #### web/src/components/AITradersPage.tsx - `handleSaveEditTrader` 的更新请求中添加 `scan_interval_minutes` #### web/src/components/landing/CommunitySection.tsx - 修复 TypeScript 编译错误:定义 `CardProps` 接口 - 修正 `TestimonialCard` 组件的 prop 名称(author → authorName) ## 功能特性 - ✅ 支持 1-60 分钟的自定义间隔 - ✅ 默认值为 3 分钟 - ✅ UI 提示建议范围:3-10 分钟 - ✅ 创建和编辑时均支持配置 - ✅ 后端验证和处理默认值 ## 测试步骤 1. 创建新 Trader,设置自定义扫描间隔(如 10 分钟) 2. 验证 Trader 创建成功 3. 编辑现有 Trader,修改扫描间隔 4. 验证修改保存成功 5. 确认 AI 决策按照新的间隔执行
功能实现详解1. 后端实现数据流程关键代码片段创建 Trader 时的默认值处理: scanIntervalMinutes := req.ScanIntervalMinutes
if scanIntervalMinutes <= 0 {
scanIntervalMinutes = 3 // 默认3分钟
}更新 Trader 时保持原值: scanIntervalMinutes := req.ScanIntervalMinutes
if scanIntervalMinutes <= 0 {
scanIntervalMinutes = existingTrader.ScanIntervalMinutes // 保持原值
}2. 前端实现UI 设计
状态管理const [formData, setFormData] = useState<TraderConfigData>({
// ... 其他字段
scan_interval_minutes: 3, // 默认值
});3. 额外修复本 PR 还修复了一个阻塞前端编译的 TypeScript 错误: CommunitySection.tsx:
4. 使用场景
5. 测试清单
6. 依赖说明本 PR 依赖 #337(修复模型验证):
|
🤖 Advisory Check ResultsThese are advisory checks to help improve code quality. They won't block your PR from being merged.
🔧 Backend ChecksGo Formatting: Files needing formattingGo Vet: ✅ Good Fix locally: go fmt ./... # Format code
go vet ./... # Check for issues
go test ./... # Run tests⚛️ Frontend ChecksBuild & Type Check: ✅ Success Fix locally: cd web
npm run build # Test build (includes type checking)📖 ResourcesQuestions? Feel free to ask in the comments! 🙏 These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml. |
将 SystemPromptTemplate 功能从扫描间隔 PR 中分离出来, 保持 PR 单一职责。 SystemPromptTemplate 功能将在单独的 PR 中处理。
🤖 Advisory Check ResultsThese are advisory checks to help improve code quality. They won't block your PR from being merged.
🔧 Backend ChecksGo Formatting: Files needing formattingGo Vet: ✅ Good Fix locally: go fmt ./... # Format code
go vet ./... # Check for issues
go test ./... # Run tests⚛️ Frontend ChecksBuild & Type Check: ✅ Success Fix locally: cd web
npm run build # Test build (includes type checking)📖 ResourcesQuestions? Feel free to ask in the comments! 🙏 These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml. |
✅ 更新:移除 SystemPromptTemplate已从本 PR 中移除 SystemPromptTemplate 相关修改,以保持 PR 的单一职责。 Revert Commit: 8ad85a4 原因
SystemPromptTemplate 功能已在独立的 PR #339 中处理,包含:
本 PR 当前内容现在本 PR 仅包含:
|
- Allow users to customize AI decision scan interval (1-60 minutes) - Default 3 minutes, recommended range 3-10 minutes - Support both high-frequency and low-frequency trading strategies - Improve trading flexibility and API call efficiency - Merge with existing actual balance query functionality
…fig-v2 feat: 添加 AI 扫描决策间隔配置支持
功能描述
在创建和编辑 Trader 时,支持配置 AI 扫描决策间隔(scan_interval_minutes),允许用户自定义 AI 决策的执行频率。
修改内容
后端修改 (api/server.go)
ScanIntervalMinutes字段ScanIntervalMinutes和SystemPromptTemplate字段scan_interval_minutes字段前端修改
类型定义 (web/src/types.ts)
CreateTraderRequest添加scan_interval_minutes?可选字段TraderConfigData添加scan_interval_minutes必填字段配置模态框 (web/src/components/TraderConfigModal.tsx)
TraderConfigData接口添加scan_interval_minutes交易员页面 (web/src/components/AITradersPage.tsx)
handleSaveEditTrader的更新请求中添加scan_interval_minutes社区页面 (web/src/components/landing/CommunitySection.tsx)
CardProps接口TestimonialCard组件的 prop 名称(author→authorName)功能特性
界面截图
配置项位于 Trader 创建/编辑模态框中:
测试步骤
依赖关系
本 PR 基于 #337 (修复编辑 Trader 时模型验证失败) 构建。
相关 Issue
Related to #335