diff --git a/src/backend/app/db/schemas.py b/src/backend/app/db/schemas.py index 30d2a5f..59b87f3 100644 --- a/src/backend/app/db/schemas.py +++ b/src/backend/app/db/schemas.py @@ -69,6 +69,7 @@ class BotResponse(BaseModel): class BacktestCreate(BaseModel): token: str + token_name: Optional[str] = None chain: str timeframe: str start_date: str diff --git a/src/frontend/src/lib/api/types.ts b/src/frontend/src/lib/api/types.ts index da30805..b1a2885 100644 --- a/src/frontend/src/lib/api/types.ts +++ b/src/frontend/src/lib/api/types.ts @@ -72,6 +72,7 @@ export interface Backtest { export interface BacktestConfig { token: string; + token_name?: string; chain: string; timeframe: string; start_date: string; diff --git a/src/frontend/src/routes/bot/[id]/backtest/+page.svelte b/src/frontend/src/routes/bot/[id]/backtest/+page.svelte index 578a099..4124642 100644 --- a/src/frontend/src/routes/bot/[id]/backtest/+page.svelte +++ b/src/frontend/src/routes/bot/[id]/backtest/+page.svelte @@ -8,7 +8,8 @@ import type { Backtest } from '$lib/api'; let botId = $derived($page.params.id); - let token = $state('PEPE'); + let tokenName = $state(''); + let tokenAddress = $state(''); let timeframe = $state('1h'); let startDate = $state(''); let endDate = $state(''); @@ -43,6 +44,16 @@ try { const bot = await api.bots.get(botId); setCurrentBot(bot); + + // Extract token info from strategy config + const strategy = bot.strategy_config; + if (strategy) { + // Try conditions first, then actions + const condition = strategy.conditions?.[0]; + const action = strategy.actions?.[0]; + tokenName = condition?.token || action?.token || ''; + tokenAddress = condition?.token_address || action?.token_address || ''; + } } catch (e) { goto('/dashboard'); } @@ -76,7 +87,8 @@ try { const backtest = await api.backtest.start(botId, { - token, + token: tokenAddress, // Use token address from strategy + token_name: tokenName, // Also send token name for display timeframe, start_date: startDate, end_date: endDate @@ -133,16 +145,18 @@