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();
|
||||
|
||||
Reference in New Issue
Block a user