Broker-agnostic market-data source. The chart depends only on this. subscribeBars is optional: a history-only feed (e.g. OpenAlgoDataFeed) omits it, while a live feed (OpenAlgoLiveDataFeed, or your own) implements it.

interface DataFeed {
    getBars(req: BarsRequest): Promise<Bar[]>;
    getBarsPage(req: BarsPageRequest): Promise<BarsPage>;
    getCachedBars(req: BarsRequest): Promise<undefined | Bar[]>;
    subscribeBars(
        req: BarsRequest,
        onBar: (bar: Bar, meta?: LiveBarMeta) => void,
        opts?: BarSubscriptionOptions,
    ): UnsubscribeFn;
    subscribeDepth(
        req: BarsRequest,
        onDepth: (depth: MarketDepth) => void,
        opts?: { depthLevel?: number },
    ): UnsubscribeFn;
}

Implemented by

Methods

  • opts.depthLevel requests a book depth (broker-dependent: 5/20/30/50). Named on the interface so a caller holding a DataFeed can ask for one; an implementation is free to ignore it and send the broker's default.

    Parameters

    Returns UnsubscribeFn