feat(chart): candle build indicator as direction line #1

Open
u1 wants to merge 31 commits from feat/candle-build-indicator into main
Showing only changes of commit b0c7806cb6 - Show all commits

View File

@@ -14,6 +14,7 @@ type Params = {
type Result = {
candles: Candle[];
indicators: ChartIndicators;
meta: { tf: string; bucketSeconds: number } | null;
loading: boolean;
error: string | null;
refresh: () => Promise<void>;
@@ -22,6 +23,7 @@ type Result = {
export function useChartData({ symbol, source, tf, limit, pollMs }: Params): Result {
const [candles, setCandles] = useState<Candle[]>([]);
const [indicators, setIndicators] = useState<ChartIndicators>({});
const [meta, setMeta] = useState<{ tf: string; bucketSeconds: number } | null>(null);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const inFlight = useRef(false);
@@ -34,6 +36,7 @@ export function useChartData({ symbol, source, tf, limit, pollMs }: Params): Res
const res = await fetchChart({ symbol, source, tf, limit });
setCandles(res.candles);
setIndicators(res.indicators);
setMeta(res.meta);
setError(null);
} catch (e: any) {
setError(String(e?.message || e));
@@ -50,8 +53,7 @@ export function useChartData({ symbol, source, tf, limit, pollMs }: Params): Res
useInterval(() => void fetchOnce(), pollMs);
return useMemo(
() => ({ candles, indicators, loading, error, refresh: fetchOnce }),
[candles, indicators, loading, error, fetchOnce]
() => ({ candles, indicators, meta, loading, error, refresh: fetchOnce }),
[candles, indicators, meta, loading, error, fetchOnce]
);
}