diff --git a/src/backend/app/api/simulate.py b/src/backend/app/api/simulate.py index 82e087f..0280add 100644 --- a/src/backend/app/api/simulate.py +++ b/src/backend/app/api/simulate.py @@ -154,9 +154,17 @@ async def start_simulation( # Fetch klines SYNCHRONOUSLY so user can see chart immediately try: token_id = f"{config.token}-{config.chain}" + + # Calculate time range (last 1 hour) + import time + end_time = int(time.time() * 1000) + start_time = end_time - (60 * 60 * 1000) # 1 hour ago + klines_data = await ave_client.get_klines( token_id, interval=config.kline_interval, + start_time=start_time, + end_time=end_time, limit=500 ) klines_for_chart = [ diff --git a/src/frontend/src/lib/components/SignalChart.svelte b/src/frontend/src/lib/components/SignalChart.svelte index b6c7dd6..2f2b71e 100644 --- a/src/frontend/src/lib/components/SignalChart.svelte +++ b/src/frontend/src/lib/components/SignalChart.svelte @@ -41,12 +41,14 @@ // Clear ctx.clearRect(0, 0, width, height); - // Get price data - const prices = klines.length > 0 - ? klines.map(k => k.close) - : signals.map(s => s.price); + // Get price data (convert strings to numbers) + const priceData = klines.length > 0 + ? klines.map(k => ({ time: k.time, price: parseFloat(k.close) || 0 })) + : signals.map(s => ({ time: 0, price: s.price })); - if (prices.length === 0) return; + if (priceData.length === 0) return; + + const prices = priceData.map(d => d.price); const padding = { top: 20, right: 20, bottom: 30, left: 60 }; const chartWidth = width - padding.left - padding.right;