Commit Graph

85 Commits

Author SHA1 Message Date
ZhouYongyou
f34efee749 merge: Integrate PR #229 UT infrastructure with fallback logic
## Changes
-  Merge dev branch's UT infrastructure (Issue #227 fix)
-  Preserve fallback mechanism for ai_model_id and exchange_id
-  Use `allModels` instead of `enabledModels` (allow editing disabled model traders)
-  Use `allExchanges` instead of `enabledExchanges`

## Conflict Resolution
- Combined feature/partial-close-dynamic-tpsl's defensive programming
- Adopted dev branch's core fix: allModels/allExchanges validation
- Updated error messages to reflect "not exist" vs "not enabled"

Related: #229, #227
2025-11-03 23:39:24 +08:00
SkywalkerJi
683e77b92f Merge pull request #229 from xqliu/test/add-ut-infrastructure
test: Add minimal UT infrastructure and fix Issue #227
2025-11-04 00:28:34 +09:00
Liu Xiang Qian
cc448bf6e2 fix: Remove unused variables in AITradersPage.test.tsx to fix TypeScript compilation
Fixed TypeScript compilation errors by removing unused imports and variables:
- Removed unused 'screen' import from test-utils
- Removed unused 'fetcher' parameter from SWR mock
- Removed unused 'mockTrader' variable
- Removed unused 'TraderInfo' type import

All tests still pass (5/5) and frontend now compiles successfully.
2025-11-03 23:20:55 +08:00
ZYY | Bobo
4edf83b0d8 Merge branch 'NoFxAiOS:dev' into feature/partial-close-dynamic-tpsl 2025-11-03 22:50:49 +08:00
Icyoung
791cecd2ff Merge pull request #336 from 0xEmberZz/fix-mobile-display-v2
UI : Fix mobile display
2025-11-03 22:40:17 +08:00
ZhouYongyou
3d565c993e feat: Add SystemPromptTemplate edit support (PR #339)
- Allow users to modify SystemPromptTemplate when editing Trader
- Enable dynamic strategy switching (default/aggressive/conservative)
- Support A/B testing of different trading strategies
- Maintain backward compatibility with existing data
- Complete full data flow from database through UI to persistence
2025-11-03 22:37:11 +08:00
ZhouYongyou
0745fdf176 feat: Add scan_interval_minutes configuration support (PR #338)
- 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
2025-11-03 22:34:44 +08:00
Liu Xiang Qian
c1f080f59f feat: 添加前端对 SystemPromptTemplate 更新的完整支持
## 修改内容

### 后端 (api/server.go)
- handleGetTraderConfig 返回中添加 system_prompt_template 字段

### 前端类型定义 (web/src/types.ts)
- TraderConfigData 接口添加 system_prompt_template 字段

### 前端更新逻辑 (web/src/components/AITradersPage.tsx)
- handleSaveEditTrader 的更新请求中添加 system_prompt_template

## 完整数据流

```
后端数据库
  ↓ handleGetTraderConfig
前端 TraderConfigData (包含 system_prompt_template)
  ↓ TraderConfigModal (UI 编辑)
前端 UpdateRequest (包含 system_prompt_template)
  ↓ handleUpdateTrader
后端更新数据库
```

现在前后端已完全打通,用户可以在 UI 中编辑系统提示词模板了。
2025-11-03 22:19:58 +08:00
ZhouYongyou
b3e97072a9 fix: Remove merge conflict markers and add WebSocket limit warnings
- Clean up remaining conflict markers in SetMarginMode
- Add visual warnings for WebSocket stream limits in UI
- Prevent user from exceeding 250 symbols (1024 streams / 4 timeframes)
2025-11-03 21:57:55 +08:00
Liu Xiang Qian
ddf6c44d65 feat: 添加 AI 扫描决策间隔配置支持
## 功能描述

在创建和编辑 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 决策按照新的间隔执行
2025-11-03 21:55:26 +08:00
Ember
7a4e9f145c feat(web): comprehensive mobile responsive optimization for AI Traders and Competition pages
Optimized mobile display for AITradersPage:
- Header: Reduced padding (px-3 on mobile), smaller icons and text
- Action buttons: Smaller on mobile (px-3, text-xs) with horizontal scroll support
- Configuration cards: Responsive padding (p-3 on mobile), smaller gaps
- Model/Exchange items: Smaller icons (w-7 on mobile), truncate text overflow
- Trader list: Stack vertically on mobile, smaller buttons with wrapping support
- Empty states: Smaller icons and text on mobile

Maintained all i18n translations and preserved Binance design style.

Addresses #311

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 21:46:07 +08:00
Ember
4f4e9f2ca9 fix: improve mobile responsive layout for header and comparison chart
This is a partial fix for issue #311 mobile display problems.

Changes in this commit:
- Add responsive header layout with separate mobile/desktop views in App.tsx
- Fix language selector visibility on mobile (no longer hidden by menu)
- Add responsive breakpoints to ComparisonChart stats grid (2 cols on mobile, 4 on desktop)
- Adjust padding and text sizes for mobile screens
- Preserve all i18n (internationalization) functionality from upstream

Note: Additional components (CompetitionPage, AITradersPage) will need similar mobile
responsive improvements in follow-up commits.

Related to #311

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 21:38:52 +08:00
ZhouYongyou
1e1f4cc36b fix: define CardProps interface and fix prop name mismatch
- Add missing CardProps interface definition
- Fix TestimonialCard to use 'authorName' instead of 'author'
- Resolves TypeScript compilation error: 'Cannot find name CardProps'
- Fixes frontend build failure in CI

Fixes the type error:
src/components/landing/CommunitySection.tsx(32,16): error TS2304: Cannot find name 'CardProps'.
2025-11-03 19:45:59 +08:00
ZhouYongyou
bead75ef8f merge: Sync with NoFxAiOS/dev - adopt WebSocket architecture
Merged 54 commits from upstream (NoFxAiOS/dev @ 8832557)

## Key Changes

### 🚀 WebSocket Real-time Data Architecture
-  NEW: WebSocket client with auto-reconnect (websocket_client.go)
-  NEW: Market data monitor with combined streams (monitor.go)
-  NEW: K-line caching system (combined_streams.go)
-  UPGRADE: market/data.go now uses WebSocket instead of REST API
- 🎯 Benefits: Lower latency, reduced API limits, auto-reconnect

### 📝 Documentation & CI/CD
-  NEW: Comprehensive troubleshooting guides (EN + ZH-CN)
-  UPGRADE: Enhanced PR workflow with checks
-  NEW: PR title guide & template improvements
-  UPDATE: FAQ expanded with common issues

### 🔧 Conflict Resolution
- market/data.go: Adopted upstream WebSocket version
- prompts/adaptive.txt: Kept our v5.5.6.1 (conf≥85, strict strategy)

### 📊 Stats
- Files changed: 40+
- New files: 12 (WebSocket modules, docs, CI)
- Commits merged: 54

Related: feature/partial-close-dynamic-tpsl
Upstream: NoFxAiOS/nofx @ 8832557
2025-11-03 18:40:54 +08:00
Liu Xiang Qian
c5516fc5fe fix: Update model validation in handleSaveModelConfig to support both configured and supported models
- Change validation to check allModels first, then supportedModels
- This allows saving new model configurations without "model does not exist" error
- Fixes issue where users couldn't save AI model config after selecting from dropdown

Fixes #245

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 00:11:44 +08:00
Ember
f3cc95d267 Merge branch 'dev' into quote-tweet-link 2025-11-02 23:56:46 +08:00
Ember
a7a0bdff41 chore(landing): add lightweight AnimatedSection wrapper for main-based branch 2025-11-02 23:52:15 +08:00
Ember
97015d31a2 chore(landing): add lightweight AnimatedSection wrapper for main-based branch 2025-11-02 23:49:23 +08:00
Ember
0b86916d8c feat(landing): integrate real community tweets in CommunitySection with author avatars and links 2025-11-02 23:48:25 +08:00
Liu Xiang Qian
4577adabbd fix: Update model validation in handleSaveModelConfig to support both configured and supported models
- Change validation to check allModels first, then supportedModels
- This allows saving new model configurations without "model does not exist" error
- Fixes issue where users couldn't save AI model config after selecting from dropdown

Fixes #245

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 18:08:25 +08:00
Liu Xiang Qian
9ab7a36fbb test: Add minimal UT infrastructure and fix Issue #227
This commit sets up a minimal, KISS-principle testing infrastructure
for both backend and frontend, and includes the fix for Issue #227.

Backend Changes:
- Add Makefile with test commands (test, test-backend, test-frontend, test-coverage)
- Add example test: config/database_test.go
- Fix Go 1.25 printf format string warnings in trader/auto_trader.go
  (Changed log.Printf to log.Print for non-format strings)
- All backend tests pass ✓

Frontend Changes:
- Add Vitest configuration: web/vitest.config.ts (minimal setup)
- Add test utilities: web/src/test/test-utils.tsx
- Add example test: web/src/App.test.tsx
- Add dependencies: vitest, jsdom, @testing-library/react
- All frontend tests pass ✓

Issue #227 Fix:
- Fix AITradersPage to allow editing traders with disabled models/exchanges
- Change validation to use allModels/allExchanges instead of enabledModels/enabledExchanges
- Add comprehensive tests in web/src/components/AITradersPage.test.tsx
- Fixes: https://github.com/tinkle-community/nofx/issues/227

CI/CD:
- Add GitHub Actions workflow: .github/workflows/test.yml
- Non-blocking tests (continue-on-error: true)
- Runs on push/PR to main and dev branches

Test Results:
- Backend: 1 test passing
- Frontend: 5 tests passing (including 4 for Issue #227)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 10:58:31 +08:00
ZhouYongyou
2d4b14e086 fix: 修復初始余額顯示錯誤(使用當前淨值而非配置值)
問題:
- 圖表顯示「初始余額 693.15 USDT」(實際應該是 600)
- 原因:使用 validHistory[0].total_equity(當前淨值)
- 導致初始余額隨著盈虧變化,數學邏輯錯誤

修復:
- 優先從 account.initial_balance 讀取真實配置值
- 備選方案:從歷史數據反推(淨值 - 盈虧)
- 默認值使用 1000(與創建交易員時的默認配置一致)

測試:
- 初始余額:600 USDT(固定)
- 當前淨值:693.15 USDT
- 盈虧:+93.15 USDT (+15.52%) ✓
2025-11-02 07:55:43 +08:00
ZhouYongyou
093d521394 Merge branch 'dev' of https://github.com/tinkle-community/nofx into dev 2025-11-02 04:54:09 +08:00
ZhouYongyou
04419b47e6 fix: 修复编辑交易员时「AI模型配置不存在或未启用」错误
问题:
- 编辑交易员并修改系统提示词模板时,保存失败
- 错误提示:AI模型配置不存在或未启用

根本原因:
1. 后端 API 返回的 ai_model 被截断(admin_deepseek → deepseek)
2. 前端验证时找不到对应的模型 ID(enabledModels 存的是完整 ID)
3. API 缺少 system_prompt_template 字段

修复内容:
- api/server.go: 移除 AI model ID 截断逻辑,返回完整 ID
- api/server.go: 在 handleGetTraderConfig 中添加 system_prompt_template 字段
- web/src/types.ts: TraderConfigData 接口添加 system_prompt_template 字段
- web/src/components/AITradersPage.tsx: 添加 fallback 机制和详细日志

测试:
- 编辑交易员 → 修改系统提示词模板 → 保存成功
- Console 输出验证日志,不再报错
2025-11-02 04:51:30 +08:00
Ember
2fa884c72d style(web): 统一 FooterSection 组件的代码风格,优化链接格式和排版 2025-11-02 01:59:42 +08:00
Ember
7a4d1db046 fix(web): Footer ‘资源/文档’ 链接改为 GitHub 主 README(https://github.com/tinkle-community/nofx/blob/main/README.md) 2025-11-02 01:57:50 +08:00
Ember
2cc4f77254 chore(web): Footer 支持方去除图标并新增 Hyperliquid 链接 2025-11-02 01:56:21 +08:00
Ember
df83eba8e7 feat(web): Footer 按旧版文案重排 —— 顶部品牌 + 三列(链接/资源/支持方:Aster DEX、Binance、Amber.ac) 2025-11-02 01:53:48 +08:00
Ember
1413eb868e feat(web): Footer 增加“支持的交易所”列(Binance、Aster DEX 图标与链接),对齐早期版本记忆 2025-11-02 01:50:49 +08:00
Ember
aa5e66f7b8 feat(web): LandingPage 页脚升级为多链接版本(链接/资源/产品/支持 四列) 2025-11-02 01:46:40 +08:00
Ember
388832876a feat(web): 恢复 LandingPage 页脚(FooterSection),复用 App 的 Footer 文案与样式 2025-11-02 01:42:30 +08:00
Ember
16a62cedce style(web): 移除功能卡片右下角黄色渐变点缀(去除黄光) 2025-11-02 01:39:31 +08:00
Ember
ba48298c03 ui(web): 对齐 #138 风格——用 Lucide/矢量图标替换表情与占位,增强空态/警告显示(ComparisonChart/Competition/AITraders/ConfigModal) 2025-11-02 01:02:15 +08:00
Ember
abcd215e19 feat(web): 重做 #138/#133 的前端改动(LOGO 替换 + Loading Logo + 校验优化保留),尽量不覆盖他人代码 2025-11-02 00:58:25 +08:00
Ember
0a4fd06882 refactor(web): 拆分 LandingPage 为可复用组件(HeaderBar/Hero/AnimatedSection 等),新增 pages 结构并完成集成;构建通过 2025-11-02 00:36:37 +08:00
Ember
a3c6568137 refactor(web): 引入 pages 目录并迁移 LandingPage;修正 App 引用与相对路径,保持构建通过 2025-11-02 00:28:38 +08:00
Ember
b5d4ff0fc2 fix(web): 优化落地页内容—移除多余空行,简化图片组件,更新支持方列表 2025-11-02 00:17:19 +08:00
Ember
28b7edbc5c style(web): 对齐币安风格—移除渐变/发光,固化深色/面板色,新增 header 样式,按钮与卡片统一 2025-11-02 00:08:46 +08:00
Ember
e6fc60c464 fix(web): 去除残留 undefined(文本最终清洗)并将启动命令改为顶层 README 流程(start.sh + compose) 2025-11-02 00:01:38 +08:00
Ember
493fd559dc fix(web): Typewriter 更稳健—charAt防越界、sanitizedLines防空值、pre-wrap防换行丢失 2025-11-01 23:58:48 +08:00
Ember
f5dfb1bb61 feat(web): Typewriter 优化(修复 undefined、矩阵绿样式、降低速度)并更新启动指令为 README 前端开发流程 2025-11-01 23:53:17 +08:00
Ember
8c57b6b1e7 feat(web): 落地页“启动输出”加入打字机效果(Typewriter) 2025-11-01 23:45:27 +08:00
Ember
9d4e86cbf5 feat(web): 新增 Landing 页面与 UI 优化\n\n- 新增 LandingPage、CryptoFeatureCard 等组件\n- 登录/注册页面与样式优化\n- 静态资源 images/main.png 2025-11-01 23:36:28 +08:00
icy
2cc91d1701 Remote auth for prompt templates 2025-11-01 20:25:55 +08:00
icy
2538d2f928 Merge branch 'dev' of https://github.com/tinkle-community/nofx 2025-11-01 20:09:17 +08:00
SkywalkerJi
4250c11ddf Supports custom system prompts and custom models. 2025-11-01 19:45:54 +08:00
icy
996b152eba Resolve merge conflicts in AITradersPage.tsx
- Fixed import statement conflict (using 'type Language')
- Merged exchange configuration logic preserving support for multiple exchange types
- Kept comprehensive form handling for Binance, Hyperliquid, Aster, and OKX exchanges
- Updated security warning messages to use proper translation keys

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 19:01:44 +08:00
icy
f413f87f39 Fixed health check; Fixed dex config; Add rank trader info view; 2025-11-01 18:58:32 +08:00
SkywalkerJi
5be7106eb2 Rename the model. 2025-11-01 17:10:36 +08:00
SkywalkerJi
48d1320209 * Fixed the custom model URL.
*   Added functionality for custom model names.
2025-11-01 16:09:15 +08:00