2e22fd5635
- Add /api/alpaca/orders endpoint for order history - Add TradingView chart component for candlestick visualization - Add /analyze/:ticker route with position and orders display - Make ticker cells in analyze page clickable for navigation
18 lines
525 B
TypeScript
18 lines
525 B
TypeScript
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",
|
|
retryOnError: false,
|
|
});
|
|
|
|
export async function loader() {
|
|
try {
|
|
const orders = await alpaca.getOrders();
|
|
return Response.json({ orders });
|
|
} catch (error) {
|
|
console.error("Alpaca orders error:", error);
|
|
return Response.json({ orders: [] }, { status: 500 });
|
|
}
|
|
} |