-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(hook): Add hook module to help decouple some specific logic #784
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
Conversation
🤖 Advisory Check ResultsThese are advisory checks to help improve code quality. They won't block your PR from being merged. 📋 PR InformationTitle Format: ✅ Good - Follows Conventional Commits 🔧 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. |
## 問題背景 解決 PR NoFxAiOS#703 Part 1: OI 時間序列數據缺失問題 - AI Prompt 要求檢查「持倉量 OI 近 4 小時變化率 >+3%」 - 系統只提供 Latest/Average 值,無法計算變化率 - 缺少 15m/1h 中期數據,AI 無法分析短期趨勢 ## 技術方案 ### 1️⃣ OI 時間序列支持 (market/monitor.go, market/types.go) - **數據結構**: OIData 新增 Change4h, Historical, ActualPeriod - **歷史緩存**: WSMonitor 新增 oiHistoryMap (sync.Map) - **定期採樣**: StartOIMonitoring() 每 15 分鐘採集 OI 快照 - **變化率計算**: CalculateOIChange4h() 查找 4 小時前數據點 - 容差 1 小時,冷啟動返回 0% - 公式: (Latest - OI_4h_ago) / OI_4h_ago × 100 ### 2️⃣ 多時間框架數據 (market/data.go, market/monitor.go) - **15m K線**: MidTermSeries15m (40 個,覆蓋 10 小時) - **1h K線**: MidTermSeries1h (24 個,覆蓋 1 天) - **API 支持**: - APIClient.GetOpenInterest() - 獲取實時 OI - APIClient.GetOpenInterestHistory() - 獲取歷史 OI(啟動回填) ### 3️⃣ AI 數據格式 (market/data.go) - Format() 輸出「Change(4h): X.XX%」 - 多時間框架 MACD/RSI/ATR 供 AI 分析 ## 實現細節 - **採樣策略**: 每 15 分鐘,保留最近 20 個快照(5 小時) - **並發安全**: sync.Map 存儲,goroutine 安全 - **向後兼容**: 無需配置更改,漸進式數據積累 - **保留 upstream**: 完整保留 hook 模組功能 ## 影響範圍 - ✅ 新增 market/types.go: OIData, MidTermData15m/1h - ✅ 擴展 market/monitor.go: OI 監控與多時間框架 - ✅ 增強 market/data.go: 整合 OI 變化率與多時間數據 - ✅ 擴展 market/api_client.go: GetOpenInterest(), GetOpenInterestHistory() ## 測試建議 1. 觀察日誌: `✅ 启动 OI 定期监控` 2. 15 分鐘後: `✅ OI快照采集完成` 3. 驗證 AI 輸入包含 `Change(4h): X.XX%` ## 相關 Issue/PR - 拆分自 PR NoFxAiOS#703 (Part 1/3) - 基於最新 upstream/dev (3112250) - 完整保留 hook 模組 (NoFxAiOS#784) - 依賴: 無 - 後續: Part 2 (數據陳舊性檢測), Part 3 (手續費率傳遞) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
包含以下关键更新: - NoFxAiOS#769: Funding Rate缓存机制(减少90% API调用) - NoFxAiOS#819: 修复AI决策盈亏计算未考虑杠杆 - NoFxAiOS#651: 修复历史最高收益率未传递给AI - NoFxAiOS#817: 修复Docker重启数据丢失问题 - NoFxAiOS#823: 添加单元测试和CI覆盖率 - NoFxAiOS#784: Hook模块解耦 - 多个安全和bug修复 冲突解决: - LoginPage.tsx: 合并了两边的import语句 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Pull Request | PR 提交
📝 Description | 描述
English: | 中文:
🎯 Type of Change | 变更类型
🔗 Related Issues | 相关 Issue
📋 Changes Made | 具体变更
English: | 中文:
🧪 Testing | 测试
✅ Checklist | 检查清单
Code Quality | 代码质量
Documentation | 文档
Git
devbranch | 已 rebase 到最新dev分支📚 Additional Notes | 补充说明
English: | 中文:
By submitting this PR, I confirm | 提交此 PR,我确认:
🌟 Thank you for your contribution! | 感谢你的贡献!