diff --git a/services/ml/app/__pycache__/main.cpython-313.pyc b/services/ml/app/__pycache__/main.cpython-313.pyc index 227dfb4..b04affe 100644 Binary files a/services/ml/app/__pycache__/main.cpython-313.pyc and b/services/ml/app/__pycache__/main.cpython-313.pyc differ diff --git a/services/ml/app/main.py b/services/ml/app/main.py index 44cfd7d..976ea82 100644 --- a/services/ml/app/main.py +++ b/services/ml/app/main.py @@ -66,7 +66,7 @@ class CandleData(BaseModel): high: float low: float close: float - volume: float + volume: Optional[float] = None class PredictRequest(BaseModel): diff --git a/src/app/api/charts/[id]/route.ts b/src/app/api/charts/[id]/route.ts index 923fbbf..a14fd49 100644 --- a/src/app/api/charts/[id]/route.ts +++ b/src/app/api/charts/[id]/route.ts @@ -3,6 +3,26 @@ import { db } from '@/lib/db'; import { charts, candles, annotations } from '@/lib/db/schema'; import { eq } from 'drizzle-orm'; +export async function GET( + _request: NextRequest, + { params }: { params: Promise<{ id: string }> } +) { + const { id } = await params; + const chartId = parseInt(id, 10); + + if (isNaN(chartId)) { + return NextResponse.json({ error: 'Invalid chart ID' }, { status: 400 }); + } + + const result = await db.select().from(charts).where(eq(charts.id, chartId)).limit(1); + + if (result.length === 0) { + return NextResponse.json({ error: 'Chart not found' }, { status: 404 }); + } + + return NextResponse.json(result[0]); +} + export async function DELETE( _request: NextRequest, { params }: { params: Promise<{ id: string }> } diff --git a/src/app/page.tsx b/src/app/page.tsx index edf9531..246b927 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -512,18 +512,12 @@ export default function Home() { throw new Error('No candles found for this chart'); } - const startTime = candlesData[0].time; - const endTime = candlesData[candlesData.length - 1].time; - - // Make batch prediction request - const response = await fetch('/api/predict/batch', { + // Use regular predict endpoint with all candles from the database + const response = await fetch('/api/predict', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ - pair: chartData.name, - timeframe: '1h', // TODO: Get from chart metadata - start_time: startTime, - end_time: endTime, + candles: candlesData, }), });