goldenChat base source add
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import type { Timeframe, OHLCVBar } from '../types';
|
||||
import { useUpbitData, type WsStatus } from './useUpbitData';
|
||||
import { useStompChartData } from './useStompChartData';
|
||||
|
||||
export type ChartRealtimeSource = 'BACKEND_STOMP' | 'UPBIT_DIRECT';
|
||||
|
||||
interface Options {
|
||||
onTickUpdate: (bar: OHLCVBar) => void;
|
||||
onNewCandle: (bar: OHLCVBar) => void;
|
||||
enabled?: boolean;
|
||||
deepObvHistory?: boolean;
|
||||
source?: ChartRealtimeSource;
|
||||
}
|
||||
|
||||
export function useChartRealtimeData(
|
||||
market: string,
|
||||
timeframe: Timeframe,
|
||||
opts: Options,
|
||||
) {
|
||||
const useStomp = opts.source !== 'UPBIT_DIRECT';
|
||||
const stomp = useStompChartData(market, timeframe, {
|
||||
onTickUpdate: opts.onTickUpdate,
|
||||
onNewCandle: opts.onNewCandle,
|
||||
enabled: opts.enabled !== false && useStomp,
|
||||
});
|
||||
const upbit = useUpbitData(market, timeframe, {
|
||||
onTickUpdate: opts.onTickUpdate,
|
||||
onNewCandle: opts.onNewCandle,
|
||||
enabled: opts.enabled !== false && !useStomp,
|
||||
deepObvHistory: opts.deepObvHistory,
|
||||
});
|
||||
return useStomp ? stomp : upbit;
|
||||
}
|
||||
|
||||
export type { WsStatus };
|
||||
Reference in New Issue
Block a user