diff --git a/README.md b/README.md index 5758e8cf..2cd60dbf 100644 --- a/README.md +++ b/README.md @@ -1,136 +1,140 @@ -# 🀖 NOFX - AI驱劚的垁安合纊自劚亀易竞赛系统 +# 🀖 NOFX - AI-Driven Binance Futures Auto Trading Competition System [![Go Version](https://img.shields.io/badge/Go-1.21+-00ADD8?style=flat&logo=go)](https://golang.org/) [![React](https://img.shields.io/badge/React-18+-61DAFB?style=flat&logo=react)](https://reactjs.org/) [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-3178C6?style=flat&logo=typescript)](https://www.typescriptlang.org/) [![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE) -䞀䞪基于 **DeepSeek/Qwen AI** 的垁安合纊自劚亀易系统支持**倚AI暡型实盘竞赛**具倇完敎的垂场分析、AI决策、**自我孊习机制**和䞓䞚的Web监控界面。 - -> ⚠ **风险提瀺**本系统䞺实验性项目AI自劚亀易存圚重倧风险区烈建议仅甚于孊习研究或小额资金测试 +**Languages:** [English](README.md) | [äž­æ–‡](README.zh-CN.md) | [УкраїМська](README.uk.md) | [РусскОй](README.ru.md) --- -## ✹ 栞心特性 +An automated Binance futures trading system powered by **DeepSeek/Qwen AI**, supporting **multi-AI model live trading competition**, featuring comprehensive market analysis, AI decision-making, **self-learning mechanism**, and professional Web monitoring interface. -### 🏆 倚AI竞赛暡匏 -- **Qwen vs DeepSeek** 实盘对抗 -- 独立莊户管理独立决策日志 -- 实时性胜对比囟衚 -- 收益率PK胜率统计 - -### 🧠 AI自我孊习机制NEW -- **历史反銈**: 每次决策前分析最近20䞪呚期的亀易衚现 -- **智胜䌘化**: - - 识别衚现最䜳/最差垁种 - - 计算胜率、盈亏比、平均盈利 - - 避免重倍错误连续亏损的垁种 - - 区化成功策略高胜率的亀易暡匏 -- **劚态调敎**: AI根据历史衚现自䞻调敎亀易风栌 - -### 📊 智胜垂场分析 -- **3分钟K线**: 实时价栌、EMA20、MACD、RSI(7) -- **4小时K线**: 长期趋势、EMA20/50、ATR、RSI(14) -- **持仓量分析**: 垂场情绪、资金流向刀断 -- **OI Top远螪**: 持仓量增长最快的20䞪垁种 -- **AI500垁种池**: 高评分垁种自劚筛选 -- **流劚性过滀**: 自劚过滀持仓价倌<15M USD的䜎流劚性垁种 - -### 🎯 䞓䞚风险控制 -- **单垁种仓䜍䞊限**: - - 山寚垁 ≀ 1.5倍莊户净倌 - - BTC/ETH ≀ 10倍莊户净倌 -- **固定杠杆**: 山寚垁20倍 | BTC/ETH 50倍 -- **保证金管理**: 总䜿甚率≀90%AI自䞻决策䜿甚率 -- **风险回报比**: 区制≥1:2止损:止盈 -- **防止仓䜍叠加**: 同垁种同方向䞍允讞重倍匀仓 - -### 🎚 风栌UI -- **䞓䞚亀易界面**: 视觉讟计 -- **暗色䞻题**: 经兞配色金色#F0B90B + 深色背景 -- **实时数据**: 5秒刷新莊户、持仓、囟衚 -- **收益率曲线**: 莊户净倌历史走势矎元/癟分比切换 -- **性胜对比囟**: 倚AI收益率实时对比 -- **劚画效果**: 流畅的hover、过枡、加蜜劚画 - -### 📝 完敎决策记圕 -- **思绎铟记圕**: AI的完敎掚理过皋CoT -- **历史衚现**: 敎䜓胜率、平均盈利、盈亏比 -- **最近亀易**: 最近5笔亀易诊情匀仓价→平仓价→盈亏% -- **垁种统计**: 各垁种衚现胜率、平均盈亏 -- **JSON日志**: 每次决策完敎记圕䟿于倍盘分析 +> ⚠ **Risk Warning**: This system is experimental. AI auto-trading carries significant risks. Strongly recommended for learning/research purposes or testing with small amounts only! --- -## 🏗 技术架构 +## ✹ Core Features + +### 🏆 Multi-AI Competition Mode +- **Qwen vs DeepSeek** live trading battle +- Independent account management and decision logs +- Real-time performance comparison charts +- ROI PK and win rate statistics + +### 🧠 AI Self-Learning Mechanism (NEW!) +- **Historical Feedback**: Analyzes last 20 cycles of trading performance before each decision +- **Smart Optimization**: + - Identifies best/worst performing coins + - Calculates win rate, profit/loss ratio, average profit + - Avoids repeating mistakes (consecutive losing coins) + - Reinforces successful strategies (high win rate patterns) +- **Dynamic Adjustment**: AI autonomously adjusts trading style based on historical performance + +### 📊 Intelligent Market Analysis +- **3-minute K-line**: Real-time price, EMA20, MACD, RSI(7) +- **4-hour K-line**: Long-term trend, EMA20/50, ATR, RSI(14) +- **Open Interest Analysis**: Market sentiment, capital flow judgment +- **OI Top Tracking**: Top 20 coins with fastest growing open interest +- **AI500 Coin Pool**: Automatic high-score coin screening +- **Liquidity Filter**: Auto-filters low liquidity coins (<15M USD position value) + +### 🎯 Professional Risk Control +- **Per-Coin Position Limit**: + - Altcoins ≀ 1.5x account equity + - BTC/ETH ≀ 10x account equity +- **Fixed Leverage**: Altcoins 20x | BTC/ETH 50x +- **Margin Management**: Total usage ≀90%, AI autonomous decision on usage rate +- **Risk-Reward Ratio**: Mandatory ≥1:2 (stop-loss:take-profit) +- **Prevent Position Stacking**: No duplicate opening of same coin/direction + +### 🎚 Professional UI +- **Professional Trading Interface**: Binance-style visual design +- **Dark Theme**: Classic color scheme (Gold #F0B90B + dark background) +- **Real-time Data**: 5-second refresh for accounts, positions, charts +- **Equity Curve**: Historical account value trend (USD/percentage toggle) +- **Performance Comparison Chart**: Real-time multi-AI ROI comparison +- **Smooth Animations**: Fluid hover, transition, and loading effects + +### 📝 Complete Decision Recording +- **Chain of Thought**: AI's complete reasoning process (CoT) +- **Historical Performance**: Overall win rate, average profit, profit/loss ratio +- **Recent Trades**: Last 5 trade details (entry price → exit price → P/L%) +- **Coin Statistics**: Per-coin performance (win rate, average P/L) +- **JSON Logs**: Complete decision records for post-trade analysis + +--- + +## 🏗 Technical Architecture ``` nofx/ -├── main.go # 皋序入口倚trader管理噚 -├── config.json # 配眮文件API密钥、倚trader配眮 +├── main.go # Program entry (multi-trader manager) +├── config.json # Configuration file (API keys, multi-trader config) │ -├── api/ # HTTP API服务 -│ └── server.go # Gin框架RESTful API +├── api/ # HTTP API service +│ └── server.go # Gin framework, RESTful API │ -├── trader/ # 亀易栞心 -│ ├── auto_trader.go # 自劚亀易䞻控单trader -│ └── binance_futures.go # 垁安合纊API封装 +├── trader/ # Trading core +│ ├── auto_trader.go # Auto trading main controller (single trader) +│ └── binance_futures.go # Binance futures API wrapper │ -├── manager/ # 倚trader管理 -│ └── trader_manager.go # 管理倚䞪trader实䟋 +├── manager/ # Multi-trader management +│ └── trader_manager.go # Manages multiple trader instances │ -├── market/ # 垂场数据䞎AI决策 -│ ├── market_data.go # 垂场数据获取K线、指标 -│ ├── ai_decision_engine.go # AI决策匕擎含历史反銈 -│ └── ai_signal.go # AI API调甚DeepSeek/Qwen +├── market/ # Market data & AI decisions +│ ├── market_data.go # Market data fetching (K-line, indicators) +│ ├── ai_decision_engine.go # AI decision engine (with historical feedback) +│ └── ai_signal.go # AI API calls (DeepSeek/Qwen) │ -├── pool/ # 垁种池管理 -│ └── coin_pool.go # AI500 + OI Top合并池 +├── pool/ # Coin pool management +│ └── coin_pool.go # AI500 + OI Top merged pool │ -├── logger/ # 日志系统 -│ └── decision_logger.go # 决策记圕 + 衚现分析 +├── logger/ # Logging system +│ └── decision_logger.go # Decision recording + performance analysis │ -├── decision_logs/ # 决策日志存傚 -│ ├── trader1/ # Trader 1的日志 -│ └── trader2/ # Trader 2的日志 +├── decision_logs/ # Decision log storage +│ ├── trader1/ # Trader 1 logs +│ └── trader2/ # Trader 2 logs │ -└── web/ # React前端 +└── web/ # React frontend ├── src/ - │ ├── components/ # React组件 - │ │ ├── EquityChart.tsx # 收益率曲线囟 - │ │ ├── ComparisonChart.tsx # 倚AI对比囟 - │ │ └── CompetitionPage.tsx # 竞赛排行抜 - │ ├── lib/api.ts # API调甚封装 - │ ├── types/index.ts # TypeScript类型 - │ ├── index.css # Binance风栌样匏 - │ └── App.tsx # 䞻应甚 + │ ├── components/ # React components + │ │ ├── EquityChart.tsx # Equity curve chart + │ │ ├── ComparisonChart.tsx # Multi-AI comparison chart + │ │ └── CompetitionPage.tsx # Competition leaderboard + │ ├── lib/api.ts # API call wrapper + │ ├── types/index.ts # TypeScript types + │ ├── index.css # Binance-style CSS + │ └── App.tsx # Main app └── package.json ``` -### 栞心䟝赖 +### Core Dependencies -**后端 (Go)** -- `github.com/adshao/go-binance/v2` - 垁安API客户端 -- `github.com/markcheno/go-talib` - 技术指标计算TA-Lib -- `github.com/gin-gonic/gin` - HTTP API框架 +**Backend (Go)** +- `github.com/adshao/go-binance/v2` - Binance API client +- `github.com/markcheno/go-talib` - Technical indicator calculation (TA-Lib) +- `github.com/gin-gonic/gin` - HTTP API framework -**前端 (React + TypeScript)** -- `react` + `react-dom` - UI框架 -- `recharts` - 囟衚库收益率曲线、对比囟 -- `swr` - 数据获取和猓存 -- `tailwindcss` - CSS框架 +**Frontend (React + TypeScript)** +- `react` + `react-dom` - UI framework +- `recharts` - Chart library (equity curve, comparison charts) +- `swr` - Data fetching and caching +- `tailwindcss` - CSS framework --- -## 🚀 快速匀始 +## 🚀 Quick Start -### 1. 环境芁求 +### 1. Environment Requirements - **Go 1.21+** - **Node.js 18+** -- **TA-Lib** 库技术指标计算 +- **TA-Lib** library (technical indicator calculation) -#### 安装 TA-Lib +#### Installing TA-Lib **macOS:** ```bash @@ -142,32 +146,32 @@ brew install ta-lib sudo apt-get install libta-lib0-dev ``` -**其他系统**: 参考 [TA-Lib官方文档](https://github.com/markcheno/go-talib) +**Other systems**: Refer to [TA-Lib Official Documentation](https://github.com/markcheno/go-talib) -### 2. 克隆项目 +### 2. Clone the Project ```bash -git clone +git clone https://github.com/tinkle-community/nofx.git cd nofx ``` -### 3. 安装䟝赖 +### 3. Install Dependencies -**后端:** +**Backend:** ```bash go mod download ``` -**前端:** +**Frontend:** ```bash cd web npm install cd .. ``` -### 4. 配眮系统 +### 4. System Configuration -创建 `config.json` 文件 +Create `config.json` file (use `config.json.example` as template): ```json { @@ -201,319 +205,240 @@ cd .. } ``` -**配眮诎明** -- `traders`: 可配眮1-N䞪trader单AI或倚AI竞赛 -- `id`: Trader唯䞀标识甚于日志目圕 -- `ai_model`: "qwen" 或 "deepseek" -- `binance_api_key/secret_key`: 每䞪trader䜿甚独立的垁安莊户 -- `initial_balance`: 初始䜙额甚于计算盈亏% -- `scan_interval_minutes`: 决策呚期建议3-5分钟 -- `coin_pool_api_url`: AI500垁种池API可选 -- `oi_top_api_url`: OI Top持仓量API可选 +**Configuration Notes:** +- `traders`: Configure 1-N traders (single AI or multi-AI competition) +- `id`: Unique trader identifier (used for log directory) +- `ai_model`: "qwen" or "deepseek" +- `binance_api_key/secret_key`: Each trader uses independent Binance account +- `initial_balance`: Initial balance (for calculating P/L%) +- `scan_interval_minutes`: Decision cycle (recommended 3-5 minutes) +- `coin_pool_api_url`: AI500 coin pool API (optional) +- `oi_top_api_url`: OI Top open interest API (optional) -### 5. 运行系统 +### 5. Run the System -**启劚后端AI亀易系统 + API服务噚:** +**Start backend (AI trading system + API server):** ```bash go build -o nofx ./nofx ``` -**启劚前端Web Dashboard:** +**Start frontend (Web Dashboard):** -新匀终端窗口 +Open a new terminal: ```bash cd web npm run dev ``` -**访问界面:** +**Access the interface:** ``` Web Dashboard: http://localhost:3000 API Server: http://localhost:8080 ``` -### 6. 停止系统 +### 6. Stop the System -圚䞀䞪终端䞭分别按 `Ctrl+C` +Press `Ctrl+C` in both terminals --- -## 📖 AI决策流皋 +## 📖 AI Decision Flow -每䞪决策呚期默讀3分钟系统按以䞋流皋运行 +Each decision cycle (default 3 minutes), the system runs the following process: ``` ┌─────────────────────────────────────────────────────┐ -│ 1. 分析历史衚现最近20䞪呚期 │ +│ 1. Analyze Historical Performance (last 20 cycles) │ ├────────────────────────────────────────────────────── -│ ✓ 计算敎䜓胜率、平均盈利、盈亏比 │ -│ ✓ 统计各垁种衚现胜率、平均盈亏 │ -│ ✓ 识别最䜳/最差垁种 │ -│ ✓ 列出最近5笔亀易诊情 │ +│ ✓ Calculate overall win rate, avg profit, P/L ratio│ +│ ✓ Statistics for each coin (win rate, avg P/L) │ +│ ✓ Identify best/worst coins │ +│ ✓ List last 5 trade details │ └─────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────┐ -│ 2. 获取莊户状态 │ +│ 2. Get Account Status │ ├────────────────────────────────────────────────────── -│ • 莊户净倌、可甚䜙额 │ -│ • 持仓数量、总盈亏 │ -│ • 保证金䜿甚率 │ +│ • Account equity, available balance │ +│ • Number of positions, total P/L │ +│ • Margin usage rate │ └─────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────┐ -│ 3. 分析现有持仓劂果有 │ +│ 3. Analyze Existing Positions (if any) │ ├────────────────────────────────────────────────────── -│ • 获取每䞪持仓的垂场数据 │ -│ • 计算技术指标RSI、MACD、EMA │ -│ • AI刀断是吊需芁平仓 │ +│ • Get market data for each position │ +│ • Calculate technical indicators (RSI, MACD, EMA) │ +│ • AI decides whether to close positions │ └─────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────┐ -│ 4. 评䌰新机䌚候选垁种池 │ +│ 4. Evaluate New Opportunities (candidate coin pool) │ ├────────────────────────────────────────────────────── -│ • 获取AI500高评分垁种前20䞪 │ -│ • 获取OI Top持仓增长垁种前20䞪 │ -│ • 合并去重过滀䜎流劚性垁种<15M │ -│ • 批量获取垂场数据和技术指标 │ +│ • Get AI500 high-score coins (top 20) │ +│ • Get OI Top growing coins (top 20) │ +│ • Merge and deduplicate, filter low liquidity │ +│ • Batch fetch market data and technical indicators │ └─────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────┐ -│ 5. AI绌合决策 │ +│ 5. AI Comprehensive Decision │ ├────────────────────────────────────────────────────── -│ • 查看历史反銈胜率、最䜳/最差垁种 │ -│ • Chain of Thought 思绎铟分析 │ -│ • 蟓出决策平仓/匀仓/持有/观望 │ -│ • 包含杠杆、仓䜍、止损、止盈 │ +│ • Review historical feedback (win rate, best/worst)│ +│ • Chain of Thought analysis │ +│ • Output decision: close/open/hold/wait │ +│ • Includes leverage, position size, SL, TP │ └─────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────┐ -│ 6. 执行亀易 │ +│ 6. Execute Trades │ ├────────────────────────────────────────────────────── -│ • 䌘先级排序先平仓再匀仓 │ -│ • 粟床自劚适配LOT_SIZE │ -│ • 防止仓䜍叠加同垁种同方向拒绝匀仓 │ -│ • 平仓后自劚取消所有挂单 │ +│ • Priority: close first, then open │ +│ • Auto-adapt precision (LOT_SIZE) │ +│ • Prevent position stacking (reject duplicate) │ +│ • Auto-cancel all orders after closing │ └─────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────┐ -│ 7. 记圕日志 │ +│ 7. Record Logs │ ├────────────────────────────────────────────────────── -│ • 保存完敎决策记圕到 decision_logs/ │ -│ • 包含思绎铟、决策JSON、莊户快照、执行结果 │ +│ • Save complete decision to decision_logs/ │ +│ • Includes CoT, decision JSON, account snapshot │ └─────────────────────────────────────────────────────┘ ``` --- -## 🧠 AI自我孊习瀺䟋 +## 🧠 AI Self-Learning Example -### 历史反銈Prompt䞭自劚添加 +### Historical Feedback (Auto-added to Prompt) ```markdown -## 📊 历史衚现反銈 +## 📊 Historical Performance Feedback -### 敎䜓衚现 -- **总亀易数**: 15 笔 (盈利: 8 | 亏损: 7) -- **胜率**: 53.3% -- **平均盈利**: +3.2% | 平均亏损: -2.1% -- **盈亏比**: 1.52:1 +### Overall Performance +- **Total Trades**: 15 (Profit: 8 | Loss: 7) +- **Win Rate**: 53.3% +- **Average Profit**: +3.2% | Average Loss: -2.1% +- **Profit/Loss Ratio**: 1.52:1 -### 最近亀易 +### Recent Trades 1. BTCUSDT LONG: 95000.0000 → 97500.0000 = +2.63% ✓ 2. ETHUSDT SHORT: 3500.0000 → 3450.0000 = +1.43% ✓ 3. SOLUSDT LONG: 185.0000 → 180.0000 = -2.70% ✗ 4. BNBUSDT LONG: 610.0000 → 625.0000 = +2.46% ✓ 5. ADAUSDT LONG: 0.8500 → 0.8300 = -2.35% ✗ -### 垁种衚现 -- **最䜳**: BTCUSDT (胜率75%, 平均+2.5%) -- **最差**: SOLUSDT (胜率25%, 平均-1.8%) +### Coin Performance +- **Best**: BTCUSDT (Win rate 75%, avg +2.5%) +- **Worst**: SOLUSDT (Win rate 25%, avg -1.8%) ``` -### AI劂䜕䜿甚反銈 +### How AI Uses Feedback -1. **避免连续亏损垁种**: 看到SOLUSDT连续3次止损AI䌚避匀或曎谚慎 -2. **区化成功策略**: BTC突砎做倚胜率75%AI䌚继续这䞪暡匏 -3. **劚态调敎风栌**: 胜率<40%时变保守盈亏比>2时保持激进 -4. **识别垂场环境**: 连续亏损可胜诎明垂场震荡减少亀易频率 +1. **Avoid consecutive losers**: Seeing SOLUSDT with 3 consecutive stop-losses, AI avoids or is more cautious +2. **Reinforce successful strategies**: BTC breakout long with 75% win rate, AI continues this pattern +3. **Dynamic style adjustment**: Win rate <40% → conservative; P/L ratio >2 → maintain aggressive +4. **Identify market conditions**: Consecutive losses may indicate choppy market, reduce trading frequency --- -## 📊 Web界面功胜 +## 📊 Web Interface Features -### 1. 竞赛页面Competition +### 1. Competition Page -- **🏆 排行抜**: 实时收益率排名金色蟹框突出星瀺领先者 -- **📈 性胜对比囟**: 双AI收益率曲线对比玫色vs蓝色 -- **⚔ Head-to-Head**: 盎接对比星瀺领先差距 -- **实时数据**: 总净倌、盈亏%、持仓数、保证金䜿甚率 +- **🏆 Leaderboard**: Real-time ROI ranking, golden border highlights leader +- **📈 Performance Comparison**: Dual AI ROI curve comparison (purple vs blue) +- **⚔ Head-to-Head**: Direct comparison showing lead margin +- **Real-time Data**: Total equity, P/L%, position count, margin usage -### 2. 诊情页面Details +### 2. Details Page -- **莊户净倌曲线**: 历史走势囟矎元/癟分比切换 -- **统计信息**: 总呚期、成功/倱莥、匀仓/平仓统计 -- **持仓衚栌**: 所有持仓诊情入场价、圓前价、盈亏%、区平价 -- **AI决策日志**: 最近决策记圕可展匀思绎铟 +- **Equity Curve**: Historical trend chart (USD/percentage toggle) +- **Statistics**: Total cycles, success/fail, open/close stats +- **Position Table**: All position details (entry price, current price, P/L%, liquidation price) +- **AI Decision Logs**: Recent decision records (expandable CoT) -### 3. 实时曎新 +### 3. Real-time Updates -- 系统状态、莊户信息、持仓列衚**每5秒刷新** -- 决策日志、统计信息**每10秒刷新** -- 收益率囟衚**每10秒刷新** +- System status, account info, position list: **5-second refresh** +- Decision logs, statistics: **10-second refresh** +- Equity charts: **10-second refresh** --- -## 🎛 API接口 +## 🎛 API Endpoints -### 竞赛盞关 +### Competition Related ```bash -GET /api/competition # 竞赛排行抜所有trader -GET /api/traders # Trader列衚 +GET /api/competition # Competition leaderboard (all traders) +GET /api/traders # Trader list ``` -### 单Trader盞关 +### Single Trader Related ```bash -GET /api/status?trader_id=xxx # 系统状态 -GET /api/account?trader_id=xxx # 莊户信息 -GET /api/positions?trader_id=xxx # 持仓列衚 -GET /api/equity-history?trader_id=xxx # 净倌历史囟衚数据 -GET /api/decisions/latest?trader_id=xxx # 最新5条决策 -GET /api/statistics?trader_id=xxx # 统计信息 +GET /api/status?trader_id=xxx # System status +GET /api/account?trader_id=xxx # Account info +GET /api/positions?trader_id=xxx # Position list +GET /api/equity-history?trader_id=xxx # Equity history (chart data) +GET /api/decisions/latest?trader_id=xxx # Latest 5 decisions +GET /api/statistics?trader_id=xxx # Statistics ``` -### 系统接口 +### System Endpoints ```bash -GET /health # 健康检查 -GET /api/config # 系统配眮 +GET /health # Health check +GET /api/config # System configuration ``` --- -## 📝 决策日志栌匏 +## ⚠ Important Risk Warnings -每次AI决策郜䌚生成诊细的JSON日志 +### Trading Risks -### 日志文件路埄 -``` -decision_logs/ -├── qwen_trader/ -│ └── decision_20251028_153042_cycle15.json -└── deepseek_trader/ - └── decision_20251028_153045_cycle15.json -``` +1. **Cryptocurrency markets are extremely volatile**, AI decisions don't guarantee profit +2. **Futures trading uses leverage**, losses may exceed principal +3. **Extreme market conditions** may lead to liquidation risk +4. **Funding rates** may affect holding costs +5. **Liquidity risk**: Some coins may experience slippage -### 日志内容瀺䟋 +### Technical Risks -```json -{ - "timestamp": "2025-10-28T15:30:42+08:00", - "cycle_number": 15, - "cot_trace": "圓前持仓ETHUSDT倚倎盈利+2.3%趋势良奜继续持有...", - "decision_json": "[{\"symbol\":\"BTCUSDT\",\"action\":\"open_long\"...}]", - "account_state": { - "total_balance": 1045.80, - "available_balance": 823.40, - "position_count": 3, - "margin_used_pct": 21.3 - }, - "positions": [...], - "candidate_coins": ["BTCUSDT", "ETHUSDT", ...], - "decisions": [ - { - "action": "open_long", - "symbol": "BTCUSDT", - "quantity": 0.015, - "leverage": 50, - "price": 95800.0, - "order_id": 123456789, - "success": true - } - ], - "execution_log": ["✓ BTCUSDT open_long 成功"], - "success": true -} -``` +1. **Network latency** may cause price slippage +2. **API rate limits** may affect trade execution +3. **AI API timeouts** may cause decision failures +4. **System bugs** may trigger unexpected behavior + +### Usage Recommendations + +✅ **Recommended** +- Use only funds you can afford to lose for testing +- Start with small amounts (recommended 100-500 USDT) +- Regularly check system operation status +- Monitor account balance changes +- Analyze AI decision logs to understand strategy + +❌ **Not Recommended** +- Invest all funds or borrowed money +- Run unsupervised for long periods +- Blindly trust AI decisions +- Use without understanding the system +- Run during extreme market volatility --- -## 🔧 风险控制诊解 +## 🛠 Common Issues -### 单垁种仓䜍限制 +### 1. Compilation error: TA-Lib not found -| 垁种类型 | 仓䜍价倌䞊限 | 杠杆 | 保证金占甚 | 瀺䟋1000U莊户 | -|---------|-------------|------|-----------|------------------| -| 山寚垁 | 1.5倍净倌 | 20x | 7.5% | 最倚匀1500U仓䜍 = 75U保证金 | -| BTC/ETH | 10倍净倌 | 50x | 20% | 最倚匀10000U仓䜍 = 200U保证金 | - -### 䞺什么这样讟计 - -1. **高杠杆 + 小仓䜍 = 分散风险** - - 20倍杠杆1500U仓䜍只需75U保证金 - - 可以同时匀10+䞪小仓䜍分散单垁种风险 - -2. **单垁种风险可控** - - 山寚垁仓䜍≀1.5倍净倌5%反向波劚 = 7.5%损倱 - - BTC仓䜍≀10倍净倌2%反向波劚 = 20%损倱 - -3. **䞍限制总保证金䜿甚率** - - AI根据垂场机䌚自䞻决策保证金䜿甚率 - - 侊限90%䜆䞍区制满仓 - - 有奜机䌚就匀仓没机䌚就观望 - -### 防止过床亀易 - -- **同垁种同方向䞍允讞重倍匀仓**: 防止AI连续匀同䞀䞪仓䜍富臎超限 -- **先平仓后匀仓**: 换仓时确保先释攟保证金 -- **止损止盈区制检查**: 风险回报比≥1:2 - ---- - -## ⚠ 重芁风险提瀺 - -### 亀易风险 - -1. **加密莧垁垂场波劚极倧**AI决策䞍保证盈利 -2. **合纊亀易䜿甚杠杆**亏损可胜超过本金 -3. **垂场极端行情**䞋可胜出现爆仓风险 -4. **资金莹率**可胜圱响持仓成本 -5. **流劚性风险**某些垁种可胜出现滑点 - -### 技术风险 - -1. **眑络延迟**可胜富臎价栌滑点 -2. **API限流**可胜圱响亀易执行 -3. **AI API超时**可胜富臎决策倱莥 -4. **系统Bug**可胜匕发意倖行䞺 - -### 䜿甚建议 - -✅ **建议做法** -- 仅䜿甚可承受损倱的资金测试 -- 从小额资金匀始建议100-500 USDT -- 定期检查系统运行状态 -- 监控莊户䜙额变化 -- 分析AI决策日志理解策略 - -❌ **䞍建议做法** -- 投入党郚资金或借获资金 -- 长时闎无人监控运行 -- 盲目信任AI决策 -- 圚䞍理解系统的情况䞋䜿甚 -- 圚垂场极端波劚时运行 - ---- - -## 🛠 垞见问题 - -### 1. 猖译错误TA-Lib not found - -**解决**: 安装TA-Lib库 +**Solution**: Install TA-Lib library ```bash # macOS brew install ta-lib @@ -522,103 +447,103 @@ brew install ta-lib sudo apt-get install libta-lib0-dev ``` -### 2. 粟床错误Precision is over the maximum +### 2. Precision error: Precision is over the maximum -**解决**: 系统已自劚倄理粟床从Binance获取LOT_SIZE。劂仍报错检查眑络连接。 +**Solution**: System auto-handles precision from Binance LOT_SIZE. If error persists, check network connection. -### 3. AI API超时 +### 3. AI API timeout -**解决**: -- 检查API密钥是吊正确 -- 检查眑络连接可胜需芁代理 -- 系统超时时闎已讟眮䞺120秒 +**Solution**: +- Check if API key is correct +- Check network connection (may need proxy) +- System timeout is set to 120 seconds -### 4. 前端无法连接后端 +### 4. Frontend can't connect to backend -**解决**: -- 确保后端正圚运行http://localhost:8080 -- 检查端口8080是吊被占甚 -- 查看浏览噚控制台错误信息 +**Solution**: +- Ensure backend is running (http://localhost:8080) +- Check if port 8080 is occupied +- Check browser console for errors -### 5. 垁种池API倱莥 +### 5. Coin pool API failure -**解决**: -- 垁种池API是可选的 -- 劂果API倱莥系统䌚䜿甚默讀䞻流垁种BTC、ETH等 -- 检查config.json侭的API URL和auth参数 +**Solution**: +- Coin pool API is optional +- If API fails, system uses default mainstream coins (BTC, ETH, etc.) +- Check API URL and auth parameter in config.json --- -## 📈 性胜䌘化建议 +## 📈 Performance Optimization Tips -1. **合理讟眮决策呚期**: 建议3-5分钟避免过床亀易 -2. **控制候选垁种数量**: 系统默讀分析AI500前20 + OI Top前20 -3. **定期枅理日志**: 避免占甚过倚磁盘空闎 -4. **监控API调甚次数**: 避免觊发Binance限流权重限制 -5. **小额资金测试**: 先甚100-500 USDT测试策略有效性 +1. **Set reasonable decision cycle**: Recommended 3-5 minutes, avoid over-trading +2. **Control candidate coin count**: System defaults to AI500 top 20 + OI Top top 20 +3. **Regularly clean logs**: Avoid excessive disk usage +4. **Monitor API call count**: Avoid triggering Binance rate limits +5. **Test with small capital**: First test with 100-500 USDT for strategy validation --- -## 🔄 曎新日志 +## 🔄 Changelog ### v2.0.0 (2025-10-28) -**重倧曎新:** -- ✅ AI自我孊习机制历史反銈、衚现分析 -- ✅ 倚Trader竞赛暡匏Qwen vs DeepSeek -- ✅ Binance风栌UI完敎暡仿垁安界面 -- ✅ 性胜对比囟衚收益率实时对比 -- ✅ 风险控制䌘化单垁种仓䜍䞊限调敎 +**Major Updates:** +- ✅ AI self-learning mechanism (historical feedback, performance analysis) +- ✅ Multi-trader competition mode (Qwen vs DeepSeek) +- ✅ Binance-style UI (complete Binance interface imitation) +- ✅ Performance comparison charts (real-time ROI comparison) +- ✅ Risk control optimization (per-coin position limit adjustment) -**Bug修倍:** -- 修倍初始䜙额硬猖码问题 -- 修倍倚trader数据同步问题 -- 䌘化囟衚数据对霐䜿甚cycle_number +**Bug Fixes:** +- Fixed hardcoded initial balance issue +- Fixed multi-trader data sync issue +- Optimized chart data alignment (using cycle_number) ### v1.0.0 (2025-10-27) -- 初始版本发垃 -- 基础AI亀易功胜 -- 决策日志系统 -- 简单Web界面 +- Initial release +- Basic AI trading functionality +- Decision logging system +- Simple Web interface --- -## 📄 匀源协议 +## 📄 License -MIT License - 诊见 [LICENSE](LICENSE) 文件 +MIT License - See [LICENSE](LICENSE) file for details --- -## 🀝 莡献 +## 🀝 Contributing -欢迎提亀Issue和Pull Request +Issues and Pull Requests are welcome! -### 匀发指南 +### Development Guide -1. Fork项目 -2. 创建功胜分支 (`git checkout -b feature/AmazingFeature`) -3. 提亀曎改 (`git commit -m 'Add some AmazingFeature'`) -4. 掚送到分支 (`git push origin feature/AmazingFeature`) -5. 匀启Pull Request +1. Fork the project +2. Create feature branch (`git checkout -b feature/AmazingFeature`) +3. Commit changes (`git commit -m 'Add some AmazingFeature'`) +4. Push to branch (`git push origin feature/AmazingFeature`) +5. Open Pull Request --- -## 📬 联系方匏 +## 📬 Contact -劂有问题或建议请提亀 [GitHub Issue](https://github.com/yourusername/nofx/issues) +For questions or suggestions, please submit a [GitHub Issue](https://github.com/tinkle-community/nofx/issues) --- -## 🙏 臎谢 +## 🙏 Acknowledgments -- [Binance API](https://binance-docs.github.io/apidocs/futures/cn/) - 垁安合纊API +- [Binance API](https://binance-docs.github.io/apidocs/futures/en/) - Binance Futures API - [DeepSeek](https://platform.deepseek.com/) - DeepSeek AI API -- [Qwen](https://dashscope.aliyuncs.com/) - 阿里云通义千问 -- [TA-Lib](https://ta-lib.org/) - 技术指标库 -- [Recharts](https://recharts.org/) - React囟衚库 +- [Qwen](https://dashscope.aliyuncs.com/) - Alibaba Cloud Qwen +- [TA-Lib](https://ta-lib.org/) - Technical indicator library +- [Recharts](https://recharts.org/) - React chart library --- -**最后曎新**: 2025-10-28 +**Last Updated**: 2025-10-28 -**⚡ 甹AI的力量探玢量化亀易的可胜性** +**⚡ Explore the possibilities of quantitative trading with the power of AI!**