Vela, our next-generation charting platform, is live at vela.luxalgo.com.
LuxAlgo

Data feeds

API reference for extended data provider interfaces covering footprint slices, market depth, trades, and quotes.

View as Markdown

This page documents the extended feed interfaces that a DataProvider can implement beyond OHLCV candles, including footprint slices, Level 2 market depth, trade tape streams, quotes, and the in-memory footprint store.

Import symbols on this page from @luxalgo/vela-pro. Related guides: Data connectivity overview, Footprint data, Quotes and market depth.

Functions

blankQuote

Also exported from @luxalgo/vela-pro-watchlist, @luxalgo/vela-pro/plugin.

function blankQuote(symbol: string): Quote

See also: Quote.

footprintFeedFor

The shared order-flow feed behind a chart symbol, or null when its provider serves none. The entry point for any indicator that reads footprints: everything read through it is fetched once and shared with every other consumer of that provider.

function footprintFeedFor(
    data: FootprintFeedSurface,
    symbol: string,
): { feed: FootprintStore; ticker: string; provider: string } | null

See also: FootprintFeedSurface, FootprintStore.

footprintStore

The shared store of a footprint-capable provider: one per provider instance.

function footprintStore(feed: FootprintFeed): FootprintStore

See also: FootprintFeed, FootprintStore.

groupLevels

Group book levels into step-wide buckets (bids floor, asks ceil), summing their sizes.

Also exported from @luxalgo/vela-pro/plugin.

function groupLevels(levels: readonly BookLevel[], step: number, side: 'bid' | 'ask'): BookLevel[]

See also: BookLevel.

hasDepthFeed

Also exported from @luxalgo/vela-pro/plugin.

function hasDepthFeed(p: unknown): p is DepthFeed

See also: DepthFeed.

hasFootprints

Narrow a registered provider to its order-flow surface, if it has one.

function hasFootprints(p: DataProvider | undefined): p is DataProvider & FootprintFeed

See also: FootprintFeed. From @luxalgo/vela/plugin: DataProvider.

withChange

Chg and Chg% from the last price and the previous close.

Also exported from @luxalgo/vela-pro-watchlist, @luxalgo/vela-pro/plugin.

function withChange(q: Quote): Quote

See also: Quote.

Classes

BookState

One book kept from a snapshot and its level changes (a size of 0 removes a level): the shape most venues send.

class BookState {
    tick: number;
    time: number;
    reset(
        bids: ReadonlyArray<readonly [number, number]>,
        asks: ReadonlyArray<readonly [number, number]>,
        tick: number,
        time?: number,
    ): void;
    update(
        bids: ReadonlyArray<readonly [number, number]>,
        asks: ReadonlyArray<readonly [number, number]>,
        time?: number,
    ): void;
    snapshot(depth?: number): BookSnapshot;
}

Defaults: reset(time = Date.now()), update(time = Date.now()), snapshot(depth = 50).

See also: BookSnapshot.

FootprintStore class

class FootprintStore implements FootprintFeed {
    constructor(source: FootprintFeed);
    footprintCaps(ticker: string): FootprintCaps;
    getFootprints(ticker: string, range: FootprintRange, sliceMs?: number): Promise<FootprintBatch>;
    subscribeFootprints(
        ticker: string,
        since: number,
        onSlices: (slices: FootprintSlice[]) => void,
    ): () => void;
    peek(
        ticker: string,
        range: { from: number; to: number; session?: string },
        sliceMs?: number,
    ): FootprintPeek;
    stats(): FootprintStoreStats;
    clear(): void;
}
MemberTypeDescription
constructor(source: FootprintFeed)
footprintCaps()(ticker: string) => FootprintCapsFetch-planner capabilities for one ticker.
getFootprints()(ticker: string, range: FootprintRange, sliceMs?: number) => Promise<FootprintBatch>Pre-aggregated one-minute footprint slices for [range.from, range.to]. sliceMs is a granularity HINT (the chart's bar duration): a multi-timeframe source may serve bucket slices that divide it (fewer, bigger slices, same sums). Returns a completeness-aware batch (see FootprintBatch).
subscribeFootprints()(ticker: string, since: number, onSlices: (slices: FootprintSlice[]) => void) => () => voidLive footprint slices from since onward. Deliveries are FULL-STATE snapshots per slice (the forming minute grows across deliveries): consumers replace by slice time, never accumulate. Returns an unsubscribe function.
peek()(ticker: string, range: { from: number; to: number; session?: string }, sliceMs?: number) => FootprintPeekWhat the store holds for (ticker, session, sliceMs) inside [from, to]: no request.
stats()() => FootprintStoreStats
clear()() => voidForget every kept interval (live subscriptions are untouched).

See also: FootprintBatch, FootprintCaps, FootprintFeed, FootprintPeek, FootprintRange, FootprintSlice, FootprintStoreStats.

ProviderQuotes

Also exported from @luxalgo/vela-pro-watchlist, @luxalgo/vela-pro/plugin.

class ProviderQuotes implements QuoteSource {
    constructor(data: () => DataFacade | null);
    dailyBars(symbol: string, count: number): Promise<OHLCV[]>;
    watch(symbol: string, onQuote: (q: Quote) => void): () => void;
    peek(symbol: string): Quote | null;
    dispose(): void;
}

// Unexported supporting type referenced above
type DataFacade = WidgetContext['chart']['data'];
MemberTypeDescription
constructor(data: () => DataFacade | null)data: the registry to resolve symbols through (the active chart's).
dailyBars()(symbol: string, count: number) => Promise<OHLCV[]>Up to count daily bars of symbol, oldest first; the last may be today's, still forming. Rejects when no history can be had. Optional: without it, the figures read from daily history (period returns, drawdowns, correlations) stay empty.
watch()(symbol: string, onQuote: (q: Quote) => void) => () => voidFollow symbol's quote; onQuote gets every change. Returns the unsubscribe.
peek()(symbol: string) => Quote | nullThe latest quote held for symbol (null when nobody watches it).
dispose()() => void

See also: Quote, QuoteSource. From @luxalgo/vela/plugin: OHLCV, WidgetContext.

Interfaces and types

BookLevel

Also exported from @luxalgo/vela-pro/plugin.

interface BookLevel {
    price: number;
    size: number;
}

BookSnapshot

Also exported from @luxalgo/vela-pro/plugin.

interface BookSnapshot {
    bids: BookLevel[];
    asks: BookLevel[];
    tick: number;
    time: number;
}
MemberTypeDescription
bidsBookLevel[]Best first: highest bid first, lowest ask first.
asksBookLevel[]
ticknumberThe price increment the book is read at.
timenumber

See also: BookLevel.

DepthFeed

interface DepthFeed {
    subscribeBook?(
        ticker: string,
        onBook: (book: BookSnapshot) => void,
        opts?: { depth?: number; onError?: (reason: string) => void },
    ): DepthSubscription;
    subscribeTrades?(
        ticker: string,
        onTrades: (trades: TapeTrade[], history?: boolean) => void,
        opts?: { onError?: (reason: string) => void },
    ): DepthSubscription;
}
MemberTypeDescription
subscribeBook?()(ticker: string, onBook: (book: BookSnapshot) => void, opts?: { depth?: number; … (truncated; see declaration)Follow ticker's book; onBook gets the whole (top-depth) book after every change.
subscribeTrades?()(ticker: string, onTrades: (trades: TapeTrade[], history?: boolean) => void, … (truncated; see declaration)Follow ticker's trades; onTrades gets new prints, newest last (history marks a first backfill).

See also: BookSnapshot, DepthSubscription, TapeTrade.

DepthSubscription

Also exported from @luxalgo/vela-pro/plugin.

interface DepthSubscription {
    close(): void;
}

FootprintCaps

How the engine's fetch planner should treat this feed for one ticker.

interface FootprintCaps {
    bulkFetch: boolean;
    maxFetchSpanSec?: number;
}
MemberTypeDescription
bulkFetchbooleanOne request returns complete slices for a wide range at low cost (a pre-aggregated, server-cached source). The planner then keeps the whole visible range covered instead of rationing tiny chunks.
maxFetchSpanSec?numberCap on one viewport fetch window, in SECONDS (Infinity = uncapped: the visible range plus its pan buffer is the only bound).

FootprintFeed

The order-flow surface a footprint-capable provider exposes (beyond the core's port).

interface FootprintFeed {
    getFootprints(ticker: string, range: FootprintRange, sliceMs?: number): Promise<FootprintBatch>;
    subscribeFootprints(
        ticker: string,
        since: number,
        onSlices: (slices: FootprintSlice[]) => void,
    ): () => void;
    footprintCaps(ticker: string): FootprintCaps;
}
MemberTypeDescription
getFootprints()(ticker: string, range: FootprintRange, sliceMs?: number) => Promise<FootprintBatch>Pre-aggregated one-minute footprint slices for [range.from, range.to]. sliceMs is a granularity HINT (the chart's bar duration): a multi-timeframe source may serve bucket slices that divide it (fewer, bigger slices, same sums). Returns a completeness-aware batch (see FootprintBatch).
subscribeFootprints()(ticker: string, since: number, onSlices: (slices: FootprintSlice[]) => void) => () => voidLive footprint slices from since onward. Deliveries are FULL-STATE snapshots per slice (the forming minute grows across deliveries): consumers replace by slice time, never accumulate. Returns an unsubscribe function.
footprintCaps()(ticker: string) => FootprintCapsFetch-planner capabilities for one ticker.

See also: FootprintBatch, FootprintCaps, FootprintRange, FootprintSlice.

FootprintFeedSurface

What footprintFeedFor needs of a chart's data surface: structural, so any host context fits.

interface FootprintFeedSurface {
    resolve(symbol: string): { provider: string; ticker: string } | null;
    providerInstance(name: string): DataProvider | undefined;
}

From @luxalgo/vela/plugin: DataProvider.

FootprintPeek

A synchronous look at what the store holds for one series.

interface FootprintPeek {
    slices: FootprintSlice[];
    covered: Array<[number, number]>;
}
MemberTypeDescription
slicesFootprintSlice[]Kept slices inside the asked range, ascending.
coveredArray<[number, number]>The [from, to) stretches of the range the slices are authoritative for.

See also: FootprintSlice.

FootprintRange

A time range request, [from, to] epoch ms (either side optional).

interface FootprintRange {
    from?: number;
    to?: number;
    session?: string;
}
MemberTypeDescription
from?number
to?number
session?stringThe chart's trading session ('regular' | 'extended'): session markets store the extended superset and filter at serve time, so an RTH consumer must say so or the server's regular default decides. Ignored by continuous markets.

FootprintStoreStats

What the store did since it was created (diagnostics and tests).

interface FootprintStoreStats {
    upstreamRequests: number;
    memoryHits: number;
    sharedRequests: number;
    liveUpstreams: number;
    liveSubscribers: number;
    intervals: number;
    retainedLevels: number;
}
MemberTypeDescription
upstreamRequestsnumberRange requests sent to the underlying feed.
memoryHitsnumberAnswers served entirely from memory.
sharedRequestsnumberRequests that joined an identical one already in flight.
liveUpstreamsnumberUpstream live subscriptions currently open.
liveSubscribersnumberLive subscribers currently fed.
intervalsnumber
retainedLevelsnumber

Quote

One symbol's quote.

Also exported from @luxalgo/vela-pro-watchlist, @luxalgo/vela-pro/plugin.

interface Quote {
    symbol: string;
    last: number | null;
    prevClose: number | null;
    open: number | null;
    high: number | null;
    low: number | null;
    volume: number | null;
    change: number | null;
    changePercent: number | null;
    spark: number[];
    tick: number;
    updated: number;
    unresolved?: boolean;
}
MemberTypeDescription
symbolstring
lastnumber | null
prevClosenumber | nullThe previous session's close: what Chg and Chg% are measured from.
opennumber | null
highnumber | null
lownumber | null
volumenumber | null
changenumber | null
changePercentnumber | null
sparknumber[]Closes over the last day, oldest first.
ticknumberPrice increment, for formatting.
updatednumber
unresolved?booleanNo provider serves the symbol.

QuoteSource

Also exported from @luxalgo/vela-pro-watchlist, @luxalgo/vela-pro/plugin.

interface QuoteSource {
    watch(symbol: string, onQuote: (q: Quote) => void): () => void;
    dailyBars?(symbol: string, count: number): Promise<readonly OHLCV[]>;
}
MemberTypeDescription
watch()(symbol: string, onQuote: (q: Quote) => void) => () => voidFollow symbol's quote; onQuote gets every change. Returns the unsubscribe.
dailyBars?()(symbol: string, count: number) => Promise<readonly OHLCV[]>Up to count daily bars of symbol, oldest first; the last may be today's, still forming. Rejects when no history can be had. Optional: without it, the figures read from daily history (period returns, drawdowns, correlations) stay empty.

See also: Quote. From @luxalgo/vela/plugin: OHLCV.

TapeTrade

Also exported from @luxalgo/vela-pro/plugin.

interface TapeTrade {
    id: string;
    time: number;
    price: number;
    size: number;
    side: 'buy' | 'sell';
}
MemberTypeDescription
idstring
timenumber
pricenumber
sizenumber
side'buy' | 'sell'The taker's side.

On this page