From 2c3b6ef073766449a892fd1cc791ad32c5d37a9c Mon Sep 17 00:00:00 2001 From: shokollm <270575765+shokollm@users.noreply.github.com> Date: Mon, 13 Apr 2026 23:37:17 +0000 Subject: [PATCH] fix: Show token name and ticker in backtest result - Added _get_token_info helper to fetch symbol and name - Backtest result now shows: **PEPE** (Pepe) - --- .../app/services/ai_agent/conversational.py | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/backend/app/services/ai_agent/conversational.py b/src/backend/app/services/ai_agent/conversational.py index 6ab0e87..0b07a8e 100644 --- a/src/backend/app/services/ai_agent/conversational.py +++ b/src/backend/app/services/ai_agent/conversational.py @@ -879,6 +879,28 @@ class ConversationalAgent: "success": True, } + def _get_token_info(self, address: str) -> Dict[str, str]: + """Get basic token info (symbol, name) without formatting for display.""" + try: + code, output = self._call_ave_script( + "token", + ["--address", address.strip(), "--chain", "bsc"], + ) + if code == 0: + try: + data = json.loads(output) + data_field = data.get("data") + token_data = data_field if isinstance(data_field, dict) else {} + token_info = token_data.get("token", token_data) + symbol = token_info.get("symbol") or token_data.get("symbol") + name = token_info.get("name") or token_data.get("name") + return {"symbol": symbol or "", "name": name or ""} + except (json.JSONDecodeError, AttributeError): + return {"symbol": "", "name": ""} + return {"symbol": "", "name": ""} + except Exception: + return {"symbol": "", "name": ""} + def _execute_token(self, address: str) -> Dict[str, Any]: """Execute token details for the given address.""" try: @@ -1073,6 +1095,12 @@ class ConversationalAgent: "success": True, } + # Look up token details first + token_info = self._get_token_info(token_address) + token_label = f"`{token_address}`" + if token_info.get("symbol"): + token_label = f"**{token_info['symbol']}** ({token_info.get('name', 'Unknown')}) - `{token_address}`" + # Execute backtest result = self._execute_backtest( token_address=token_address, @@ -1080,8 +1108,9 @@ class ConversationalAgent: start_date=start_date, end_date=end_date, ) + # Prepend token info to backtest result return { - "response": result, + "response": f"📊 **Backtest for {token_label}**\n\n{result}", "thinking": None, "strategy_updated": False, "strategy_needs_confirmation": False,