feat(tests): update Alpaca API tests to include range parameters and improve stock database cleanup
Run Tests / test (push) Failing after 8s
Run Tests / test (push) Failing after 8s
- Modified Alpaca Historical Bars tests to include range parameters in API requests. - Updated test descriptions for clarity. - Added cleanup step to delete test ticker after verification in stock database tests. - Adjusted Vitest configuration to exclude test files from coverage.
This commit is contained in:
@@ -1,9 +1,19 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import * as LightweightCharts from "lightweight-charts";
|
||||
|
||||
type ChartTime = string | number;
|
||||
|
||||
interface ChartDataPoint {
|
||||
time: ChartTime;
|
||||
open: number;
|
||||
high: number;
|
||||
low: number;
|
||||
close: number;
|
||||
}
|
||||
|
||||
interface TradingViewChartProps {
|
||||
ticker: string;
|
||||
data?: Array<{ time: string; open: number; high: number; low: number; close: number }>;
|
||||
data?: ChartDataPoint[];
|
||||
}
|
||||
|
||||
export default function TradingViewChart({ ticker, data }: TradingViewChartProps) {
|
||||
@@ -11,12 +21,9 @@ export default function TradingViewChart({ ticker, data }: TradingViewChartProps
|
||||
|
||||
useEffect(() => {
|
||||
if (!containerRef.current) {
|
||||
console.warn(`TradingViewChart: container not ready for ${ticker}`);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`TradingViewChart: creating chart for ${ticker} with ${data?.length ?? 0} bars`);
|
||||
|
||||
const chart = LightweightCharts.createChart(containerRef.current, {
|
||||
height: 400,
|
||||
autoSize: true,
|
||||
@@ -32,15 +39,11 @@ export default function TradingViewChart({ ticker, data }: TradingViewChartProps
|
||||
});
|
||||
|
||||
if (data && data.length > 0) {
|
||||
console.log(`TradingViewChart: setting data for ${ticker}`, data.slice(0, 3));
|
||||
try {
|
||||
candlestickSeries.setData(data);
|
||||
console.log(`TradingViewChart: data set successfully for ${ticker}`);
|
||||
candlestickSeries.setData(data as any);
|
||||
} catch (err) {
|
||||
console.error(`TradingViewChart: error setting data for ${ticker}`, err);
|
||||
}
|
||||
} else {
|
||||
console.log(`TradingViewChart: no data to set for ${ticker}`);
|
||||
}
|
||||
|
||||
return () => chart.remove();
|
||||
|
||||
@@ -18,12 +18,11 @@ describe("AlpacaAccountInfo", () => {
|
||||
render(<AlpacaAccountInfo />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/Alpaca Account/i)).toBeInTheDocument();
|
||||
expect(screen.getByText(/Trading Account/i)).toBeInTheDocument();
|
||||
});
|
||||
// Use regex to match number regardless of locale decimal separator
|
||||
expect(screen.getByText(/\$12[\.,]345/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/\$8[\.,]000/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/\$25[\.,]000/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/Cash/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/Buying Power/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/Portfolio Value/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("displays error when fetch fails", async () => {
|
||||
@@ -33,7 +32,7 @@ describe("AlpacaAccountInfo", () => {
|
||||
render(<AlpacaAccountInfo />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/Failed to load account info/i)).toBeInTheDocument();
|
||||
expect(screen.getByText(/Network error/i)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -10,7 +10,8 @@ describe("OpenRouterClient", () => {
|
||||
it("should have default free models list", () => {
|
||||
const client = new OpenRouterClient("test-api-key");
|
||||
const models = client.getFreeModels();
|
||||
expect(models).toContain("google/gemini-2.0-flash-exp:free");
|
||||
expect(models.length).toBeGreaterThan(0);
|
||||
expect(models).toContain("openai/gpt-oss-120b:free");
|
||||
});
|
||||
|
||||
it("should have available model providers", () => {
|
||||
|
||||
@@ -6,7 +6,6 @@ export default [
|
||||
route("api/alpaca/quote/:ticker", "routes/api/alpaca/quote.ts"),
|
||||
route("api/alpaca/orders", "routes/api/alpaca/orders.ts"),
|
||||
route("api/alpaca/positions", "routes/api/alpaca/positions.ts"),
|
||||
route("api/test-alpaca", "routes/api/test-alpaca.ts"),
|
||||
route("api/indicators", "routes/api/indicators.ts"),
|
||||
route("api/analyze", "routes/api/analyze.ts"),
|
||||
route("api/stocks", "routes/api/stocks/index.ts"),
|
||||
|
||||
@@ -6,11 +6,11 @@ export const meta = () => [{ title: "Stock Detail - AITrader" }];
|
||||
|
||||
interface LoaderData {
|
||||
ticker: string;
|
||||
position: number | null;
|
||||
position: { qty: number; avg_entry_price: number; current_price: number; market_value: number; unrealized_pl: number } | null;
|
||||
orders: any[];
|
||||
bars: any[];
|
||||
timeframe: string;
|
||||
limit: number;
|
||||
range: string;
|
||||
}
|
||||
|
||||
const TIMEFRAMES = [
|
||||
@@ -21,70 +21,85 @@ const TIMEFRAMES = [
|
||||
{ value: "1W", label: "1 Week" },
|
||||
];
|
||||
|
||||
const RANGES = [
|
||||
{ value: "1D", label: "1 Day" },
|
||||
{ value: "1W", label: "1 Week" },
|
||||
{ value: "1M", label: "1 Month" },
|
||||
{ value: "3M", label: "3 Months" },
|
||||
{ value: "1Y", label: "1 Year" },
|
||||
{ value: "3Y", label: "3 Years" },
|
||||
{ value: "ALL", label: "All" },
|
||||
];
|
||||
|
||||
export async function loader({ params, request }: { params: { ticker: string }; request: Request }) {
|
||||
const ticker = params.ticker?.toUpperCase() || "";
|
||||
const url = new URL(request.url);
|
||||
const timeframe = url.searchParams.get("timeframe") || "1D";
|
||||
const limit = parseInt(url.searchParams.get("limit") || "30", 10);
|
||||
console.log(`analyze/${ticker}: loader called with timeframe=${timeframe}, limit=${limit}`);
|
||||
const range = url.searchParams.get("range") || "1M";
|
||||
|
||||
// Build base URL from request for server-side fetches
|
||||
const reqUrl = new URL(request.url);
|
||||
const host = request.headers.get("host") || reqUrl.host;
|
||||
const protocol = reqUrl.protocol;
|
||||
const baseUrl = `${protocol}//${host}`;
|
||||
console.log(`analyze/${ticker}: baseUrl = ${baseUrl}`);
|
||||
|
||||
let position = null;
|
||||
let orders = [];
|
||||
let bars = [];
|
||||
|
||||
try {
|
||||
// Fetch position
|
||||
// Fetch positions
|
||||
const posRes = await fetch(`${baseUrl}/api/alpaca/positions`);
|
||||
console.log(`analyze/${ticker}: positions status = ${posRes.status}`);
|
||||
const positions = posRes.ok ? await posRes.json() : [];
|
||||
position = positions.find((p: any) => p.ticker === ticker)?.qty ?? null;
|
||||
position = positions.find((p: any) => p.ticker === ticker) ?? null;
|
||||
|
||||
// Fetch orders
|
||||
const ordRes = await fetch(`${baseUrl}/api/alpaca/orders`);
|
||||
const ordersData = ordRes.ok ? await ordRes.json() : { orders: [] };
|
||||
orders = ordersData.orders?.filter((o: any) => o.symbol === ticker) || [];
|
||||
|
||||
// Fetch bars for chart with timeframe and limit
|
||||
console.log(`analyze/${ticker}: fetching bars from ${baseUrl}/api/alpaca/quote/${ticker}?timeframe=${timeframe}&limit=${limit}`);
|
||||
const barsRes = await fetch(`${baseUrl}/api/alpaca/quote/${ticker}?timeframe=${timeframe}&limit=${limit}`);
|
||||
console.log(`analyze/${ticker}: bars response status = ${barsRes.status}`);
|
||||
// Fetch bars for chart with timeframe and range
|
||||
const barsRes = await fetch(`${baseUrl}/api/alpaca/quote/${ticker}?timeframe=${timeframe}&range=${range}`);
|
||||
const barsData = barsRes.ok ? await barsRes.json() : null;
|
||||
console.log(`analyze/${ticker}: barsData =`, JSON.stringify(barsData));
|
||||
bars = barsData?.bars || [];
|
||||
} catch (err) {
|
||||
console.error(`analyze/${ticker}: loader error`, err);
|
||||
}
|
||||
|
||||
return Response.json({ ticker, position, orders, bars, timeframe, limit });
|
||||
return Response.json({ ticker, position, orders, bars, timeframe, range });
|
||||
}
|
||||
|
||||
export default function StockDetail() {
|
||||
const { ticker, position, orders, bars, timeframe, limit } = useLoaderData() as LoaderData;
|
||||
const { ticker, position, orders, bars, timeframe, range } = useLoaderData() as LoaderData;
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
const updateParams = (newTimeframe: string, newLimit: number) => {
|
||||
const updateParams = (newTimeframe: string, newRange: string) => {
|
||||
const searchParams = new URLSearchParams(location.search);
|
||||
searchParams.set("timeframe", newTimeframe);
|
||||
searchParams.set("limit", newLimit.toString());
|
||||
searchParams.set("range", newRange);
|
||||
navigate(`${location.pathname}?${searchParams.toString()}`, { replace: true });
|
||||
};
|
||||
|
||||
// Convert Alpaca bars to TradingView format (YYYY-MM-DD for time)
|
||||
const chartData = bars?.map((bar: any) => {
|
||||
// Convert Alpaca bars to TradingView format
|
||||
// Keep full timestamp for intraday, use date-only for daily
|
||||
// Sort bars by timestamp to ensure ascending order
|
||||
const sortedBars = [...(bars || [])].sort((a, b) => {
|
||||
const timeA = a.t ? new Date(a.t).getTime() : 0;
|
||||
const timeB = b.t ? new Date(b.t).getTime() : 0;
|
||||
return timeA - timeB;
|
||||
});
|
||||
|
||||
const chartData = sortedBars?.map((bar: any) => {
|
||||
// Handle timestamp - could be string, number, or Date
|
||||
let time = "";
|
||||
let time: string | number = "";
|
||||
if (bar.t) {
|
||||
const date = new Date(bar.t);
|
||||
if (!isNaN(date.getTime())) {
|
||||
time = date.toISOString().split('T')[0];
|
||||
// Use Unix timestamp for intraday, date string for daily
|
||||
time = ["1Min", "5Min", "15Min", "30Min", "1H"].includes(timeframe)
|
||||
? Math.floor(date.getTime() / 1000)
|
||||
: date.toISOString().split('T')[0];
|
||||
}
|
||||
}
|
||||
return {
|
||||
@@ -94,9 +109,12 @@ export default function StockDetail() {
|
||||
low: bar.l,
|
||||
close: bar.c,
|
||||
};
|
||||
}).filter((bar: any) => bar.time && bar.open != null && bar.high != null && bar.low != null && bar.close != null) || [];
|
||||
|
||||
console.log(`StockDetail: loaded ${bars?.length ?? 0} bars, transformed to ${chartData.length} chart points`);
|
||||
})
|
||||
// Remove duplicates by time (keep first occurrence) and filter valid bars
|
||||
.filter((bar: any, index: number, arr: any[]) =>
|
||||
bar.time && bar.open != null && bar.high != null && bar.low != null && bar.close != null &&
|
||||
index === arr.findIndex((b: any) => b.time === bar.time)
|
||||
) || [];
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-gray-50 to-blue-50">
|
||||
@@ -109,7 +127,7 @@ export default function StockDetail() {
|
||||
<span className="text-gray-700 font-medium">Timeframe:</span>
|
||||
<select
|
||||
value={timeframe}
|
||||
onChange={(e) => updateParams(e.target.value, limit)}
|
||||
onChange={(e) => updateParams(e.target.value, range)}
|
||||
className="border border-gray-300 rounded-lg px-3 py-1.5 text-gray-900 focus:ring-2 focus:ring-blue-500"
|
||||
>
|
||||
{TIMEFRAMES.map((tf) => (
|
||||
@@ -117,16 +135,15 @@ export default function StockDetail() {
|
||||
))}
|
||||
</select>
|
||||
|
||||
<span className="text-gray-700 font-medium">Bars:</span>
|
||||
<span className="text-gray-700 font-medium">Range:</span>
|
||||
<select
|
||||
value={limit}
|
||||
onChange={(e) => updateParams(timeframe, parseInt(e.target.value))}
|
||||
value={range}
|
||||
onChange={(e) => updateParams(timeframe, e.target.value)}
|
||||
className="border border-gray-300 rounded-lg px-3 py-1.5 text-gray-900 focus:ring-2 focus:ring-blue-500"
|
||||
>
|
||||
<option value={10}>10</option>
|
||||
<option value={30}>30</option>
|
||||
<option value={50}>50</option>
|
||||
<option value={100}>100</option>
|
||||
{RANGES.map((r) => (
|
||||
<option key={r.value} value={r.value}>{r.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -135,7 +152,34 @@ export default function StockDetail() {
|
||||
|
||||
<div className="mt-6 bg-white rounded-xl shadow-lg p-6 border border-gray-200">
|
||||
<h2 className="text-xl font-bold text-gray-900 mb-4">Position</h2>
|
||||
<p className="text-gray-600">{position ? `Quantity: ${position} shares` : "No position held"}</p>
|
||||
{position ? (
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-sm">
|
||||
<tbody>
|
||||
<tr className="border-b border-gray-100">
|
||||
<td className="py-2 px-3 font-medium text-gray-700">Quantity</td>
|
||||
<td className="py-2 px-3 text-gray-900">{position.qty} shares</td>
|
||||
</tr>
|
||||
<tr className="border-b border-gray-100">
|
||||
<td className="py-2 px-3 font-medium text-gray-700">Ticker</td>
|
||||
<td className="py-2 px-3 text-gray-900">{ticker}</td>
|
||||
</tr>
|
||||
<tr className="border-b border-gray-100">
|
||||
<td className="py-2 px-3 font-medium text-gray-700">Current Value</td>
|
||||
<td className="py-2 px-3 text-gray-900">${position.market_value.toFixed(2)}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="py-2 px-3 font-medium text-gray-700">Earnings</td>
|
||||
<td className={`py-2 px-3 font-bold ${position.unrealized_pl >= 0 ? "text-green-600" : "text-red-600"}`}>
|
||||
${position.unrealized_pl.toFixed(2)}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-gray-600">No position held</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="mt-6 bg-white rounded-xl shadow-lg p-6 border border-gray-200">
|
||||
|
||||
@@ -12,9 +12,13 @@ export async function loader() {
|
||||
try {
|
||||
const positions = await alpaca.getPositions();
|
||||
return Response.json(
|
||||
positions.map((p: { symbol: string; qty: string; avg_entry_price: string; current_price: string }) => ({
|
||||
positions.map((p: { symbol: string; qty: string; avg_entry_price: string; current_price: string; market_value: string; unrealized_pl: string }) => ({
|
||||
ticker: p.symbol,
|
||||
qty: parseFloat(p.qty),
|
||||
avg_entry_price: parseFloat(p.avg_entry_price),
|
||||
current_price: parseFloat(p.current_price),
|
||||
market_value: parseFloat(p.market_value),
|
||||
unrealized_pl: parseFloat(p.unrealized_pl),
|
||||
}))
|
||||
);
|
||||
} catch (error) {
|
||||
|
||||
@@ -12,9 +12,8 @@ export async function loader({ request, params }: { request: Request; params: {
|
||||
const ticker = params.ticker?.toUpperCase();
|
||||
const url = new URL(request.url);
|
||||
const timeframe = url.searchParams.get("timeframe") || "1D";
|
||||
const limit = parseInt(url.searchParams.get("limit") || "30", 10);
|
||||
const range = url.searchParams.get("range") || "1M"; // 1D, 1W, 1M, 3M, 1Y, 3Y, ALL
|
||||
|
||||
console.log(`API quote/${ticker}: loader called with timeframe=${timeframe}, limit=${limit}`);
|
||||
if (!ticker) {
|
||||
return Response.json({ error: "Ticker is required" }, { status: 400 });
|
||||
}
|
||||
@@ -25,52 +24,51 @@ export async function loader({ request, params }: { request: Request; params: {
|
||||
try {
|
||||
const trade = await alpaca.getLatestTrade(ticker);
|
||||
price = (trade as { Price?: number }).Price || 0;
|
||||
console.log(`API quote/${ticker}: latest trade price = ${price}`);
|
||||
} catch (tradeErr) {
|
||||
console.error(`API quote/${ticker}: getLatestTrade failed`, tradeErr);
|
||||
}
|
||||
|
||||
// Calculate start date based on timeframe
|
||||
// Calculate start date based on range
|
||||
const startDate = new Date();
|
||||
const isIntraday = ["1Min", "5Min", "15Min", "30Min", "1H"].includes(timeframe);
|
||||
|
||||
if (timeframe === "1D") {
|
||||
startDate.setDate(startDate.getDate() - Math.min(limit, 30));
|
||||
} else if (timeframe === "1W") {
|
||||
startDate.setDate(startDate.getDate() - (limit * 7));
|
||||
} else if (timeframe === "1M") {
|
||||
startDate.setMonth(startDate.getMonth() - limit);
|
||||
if (range === "1D") {
|
||||
startDate.setDate(startDate.getDate() - 1);
|
||||
} else if (range === "1W") {
|
||||
startDate.setDate(startDate.getDate() - 7);
|
||||
} else if (range === "1M") {
|
||||
startDate.setMonth(startDate.getMonth() - 1);
|
||||
} else if (range === "3M") {
|
||||
startDate.setMonth(startDate.getMonth() - 3);
|
||||
} else if (range === "1Y") {
|
||||
startDate.setFullYear(startDate.getFullYear() - 1);
|
||||
} else if (range === "3Y") {
|
||||
startDate.setFullYear(startDate.getFullYear() - 3);
|
||||
} else if (range === "ALL") {
|
||||
startDate.setFullYear(startDate.getFullYear() - 10); // Max 10 years
|
||||
} else if (isIntraday) {
|
||||
startDate.setDate(startDate.getDate() - Math.floor(limit / 5));
|
||||
startDate.setDate(startDate.getDate() - 30); // Default 30 days for intraday
|
||||
}
|
||||
|
||||
const barsOptions: any = { timeframe, limit };
|
||||
if (timeframe !== "1Min" && timeframe !== "5Min") {
|
||||
const barsOptions: any = { timeframe, limit: 1000 }; // High limit for time range
|
||||
if (!isIntraday && range !== "ALL") {
|
||||
barsOptions.start = startDate.toISOString().split('T')[0];
|
||||
} else if (!isIntraday) {
|
||||
barsOptions.start = startDate.toISOString().split('T')[0];
|
||||
}
|
||||
|
||||
console.log(`API quote/${ticker}: calling getBarsV2 with timeframe=${timeframe}, limit=${limit}`);
|
||||
const bars = await alpaca.getBarsV2(ticker, barsOptions);
|
||||
console.log(`API quote/${ticker}: getBarsV2 returned`, typeof bars, bars?.constructor?.name);
|
||||
|
||||
// Convert async generator to array
|
||||
// Alpaca v2 API returns AlpacaBar with capitalized property names
|
||||
const barsArray = [];
|
||||
try {
|
||||
for await (const bar of bars) {
|
||||
console.log(`API quote/${ticker}: received bar =`, JSON.stringify(bar));
|
||||
barsArray.push(bar);
|
||||
}
|
||||
} catch (genErr) {
|
||||
console.error(`API quote/${ticker}: error iterating bars`, genErr);
|
||||
}
|
||||
|
||||
console.log(`API quote/${ticker}: raw bars count = ${barsArray.length}`);
|
||||
if (barsArray.length > 0) {
|
||||
console.log(`API quote/${ticker}: first bar =`, JSON.stringify(barsArray[0]));
|
||||
} else {
|
||||
console.log(`API quote/${ticker}: no bars returned from Alpaca, generator may be empty`);
|
||||
}
|
||||
|
||||
// Transform to chart format
|
||||
const transformedBars = barsArray.map((bar: any) => {
|
||||
@@ -91,8 +89,6 @@ export async function loader({ request, params }: { request: Request; params: {
|
||||
v: volume,
|
||||
};
|
||||
}).filter((bar: any) => bar.o > 0 && bar.h > 0 && bar.l > 0 && bar.c > 0);
|
||||
|
||||
console.log(`API quote/${ticker}: returning ${transformedBars.length} bars`);
|
||||
|
||||
return Response.json({
|
||||
ticker,
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
import Alpaca from "@alpacahq/alpaca-trade-api";
|
||||
|
||||
const alpaca = new Alpaca({
|
||||
keyId: process.env.ALPACA_API_KEY!,
|
||||
secretKey: process.env.ALPACA_SECRET_KEY!,
|
||||
baseUrl: process.env.ALPACA_BASE_URL || "https://paper-api.alpaca.markets",
|
||||
dataBaseUrl: process.env.ALPACA_DATA_URL || "https://data.alpaca.markets",
|
||||
retryOnError: false,
|
||||
});
|
||||
|
||||
export async function loader({ request }: { request: Request }) {
|
||||
const url = new URL(request.url);
|
||||
const ticker = url.searchParams.get("ticker")?.toUpperCase() || "AAPL";
|
||||
|
||||
try {
|
||||
// Test different timeframes
|
||||
const timeframes = ["1Day", "1Min", "5Min"];
|
||||
const results: any = {};
|
||||
|
||||
for (const tf of timeframes) {
|
||||
try {
|
||||
console.log(`test-alpaca: testing ${ticker} with timeframe ${tf}`);
|
||||
const bars = await alpaca.getBarsV2(ticker, {
|
||||
timeframe: tf as any,
|
||||
limit: 3,
|
||||
});
|
||||
|
||||
const barsArray = [];
|
||||
for await (const bar of bars) {
|
||||
barsArray.push(bar);
|
||||
}
|
||||
results[tf] = { count: barsArray.length, sample: barsArray[0] };
|
||||
console.log(`test-alpaca: ${tf} -> ${barsArray.length} bars`);
|
||||
} catch (e) {
|
||||
results[tf] = { error: e instanceof Error ? e.message : String(e) };
|
||||
}
|
||||
}
|
||||
|
||||
// Test popular stocks
|
||||
const symbols = ["AAPL", "MSFT", "SPY", "QQQ"];
|
||||
const symbolResults: any = {};
|
||||
|
||||
const startDate = new Date();
|
||||
startDate.setDate(startDate.getDate() - 30);
|
||||
const start = startDate.toISOString().split('T')[0];
|
||||
|
||||
for (const sym of symbols) {
|
||||
try {
|
||||
const bars = await alpaca.getBarsV2(sym, {
|
||||
timeframe: "1D",
|
||||
limit: 3,
|
||||
start,
|
||||
});
|
||||
const barsArray = [];
|
||||
for await (const bar of bars) barsArray.push(bar);
|
||||
symbolResults[sym] = barsArray.length;
|
||||
} catch (e) {
|
||||
symbolResults[sym] = e instanceof Error ? e.message : String(e);
|
||||
}
|
||||
}
|
||||
|
||||
return Response.json({
|
||||
ticker,
|
||||
timeframeResults: results,
|
||||
symbolResults,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("test-alpaca error:", error);
|
||||
return Response.json({
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
ticker
|
||||
}, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user