Commit Graph

36 Commits

Author SHA1 Message Date
tinkle
6d822173fb Docs: Enhance README files with beginner-friendly guides (4 languages)
**Configuration Improvements:**
- Add comprehensive "Get AI API Keys" section (DeepSeek + Qwen)
- Split configuration into Beginner Mode and Expert Mode
- Add step-by-step setup guides with placeholder tables
- Add configuration checklist and field explanations
- Document smart default behavior for use_default_coins (v2.0.2)

**Startup/Monitoring Guides:**
- Add detailed 2-step system startup instructions
- Include expected output and error troubleshooting tables
- Add monitoring and graceful shutdown procedures
- Provide health check commands

**AI Decision Flow Updates:**
- Enhance flow diagram with emojis and wider boxes
- Add v2.0.2 improvement markers throughout
- Document position duration tracking
- Document accurate USDT PnL calculation with leverage
- Document enhanced AI freedom for raw data analysis
- Document improved position tracking (symbol_side keys)
- Add "Key Improvements in v2.0.2" summary section

**Code Changes:**
- Simplify config.json.example to beginner-friendly single trader
- Implement smart default: use_default_coins auto-enables when omitted
- Set default to true if false without coin_pool_api_url

**Files Updated:**
- README.md (English): +559 lines
- README.zh-CN.md (Chinese): +527 lines
- README.ru.md (Russian): +634 lines
- README.uk.md (Ukrainian): +521 lines
- config.json.example: Simplified configuration
- config/config.go: Smart default logic

Total: 2068+ additions across all documentation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 17:16:27 +08:00
tinkle
a3f896d3b3 Fix: Correct PnL calculation in trade history analysis
Fixed critical issues in historical trade record and performance analysis:

1. PnL Calculation: Changed from percentage-only to actual USDT amount
   - Now correctly calculates: positionValue × priceChange% × leverage
   - Previously: 100U@5% and 1000U@5% both showed 5.0
   - Now: Properly reflects different position sizes and leverage

2. Position Tracking: Added quantity and leverage to open position records
   - Store complete trade data for accurate PnL calculation
   - Previously only stored: side, openPrice, openTime
   - Now includes: quantity, leverage for proper accounting

3. Position Key: Fixed to distinguish long/short positions
   - Changed from symbol to symbol_side (e.g., BTCUSDT_long)
   - Prevents conflicts when holding both long and short positions

4. Sharpe Ratio: Replaced custom Newton's method with math.Sqrt
   - Simplified standard deviation calculation
   - More reliable and maintainable

Impact: Win rate, profit factor, and Sharpe ratio now based on accurate USDT amounts

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 15:30:32 +08:00
tinkle
1d697c978f Refactor: Give AI full freedom to analyze raw sequence data
Remove prescriptive indicator combinations and let AI freely use all available data.

**Changes**:
- Emphasized AI has access to **raw sequence data** (MidPrices array, 4h candles)
- Listed all available sequences: price, technical (EMA/MACD/RSI), and capital flow (volume/OI)
- Removed hard-coded indicator combinations (e.g., "MACD + RSI + Volume")
- Changed from prescriptive examples to open-ended analysis freedom
- AI can now freely perform trend analysis, pattern recognition, support/resistance calculation
- Reduced minimum close-open interval from 30min to 15min for more flexibility

**Before**:
```
强信号示例:
- 趋势突破 + 多个指标确认(MACD + RSI + 成交量)
- 持仓量暴增 + 价格突破关键位
```

**After**:
```
你拥有的完整数据:
- 📊 原始序列:3分钟价格序列(MidPrices数组) + 4小时K线序列
- 📈 技术序列:EMA20序列、MACD序列、RSI7序列、RSI14序列
- 💰 资金序列:成交量序列、持仓量(OI)序列、资金费率

分析方法(完全由你自主决定):
- 自由运用序列数据,你可以做趋势分析、形态识别、支撑阻力计算
- 多维度交叉验证(价格+量+OI+指标+序列形态)
- 用你认为最有效的方法发现高确定性机会
```

**Philosophy**: Trust AI to discover effective patterns in raw data rather than constraining it to pre-defined indicator combinations.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 14:33:54 +08:00
tinkle
68c0c62d04 Feature: Add position holding duration to AI decision context
Track and display how long each position has been held to help AI make better timing decisions.

**Implementation**:
- Added UpdateTime field to PositionInfo struct (decision/engine.go:26)
- Added positionFirstSeenTime map to AutoTrader for tracking (trader/auto_trader.go:60)
- Record opening time when position is created successfully:
  - executeOpenLongWithRecord: Records timestamp for long positions (trader/auto_trader.go:540-541)
  - executeOpenShortWithRecord: Records timestamp for short positions (trader/auto_trader.go:593-594)
- Fallback tracking in buildTradingContext for program restart scenarios (trader/auto_trader.go:386-392)
- Auto-cleanup closed positions from tracking map (trader/auto_trader.go:409-414)
- Display duration in user prompt with smart formatting:
  - Under 60 min: "持仓时长25分钟"
  - Over 60 min: "持仓时长2小时15分钟"

**Example Output**:
```
1. TAOUSDT LONG | 入场价435.5300 当前价433.1900 | 盈亏-0.54% | 杠杆20x | 保证金25 | 强平价418.1528 | 持仓时长2小时15分钟
```

**Benefits**:
- AI can see how long positions have been held
- Helps enforce minimum holding period (30-60 min) from system prompt
- Simple implementation with minimal overhead
- Auto-cleanup prevents memory leaks

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 14:20:40 +08:00
tinkle-community
f07ad429a8 Merge pull request #9 from hrzisme/fix/empty-api-url-default-coins
fix: 当API URL为空时使用默认币种列表,避免循环请求失败
2025-10-29 13:06:19 +08:00
nobody
ccfa48688b feat: 添加use_default_coins开关,简化默认币种配置
- 新增use_default_coins配置项:true=使用默认8个主流币种,false=使用API币种池
- 更直观的配置方式,新手可直接设置true快速开始
- 优先级:use_default_coins > coin_pool_api_url > 缓存 > 默认列表
- 更新所有语言版本README(en/zh-CN/ru/uk)添加配置说明
- 更新config.json.example示例文件
2025-10-29 12:59:12 +08:00
tinkle
f3b7131ba8 Refactor: Enhance AI decision engine with Sharpe ratio optimization
Major improvements to the AI trading decision engine:

**Core Changes in decision/engine.go** (175 lines modified):

1. **Sharpe Ratio Optimization Focus**
   - Restructured system prompt to emphasize Sharpe ratio maximization
   - Added clear guidance: high-quality trades over frequent trading
   - Explained that 3-minute scan interval ≠ trade every cycle

2. **Trading Frequency Controls**
   - Defined optimal frequency: 2-4 trades/day (0.1-0.2 trades/hour)
   - Over-trading threshold: >2 trades/hour indicates issues
   - Minimum holding period: 30-60 minutes per position

3. **Long/Short Balance Incentives**
   - Emphasized equal profit potential for long and short positions
   - Removed long-bias with explicit short trading encouragement
   - Clear guidance: uptrend→long, downtrend→short, sideways→wait

4. **Stricter Entry Signal Standards**
   - Strong signals only: confidence ≥75, multi-indicator confirmation
   - Weak signals explicitly discouraged (single indicator, unclear trend)
   - Self-check mechanism to prevent premature re-entry (<30min)

5. **Enhanced Sharpe Ratio Feedback Loop**
   - Sharpe < -0.5: Stop trading for 6+ cycles (18min), deep reflection
   - Sharpe -0.5~0: Strict control, confidence >80 only
   - Sharpe 0~0.7: Maintain current strategy
   - Sharpe >0.7: Consider position size increase

6. **Risk-Reward Ratio Validation**
   - Added hard constraint: R:R must be ≥ 3.0:1
   - Automatic calculation and validation in `validateDecision()`
   - Rejects trades with insufficient risk-reward ratio

7. **Improved Prompt Structure**
   - More organized sections with clear headers
   - Actionable guidance instead of abstract principles
   - Better examples for JSON output format

**Impact**: These changes should significantly improve trading quality,
reduce over-trading, and increase Sharpe ratio through better risk management
and trade selection discipline.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 12:49:34 +08:00
nobody
7a0612b2db fix: 当API URL为空时使用默认币种列表,避免循环请求失败
- 添加默认主流币种列表(BTC、ETH、SOL、BNB、XRP、DOGE、ADA、HYPE)
- 在GetCoinPool()中检查coin_pool_api_url,为空时直接返回默认列表
- 在GetOITopPositions()中检查oi_top_api_url,为空时跳过OI Top数据
- 更新README文档,说明API URL可选配置和默认币种列表
- 修复:避免空URL导致的循环请求和"unsupported protocol scheme"错误
2025-10-29 12:23:29 +08:00
awake 0x
deadd2e437 sync: Sync complete codebase from nofx internal version
Full code synchronization from nofx internal repository to open-nofx.
Updated all source files, documentation, and configuration.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 12:00:09 +08:00
tinkle
321b3395e7 sync: Sync complete codebase from nofx internal version
Full synchronization of all files from nofx to open-nofx repository.
Updated documentation and source code to match internal version.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 11:42:20 +08:00
tinkle
8f5ee23fa6 sync: Sync complete codebase from nofx internal version
Synchronize all source code, documentation, and configuration files
from the internal nofx repository to the open-nofx public repository.

This includes:
- Updated README files (EN/ZH/RU/UK) with Binance registration info
- Latest source code across all modules
- Current dependencies and configurations

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 11:37:33 +08:00
tinkle
6ef15e27d8 docs: Update README to reflect new codebase architecture
- Split market/ into mcp/, decision/, and market/ modules
- Update trader log directory names (trader1/2 -> qwen/deepseek_trader)
- Reflect modular architecture changes in documentation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 11:26:49 +08:00
tinkle
a4dd64910f sync: Sync codebase from nofx internal version
- Update .gitignore to align with nofx configuration
- Sync README files across all languages (EN/ZH/RU/UK)
- Update web/package-lock.json with latest dependencies

This commit synchronizes the open-nofx repository with the latest
changes from the internal nofx version to maintain consistency.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 11:15:08 +08:00
tinkle
ef2eda5037 fix 2025-10-29 10:59:14 +08:00
tinkle
4846e4c4ef chore: Remove obsolete market and scanner files
Remove deprecated files that don't exist in nofx internal version:
- market/ai_decision_engine.go
- market/ai_signal.go
- market/market_data.go
- scanner/ai_scanner.go

Keep only market/data.go to align with internal version structure.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 10:50:09 +08:00
tinkle
7f9d88dca4 chore: Remove unnecessary files from open-nofx repository
Remove node_modules directory and update .gitignore:
- Remove all web/node_modules files from git tracking
- Add node_modules/, web/dist/, web/.vite/ to .gitignore
- Remove backup files (*.bak) and empty directories (web/web/)
- Align open-nofx repository structure with nofx internal version

This cleanup ensures the open-source version only contains necessary
source files and proper gitignore configuration.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 10:44:27 +08:00
tinkle
86105fbde8 chore: Remove nofx_test binary and add to gitignore 2025-10-29 06:15:27 +08:00
tinkle
f3a87b5a7a Refactor: Modularize codebase with separate decision and MCP packages
Architecture improvements:
- Extract AI decision engine to dedicated `decision` package
- Create `mcp` package for Model Context Protocol client
- Separate market data structures into `market/data.go`
- Update trader to use new modular structure

New packages:
- `decision/engine.go` - AI decision logic and prompt building
- `mcp/client.go` - Unified AI API client (DeepSeek/Qwen)
- `market/data.go` - Market data type definitions

Benefits:
- Better separation of concerns
- Improved code organization and maintainability
- Easier to test individual components
- More flexible AI provider integration
- Cleaner dependency management

Updated imports:
- trader/auto_trader.go now uses decision and mcp packages
- Consistent API across different AI providers

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 06:14:57 +08:00
tinkle
765771d3be Docs: Add v2.0.1 changelog for chart improvements
Update all README files (English, Chinese, Russian, Ukrainian) with:
- Version 2.0.1 changelog section
- Document ComparisonChart timestamp-based grouping fix
- Note resolution of chart freezing issue on backend restart
- Highlight improved chronological data display
- Update last modified date to 2025-10-29

Bug fixes documented:
- Switched from cycle_number to timestamp grouping
- Fixed data alignment when backend resets cycles
- Enhanced debugging capabilities
- Improved historical data visualization

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 05:37:55 +08:00
tinkle
8a9c29a918 Refactor: Improve comparison chart data synchronization
Major improvements:
- Replace useState+useEffect with useMemo for better performance
- Use timestamp-based grouping instead of cycle_number
- Fix data alignment issues when backend resets cycles
- Add detailed console logging for debugging
- Optimize data merging logic with Map structures

Chart updates:
- Display sequence number instead of cycle number on X-axis
- Improve tooltip to show actual time and sequence
- Better handling of multi-trader data synchronization
- More reliable data point matching across traders

Performance:
- Reduce unnecessary re-renders with useMemo
- More efficient data processing with Maps
- Better dependency tracking in hooks

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 05:31:15 +08:00
tinkle
390c8fd588 UI: Enhance AI learning dashboard visual design
Improvements:
- Add gradient background with glowing effects
- Redesign header section with larger icon and enhanced typography
- Improve card layouts with modern shadows and hover effects
- Optimize Sharpe ratio and profit factor display sections
- Add better visual hierarchy and spacing
- Enhance color schemes for better readability
- Remove unused decision record fetching code
- Clean up comments for better code clarity

Visual enhancements:
- Glassmorphism effects with backdrop blur
- Animated gradient backgrounds
- Enhanced metric cards with better contrast
- Improved symbol performance table design
- Modernized trade history cards with gradients

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 04:54:53 +08:00
tinkle
102d9f438d Refactor: Improve AI decision system and Sharpe ratio calculation
Major improvements:
- Use period-level Sharpe ratio (range -2 to +2) instead of annualized
- Save full user prompt in decision logs for debugging
- Format complete market data (3m + 4h candles) for AI analysis
- Prevent position stacking with duplicate position checks
- Update Sharpe ratio interpretation thresholds

Market data enhancements:
- Display full technical indicators in user prompt
- Include 3-minute and 4-hour timeframe data
- Add OI (Open Interest) change and funding rate signals

Risk control:
- Block opening duplicate positions (same symbol + direction)
- Suggest close action first before opening new position
- Prevent margin usage from exceeding limits

UI improvements:
- Update multi-language translations
- Refine AI learning dashboard display

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 04:44:17 +08:00
tinkle
c2aae0b652 Fix: Ensure Sharpe ratio is always visible to AI
Problem: When TotalTrades == 0 (no completed trades), formatPerformanceFeedback
would return early, hiding Sharpe ratio and adaptive behavior recommendations
from AI's prompt. This caused AI to say "no historical data" even though Sharpe
ratio was calculated and displayed on frontend.

Solution:
- Display Sharpe ratio BEFORE checking TotalTrades
- Don't return early when TotalTrades == 0
- Always show adaptive behavior recommendations if Sharpe ratio exists
- Sharpe ratio is calculated from account equity changes, not just closed trades

Impact: AI can now properly use Sharpe ratio for self-evolution, even in early
stages before any trades are closed.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 02:36:37 +08:00
tinkle
35c7a1d037 Feature: Add Sharpe ratio for AI self-evolution
- Implement Sharpe ratio calculation in decision logger
- Add adaptive behavior recommendations based on Sharpe ratio
- Display Sharpe ratio in AI learning dashboard with visual indicators
- Enable AI to adjust trading strategy based on risk-adjusted returns
- Color-coded performance levels (red/yellow/green) for easy monitoring

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 02:31:15 +08:00
tinkle
8b0b0c76a6 Refactor: Separate system and user prompts for AI API
- Split AI prompts into system (cacheable) and user (dynamic) messages
- Add confidence and risk_usd fields to trading decisions
- Reduce temperature to 0.5 for more stable JSON output
- Add retry mechanism for AI API calls
- Simplify candidate display (show top 10 only)
- Improve prompt structure for better AI decision quality
2025-10-28 23:51:55 +08:00
tinkle
5522e33ec6 Update: Simplify JSON parsing and add contact info
- Replace regex-based quote fixing with simple character replacement
- Add Twitter/X contact link to all README versions
- Remove complex regex pattern for better performance
- Fix Chinese quote mark handling in AI responses
2025-10-28 22:58:48 +08:00
tinkle
17868cf0e9 Improve: Optimize AI decision engine and position management
- Add focused position strategy (max 3 concurrent positions)
- Increase position sizes for better capital efficiency
- Add historical reflection prompts for AI learning
- Fix JSON parsing with missing quotes in reasoning field
- Update position limits and leverage recommendations
- Enhance risk management with concentrated positions
2025-10-28 22:40:34 +08:00
tinkle
641b772465 Feature: Add multi-language support and UI improvements
- Add language context and translation system (Chinese/English)
- Enhance UI components with i18n support
- Update AILearning, EquityChart, and CompetitionPage
- Add language toggle in header
- Improve user experience with localized text
2025-10-28 22:25:36 +08:00
tinkle
4502ec4579 Fix: Restore English README.md 2025-10-28 22:16:42 +08:00
tinkle
14ffb0593a Update: Merge nofx improvements
- Frontend trading records and UI enhancements
- Optimized AI prompts and decision engine
- Performance analysis and comparison features
- Binance-style UI improvements
2025-10-28 21:45:28 +08:00
tinkle
afe513b7aa Security: Remove hardcoded credentials
- Remove hardcoded API URL and auth token from pool/coin_pool.go
- Update config.json.example with placeholder format
- Credentials should now be configured via config.json file
2025-10-28 20:58:02 +08:00
tinkle
82d36e4b0e Add multi-language README support
- Add English README.md with language switcher
- Add Chinese README.zh-CN.md (中文版)
- Add Ukrainian README.uk.md (Українська версія)
- Add Russian README.ru.md (Русская версия)
- Each README includes language navigation links
- Covers all core features, installation, and usage
2025-10-28 16:36:46 +08:00
tinkle
a3e6dae5b7 readme 2025-10-28 15:55:49 +08:00
tinkle
7e8a494ed3 Initial commit: NOFX AI Trading System
- Multi-AI competition mode (Qwen vs DeepSeek)
- Binance Futures integration
- AI self-learning mechanism
- Professional web dashboard
- Complete risk management system
2025-10-28 15:47:34 +08:00
awake 0x
976d6d74f6 first commit 2025-10-28 15:41:59 +08:00
awake 0x
211eca1476 first commit 2025-10-28 15:41:34 +08:00