Skip to content

Conversation

@hzb1115
Copy link
Member

@hzb1115 hzb1115 commented Nov 9, 2025

Pull Request | PR 提交

📝 Description | 描述

English:中文:

  • 添加Hook逻辑,方便根据个人设置,插拔指定逻辑规则
  • 动态开关hook
  • 方便自由开发自己的hook
  • 修复关闭交易员导致的panic (这部分是忘了先提交个PR,但是不得不一起提进来,确定修复了这个Bug)

🎯 Type of Change | 变更类型

  • 🐛 Bug fix | 修复 Bug
  • ✨ New feature | 新功能
  • 💥 Breaking change | 破坏性变更
  • 📝 Documentation update | 文档更新
  • 🎨 Code style update | 代码样式更新
  • ♻️ Refactoring | 重构
  • ⚡ Performance improvement | 性能优化
  • ✅ Test update | 测试更新
  • 🔧 Build/config change | 构建/配置变更
  • 🔒 Security fix | 安全修复

🔗 Related Issues | 相关 Issue

  • Closes # | 关闭 #
  • Related to # | 相关 #

📋 Changes Made | 具体变更

English:中文:


🧪 Testing | 测试

  • Tested locally | 本地测试通过
  • Tests pass | 测试通过
  • Verified no existing functionality broke | 确认没有破坏现有功能

✅ Checklist | 检查清单

Code Quality | 代码质量

  • Code follows project style | 代码遵循项目风格
  • Self-review completed | 已完成代码自查
  • Comments added for complex logic | 已添加必要注释

Documentation | 文档

  • Updated relevant documentation | 已更新相关文档

Git

  • Commits follow conventional format | 提交遵循 Conventional Commits 格式
  • Rebased on latest dev branch | 已 rebase 到最新 dev 分支
  • No merge conflicts | 无合并冲突

📚 Additional Notes | 补充说明

English:中文:


By submitting this PR, I confirm | 提交此 PR,我确认:

  • I have read the Contributing Guidelines | 已阅读贡献指南
  • I agree to the Code of Conduct | 同意行为准则
  • My contribution is licensed under AGPL-3.0 | 贡献遵循 AGPL-3.0 许可证

🌟 Thank you for your contribution! | 感谢你的贡献!

@hzb1115 hzb1115 changed the title feat(hook): Add hook module to help add some special logic feat(hook): Add hook module to help add some specific logic Nov 9, 2025
@hzb1115 hzb1115 changed the title feat(hook): Add hook module to help add some specific logic feat(hook): Add hook module to help decouple some specific logic Nov 9, 2025
@github-actions
Copy link

github-actions bot commented Nov 9, 2025

🤖 Advisory Check Results

These are advisory checks to help improve code quality. They won't block your PR from being merged.

📋 PR Information

Title Format: ✅ Good - Follows Conventional Commits
PR Size: 🟡 Medium (509 lines: +474 -35)

🔧 Backend Checks

Go Formatting: ⚠️ Needs formatting

Files needing formatting
auth/auth.go
bootstrap/bootstrap.go
config/database.go
crypto/crypto.go
main.go
trader/auto_trader.go

Go Vet: ✅ Good
Tests: ✅ Passed

Fix locally:

go fmt ./...      # Format code
go vet ./...      # Check for issues
go test ./...     # Run tests

⚛️ Frontend Checks

Build & Type Check: ✅ Success

Fix locally:

cd web
npm run build  # Test build (includes type checking)

📖 Resources

Questions? 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.

@tinkle-community tinkle-community merged commit 49f8e95 into NoFxAiOS:dev Nov 9, 2025
140 of 159 checks passed
the-dev-z added a commit to the-dev-z/nofx that referenced this pull request Nov 9, 2025
## 問題背景
解決 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]>
0xppppp added a commit to 0xppppp/nofx that referenced this pull request Nov 10, 2025
包含以下关键更新:
- 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants