Skip to content

Conversation

@kevinup8
Copy link

@kevinup8 kevinup8 commented Dec 6, 2025

…setup

The application previously tried to read 'secrets/data_key' from a read-only filesystem in Docker Compose environments, leading to a startup crash. This commit updates the compose config and/or init logic to ensure the secrets directory is mounted as a writable volume or initialized via Docker secrets.

Closes #<1164>

🎯 Type of Change | 变更类型

  • 🐛 Bug fix | 修复 Bug
  • 🔒 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 | 已添加必要注释

Git

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


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 许可证

Icyoung and others added 30 commits November 5, 2025 15:41
…ore-v2

feat: 部分平倉和動態止盈止損核心實現 / Partial Close & Dynamic TP/SL Core
…tpsl

feat(logger): 添加動態 TP/SL 日誌支持 [依賴 NoFxAiOS#415]
…tial-close-guidance

refactor(prompts): 增強部分平倉使用指導 [依賴 NoFxAiOS#415]
…lance-v2

feat(api): query actual exchange balance when creating trader
…leness

fix(market): resolve price staleness causing trade failures
…-threshold

feat(decision): configurable OI threshold + relaxed trading template
…haracters

fix(decision): handle fullwidth JSON characters from AI responses
…lete-balance-fix

fix(hyperliquid): complete balance detection with 4 critical fixes
…sync

fix(api): add balance sync endpoint with smart detection
fix(api):enforce minimum scan interval of three minutes
feat(trader): add automatic balance sync every 10 minutes
Updates dependencies and ignores files
…rofit-separation

fix(trader): separate stop-loss and take-profit order cancellation to prevent accidental deletions
…erwrite

fix(margin): correct position sizing formula to prevent insufficient margin errors
…on-mode

fix(binance): initialize dual-side position mode to prevent code=-4061 errors
fix(ui): prevent system_prompt_template overwrite when value is empty string
fix(margin): correct position sizing formula to prevent insufficient margin errors
feat: 增加持仓最高收益缓存和自动止盈机制
…sets-api-error

fix: 智能处理币安多资产模式和统一账户API错误
…n-notional

fix(trader+decision): prevent quantity=0 error with minimum notional validation
* ci(docker): 添加Docker镜像构建和推送的GitHub Actions工作流

- 支持在main和develop分支及版本标签的push事件触发
- 支持Pull Request事件及手动触发工作流
- 配置了backend和frontend两个镜像的构建策略
- 使用QEMU和Docker Buildx实现多平台构建(amd64和arm64)
- 集成GitHub Container Registry和Docker Hub登录
- 自动生成镜像元数据和多标签支持
- 支持基于GitHub Actions缓存提升构建速度
- 实现根据事件类型自动决定是否推送镜像
- 输出构建完成的镜像摘要信息

* Update Docker Hub login condition in workflow

* Fix Docker Hub login condition in workflow

* Simplify Docker Hub login step

Removed conditional check for Docker Hub username.

* Change branch names in Docker build workflow

* Update docker-build.yml
tinkle-community and others added 21 commits November 25, 2025 20:26
- Add supported exchanges table to EN, ZH-CN, JA, KO READMEs
- CEX: Binance (supported), OKX (coming soon), Bybit (coming soon)
- Perp-DEX: Hyperliquid (supported), Aster DEX (supported)
- Include referral links with fee discounts for all exchanges
- Remove What's New sections from all READMEs
- Create Binance API setup guide
- Create Hyperliquid agent wallet setup guide
- Create Aster DEX API wallet setup guide
- Mark Bybit, OKX as supported in CEX section
- Mark Lighter as supported in Perp-DEX section
- Add Bybit API setup guide
- Add OKX API setup guide
- Add Lighter agent wallet setup guide
- Update all READMEs (EN, ZH-CN, JA, KO)
…s table

- Remove individual exchange registration sections from all READMEs
- Remove redundant Binance, Hyperliquid, Aster DEX detailed setup sections
- Consolidate all exchange info into Supported Exchanges table with register links and setup guides
- Rename section to "Supported Exchanges (DEX/CEX Tutorials)" in respective languages
* fix: resolve multiple bugs preventing trader creation

Bug fixes:
1. Fix time.Time scanning error - SQLite stores datetime as TEXT, now parsing manually
2. Fix foreign key mismatch - traders table referenced exchanges(id) but exchanges uses composite primary key (id, user_id)
3. Add missing backtestManager field to Server struct
4. Add missing Shutdown method to Server struct
5. Fix NewFuturesTrader call - pass userId parameter
6. Fix UpdateExchange call - pass all required parameters
7. Add migrateTradersTable() to fix existing databases

These issues prevented creating new traders with 500 errors.

* fix(api): fix balance extraction field name mismatch

Binance API returns 'availableBalance' (camelCase) but code was looking for
'available_balance' (snake_case). Now supports both formats.

Also added 'totalWalletBalance' as fallback for total balance extraction.

* fix(frontend): add missing ConfirmDialogProvider to App

The delete trader button required ConfirmDialogProvider to be wrapped
around the App component for the confirmation dialog to work.

---------

Co-authored-by: NOFX Trader <[email protected]>
Tab buttons were only calling navigate() which changes URL but doesn't
trigger popstate events. App.tsx listens to popstate/hashchange to
update page state, so clicks appeared to do nothing.

Now all tab buttons call both onPageChange() callback and navigate()
to ensure page state updates and URL stays in sync.
…oFxAiOS#1140)

* fix: resolve multiple bugs preventing trader creation

Bug fixes:
1. Fix time.Time scanning error - SQLite stores datetime as TEXT, now parsing manually
2. Fix foreign key mismatch - traders table referenced exchanges(id) but exchanges uses composite primary key (id, user_id)
3. Add missing backtestManager field to Server struct
4. Add missing Shutdown method to Server struct
5. Fix NewFuturesTrader call - pass userId parameter
6. Fix UpdateExchange call - pass all required parameters
7. Add migrateTradersTable() to fix existing databases

These issues prevented creating new traders with 500 errors.

* fix(api): fix balance extraction field name mismatch

Binance API returns 'availableBalance' (camelCase) but code was looking for
'available_balance' (snake_case). Now supports both formats.

Also added 'totalWalletBalance' as fallback for total balance extraction.

* fix(frontend): add missing ConfirmDialogProvider to App

The delete trader button required ConfirmDialogProvider to be wrapped
around the App component for the confirmation dialog to work.

---------

Co-authored-by: NOFX Trader <[email protected]>
* feat: 添加 OKX 交易所支持(USDT Perpetual Swap)

## 新增功能
- 實現完整的 OKX API v5 REST 客戶端(純 Go 標準庫,無外部依賴)
- 支持 USDT 永續合約交易(BTC-USDT-SWAP 等)
- 實現 Trader 接口的 13 個核心方法

## 技術細節
### trader/okx_trader.go (NEW)
- HMAC-SHA256 簽名機制(完全符合 OKX API v5 規範)
- 餘額和持倉緩存(15秒,參考 Binance 實現)
- 支持 Demo Trading(testnet 模式)
- Symbol 格式轉換(BTCUSDT ↔ BTC-USDT-SWAP)
- 全倉模式(Cross Margin)支持
- 自動槓桿設置

### 實現的接口方法:
- ✅ GetBalance() - 獲取賬戶餘額
- ✅ GetPositions() - 獲取所有持倉
- ✅ OpenLong() / OpenShort() - 開倉
- ✅ CloseLong() / CloseShort() - 平倉
- ✅ SetLeverage() - 設置槓桿
- ✅ SetMarginMode() - 設置保證金模式
- ✅ GetMarketPrice() - 獲取市場價格
- ✅ FormatQuantity() - 格式化數量
- ⚠️  止盈止損功能標記為 TODO(非核心交易功能)

### config/database.go (MODIFIED)
- 添加 "okx" 到預設交易所列表
- 新增 okx_passphrase 字段(OKX 需要 3 個認證參數)
- 更新 ExchangeConfig 結構
- 添加數據庫遷移語句(ALTER TABLE)

### api/server.go (MODIFIED)
- 在 handleCreateTrader() 添加 OKX 初始化邏輯
- switch case "okx" 分支

## 代碼品質
- 代碼行數:~450 行
- 外部依賴:0 個
- 編譯狀態:✅ 通過
- 測試覆蓋:待實現(下一步)

## 待完成事項
- [ ] 撰寫單元測試(目標 >80% 覆蓋率)
- [ ] 完善數據庫查詢邏輯(GetExchanges 添加 OKX passphrase 掃描)
- [ ] 實現止盈止損功能(可選)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* refactor: 完善 OKX passphrase 數據庫和 API 支持

- config/database.go:
  • GetExchanges() 添加 okx_passphrase 查詢和解密
  • UpdateExchange() 函數簽名添加 okxPassphrase 參數
  • UpdateExchange() UPDATE 邏輯添加 okx_passphrase SET 子句
  • UpdateExchange() INSERT 添加 okx_passphrase 加密和列

- api/server.go:
  • UpdateExchangeConfigRequest 添加 OKXPassphrase 字段
  • UpdateExchange 調用添加 OKXPassphrase 參數

- api/utils.go:
  • SanitizeExchangeConfigForLog 添加 OKXPassphrase 脫敏

✅ 編譯測試通過,OKX 完整功能支持完成

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* test: 添加 OKX Trader 完整單元測試套件

📊 測試覆蓋率:92.6% (遠超 80% 目標)

✅ 完成的測試:
- 接口兼容性測試
- NewOKXTrader 構造函數測試(5個場景)
- 符號格式轉換測試(5個場景)
- HMAC-SHA256 簽名一致性測試
- GetBalance 測試(含字段驗證)
- GetPositions 測試(含標準化數據驗證)
- GetMarketPrice 測試(3個場景)
- FormatQuantity 測試(5個場景)
- SetLeverage/SetMarginMode 測試
- OpenLong/OpenShort 測試
- CloseLong/CloseShort 測試
- 緩存機制測試
- 錯誤處理測試(API錯誤、網絡錯誤、JSON錯誤)

🔧 測試套件架構:
- OKXTraderTestSuite 繼承 TraderTestSuite
- Mock HTTP 服務器模擬 OKX API v5 響應
- 完整覆蓋所有公開方法
- 包含邊界條件和錯誤場景測試

📈 方法覆蓋率明細:
- request: 90.0%
- GetBalance: 97.0%
- GetPositions: 83.3%
- formatSymbol, OpenLong, OpenShort, CloseLong, CloseShort: 100%
- placeOrder, SetMarginMode, FormatQuantity, clearCache: 100%
- Cancel* 方法系列: 100%
- SetLeverage: 81.8%
- GetMarketPrice: 85.7%

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: the-dev-z <[email protected]>
Co-authored-by: Claude <[email protected]>
…AiOS#1166)

* fix: Compatible with the HTTP2 stream transmission bug on DeepSeek's official website endpoint.

* fix: Remove reasoning from JSON
…setup

The application previously tried to read 'secrets/data_key' from a
read-only filesystem in Docker Compose environments, leading to a
startup crash. This commit updates the compose config and/or init logic
to ensure the secrets directory is mounted as a writable volume or
initialized via Docker secrets.

Closes #<1164>
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.