UNPKG

@drift-labs/common

Version:

Common functions for Drift

34 lines (33 loc) 1.09 kB
import { CandleResolution } from '@drift-labs/sdk'; import { JsonCandle, JsonTrade, MarketSymbol, UIEnv } from '../types'; import { Observable } from 'rxjs'; type DataApiWsSubscriptionConfig = { resolution: CandleResolution; marketSymbol: MarketSymbol; env: UIEnv; }; export declare class DataApiWsClient { readonly config: DataApiWsSubscriptionConfig; private readonly candleSubject; private readonly tradesSubject; private readonly _candleObservable; private readonly _tradesObservable; private multiplexSubscription; constructor(config: DataApiWsSubscriptionConfig); private handleWsMessage; private handleError; private handleClose; subscribe: () => Promise<void>; unsubscribe: () => void; /** * Get the candle updates stream * @returns An observable that emits candle updates */ get candlesObservable(): Observable<JsonCandle>; /** * Get the trade updates stream * @returns An observable that emits trade updates */ get tradesObservable(): Observable<JsonTrade[]>; } export {};