Add tests for Alpaca Historical Bars API

- Implemented tests for fetching historical bars for AAPL with different timeframes (1D, 5Min, 1H).
- Verified response structure and data integrity for each timeframe.
- Ensured that the API returns valid data and appropriate status for the requests.
This commit is contained in:
2026-05-14 12:50:14 +02:00
parent d1a84325ae
commit cc22174b78
13 changed files with 384 additions and 59 deletions
+26 -6
View File
@@ -10,26 +10,46 @@ export default function TradingViewChart({ ticker, data }: TradingViewChartProps
const containerRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!containerRef.current) return;
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, {
width: containerRef.current.clientWidth,
height: 400,
autoSize: true,
});
const candlestickSeries = chart.addSeries(LightweightCharts.CandlestickSeries);
const candlestickSeries = chart.addSeries(LightweightCharts.CandlestickSeries, {
upColor: "#26a69a",
downColor: "#ef5350",
borderUpColor: "#26a69a",
borderDownColor: "#ef5350",
wickUpColor: "#26a69a",
wickDownColor: "#ef5350",
});
if (data && data.length > 0) {
candlestickSeries.setData(data);
console.log(`TradingViewChart: setting data for ${ticker}`, data.slice(0, 3));
try {
candlestickSeries.setData(data);
console.log(`TradingViewChart: data set successfully for ${ticker}`);
} catch (err) {
console.error(`TradingViewChart: error setting data for ${ticker}`, err);
}
} else {
console.log(`TradingViewChart: no data to set for ${ticker}`);
}
return () => chart.remove();
}, [data]);
}, [data, ticker]);
return (
<div className="bg-white rounded-xl shadow-lg p-4">
<h3 className="text-lg font-bold mb-3">{ticker} Price Chart</h3>
<div ref={containerRef} />
<div ref={containerRef} className="w-full" />
</div>
);
}