diff --git a/api/server.go b/api/server.go index 211d5aff..c87138fd 100644 --- a/api/server.go +++ b/api/server.go @@ -157,8 +157,8 @@ func (s *Server) setupRoutes() { s.route(protected, "GET", "/my-traders", "List user's traders with status", s.handleTraderList) s.route(protected, "GET", "/traders/:id/config", "Get full trader configuration", s.handleGetTraderConfig) s.routeWithSchema(protected, "POST", "/traders", "Create a new AI trader", - `Body: {"name":"","ai_model_id":"","exchange_id":"","strategy_id":"","scan_interval_minutes":} -Workflow: 1) GET /api/exchanges to find enabled exchange ID 2) GET /api/models to find enabled model ID 3) GET /api/strategies to find strategy ID 4) POST with all IDs`, + `Body: {"name":"","ai_model_id":"","exchange_id":"","strategy_id":"","scan_interval_minutes":} +Use exchange_id and ai_model_id from the Account State block injected at conversation start — no need to GET them again.`, s.handleCreateTrader) s.route(protected, "PUT", "/traders/:id", "Update trader configuration", s.handleUpdateTrader) s.route(protected, "DELETE", "/traders/:id", "Delete trader", s.handleDeleteTrader) @@ -211,7 +211,9 @@ Required fields by exchange: s.route(protected, "POST", "/strategies/test-run", "Test-run strategy AI analysis", s.handleStrategyTestRun) s.route(protected, "GET", "/strategies/:id", "Get strategy by ID", s.handleGetStrategy) s.routeWithSchema(protected, "POST", "/strategies", "Create a new trading strategy", - `Body: {"name":"","description":"","lang":"zh|en","config":} + `Body: {"name":"","description":"","lang":"zh|en","config":} +IMPORTANT: For most use cases just POST {"name":""} — the backend fills everything in. Only include "config" when the user explicitly requests custom settings (specific coins, custom leverage, custom timeframes). + StrategyConfig fields: coin_source.source_type: "static"(fixed coin list) | "ai500"(AI top500 ranking) | "oi_top"(OI increasing, suited for long) | "oi_low"(OI decreasing, suited for short) | "mixed" coin_source.static_coins: ["BTCUSDT","ETHUSDT"] — only when source_type="static" diff --git a/telegram/agent/prompt.go b/telegram/agent/prompt.go index 075ef5d3..56629b59 100644 --- a/telegram/agent/prompt.go +++ b/telegram/agent/prompt.go @@ -65,21 +65,17 @@ Use this to: **Create strategy** (independent from traders): - Never GET trader info just to create a strategy. -- If user specifies style + coins (e.g. "BTC trend"), build and POST immediately — no questions needed. -- Build StrategyConfig intelligently from user's description: - - "trend" / "趋势" → enable EMA(20,50), MACD, RSI, multi-timeframe (15m,1h,4h), longer primary TF - - "scalping" / "短线" → enable RSI, ATR, shorter timeframes (1m,3m,5m) - - "conservative" / "保守" → lower leverage (2-3x), higher min confidence (80%%+) - - "BTC/ETH" → set coin_source.source_type="static", static_coins=["BTC/USDT"] or similar -- After POST: GET /api/strategies/:id to verify → show user: name, coins, key indicators, leverage +- POST {"name":""} — config is OPTIONAL. Backend applies complete working defaults automatically (ai500 top coins, all indicators, standard risk control). Strategy is immediately usable. +- Only include "config" when user explicitly requests custom settings (specific coins, custom leverage, different timeframes). +- After POST: GET /api/strategies/:id to verify → show user: name, coin_source.source_type, key risk_control values **"帮我配置策略并跑起来" / "create strategy and start" (full setup workflow)**: Execute these steps IN ORDER with NO user confirmation between them: -1. POST /api/strategies — create strategy with config built from user's description -2. GET /api/strategies/:id — verify strategy was saved correctly -3. POST /api/traders — create trader: use exchange_id and model_id from Account State (if only one each, use directly); set strategy_id from step 1; set name like "BTC趋势" or similar +1. POST /api/strategies — body: {"name":""} — no config needed, defaults are complete +2. GET /api/strategies/:id — verify strategy was saved +3. POST /api/traders — create trader: use exchange_id and model_id from Account State (if only one each, use directly); set strategy_id from step 1; set name matching the strategy 4. POST /api/traders/:id/start — start the trader -5. Final reply: show strategy name, trader name, key config (coins, leverage, indicators), confirm running +5. Final reply: show strategy name, trader name, coin source, confirm running **Update strategy config**: 1. GET /api/strategies/:id to read current full config diff --git a/telegram/bot.go b/telegram/bot.go index 51cd83d8..959ab336 100644 --- a/telegram/bot.go +++ b/telegram/bot.go @@ -254,9 +254,12 @@ func clientForProvider(provider string) mcp.AIClient { return mcp.NewOpenAIClient() case "deepseek": return mcp.NewDeepSeekClient() + case "claude": + // Anthropic Messages API — different wire format (x-api-key, input_schema, tool_use blocks). + return mcp.NewClaudeClient() default: - // Qwen, Kimi, Grok, Gemini, Claude, custom: fall back to DeepSeek-format client. - // These providers use OpenAI-compatible APIs; CustomAPIURL and CustomModelName are required. + // Qwen, Kimi, Grok, Gemini, custom: OpenAI-compatible APIs. + // CustomAPIURL and CustomModelName are required for these providers. return mcp.NewDeepSeekClient() } }