diff --git a/app/routes/analyze.ticker.tsx b/app/routes/analyze.ticker.tsx index 960594e..1b87874 100644 --- a/app/routes/analyze.ticker.tsx +++ b/app/routes/analyze.ticker.tsx @@ -8,6 +8,7 @@ interface LoaderData { ticker: string; position: number | null; orders: any[]; + bars: any[]; } export async function loader({ params, request }: { params: { ticker: string }; request: Request }) { @@ -27,11 +28,25 @@ export async function loader({ params, request }: { params: { ticker: string }; const ordersData = ordRes.ok ? await ordRes.json() : { orders: [] }; const orders = ordersData.orders?.filter((o: any) => o.symbol === ticker) || []; + // Fetch bars for chart + const barsRes = await fetch(`${baseUrl}/api/alpaca/quote/${ticker}`); + const barsData = barsRes.ok ? await barsRes.json() : null; + const bars = barsData?.bars || []; + return Response.json({ ticker, position, orders }); } export default function StockDetail() { - const { ticker, position, orders } = useLoaderData() as LoaderData; + const { ticker, position, orders, bars } = useLoaderData() as LoaderData; + + // Convert Alpaca bars to TradingView format + const chartData = bars?.map((bar: any) => ({ + time: bar.t, + open: bar.o, + high: bar.h, + low: bar.l, + close: bar.c, + })) || []; return (