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

Symbols

API reference for the symbol search dialog, custom symbol sections, and symbology helper functions.

View as Markdown

This page documents the symbol search dialog, custom symbol section descriptors, and helper functions for parsing market categories and venues from symbol identifiers.

Import symbols on this page from @luxalgo/vela-pro. Related guides: Symbol search, Symbology.

Feature enabler for this area (enableSymbolSearch) is documented on Enablers and options.

Functions

defaultMemberOf

The member a group pick loads: its single default, else its first member.

function defaultMemberOf(
    pool: readonly SymbolDescriptor[],
    group: SymbolDescriptor,
): SymbolDescriptor | null

From @luxalgo/vela/plugin: SymbolDescriptor.

foldGroups

Drop a member whose group's row is already listed above it: the group stands for its members.

function foldGroups(list: readonly SymbolDescriptor[]): SymbolDescriptor[]

From @luxalgo/vela/plugin: SymbolDescriptor.

marketOf

function marketOf(d: SymbolDescriptor): SymbolMarket

See also: SymbolMarket. From @luxalgo/vela/plugin: SymbolDescriptor.

otherListings

The same instrument elsewhere: a stock's listing on another venue (same ticker), a crypto asset's pairs on other venues and its perpetuals (most liquid quotes first).

function otherListings(
    d: SymbolDescriptor,
    pool: readonly SymbolDescriptor[],
    max?: number,
): SymbolDescriptor[]

Default: max = 5.

From @luxalgo/vela/plugin: SymbolDescriptor.

registerSymbolPickerSection

Add (or replace, by id) a section of the symbol picker's inspector. Returns the removal.

function registerSymbolPickerSection(section: SymbolPickerSection): () => void

See also: SymbolPickerSection.

searchSymbols

The ranked rows for a query: Vela's ranking over the tab's pool, futures contracts folded under their root.

function searchSymbols(
    pool: readonly SymbolDescriptor[],
    q: SymbolQuery,
    top?: readonly string[],
): { rows: SymbolDescriptor[]; exhausted: boolean }

Default: top = TOP_SYMBOLS.

See also: SymbolQuery. From @luxalgo/vela/plugin: SymbolDescriptor.

symbolOf

The symbol string a pick commits: venue-pinned, so a ticker listed twice never re-resolves elsewhere.

function symbolOf(d: SymbolDescriptor): string

From @luxalgo/vela/plugin: SymbolDescriptor.

symbolPicker

The symbol picker of a shell (ctx or its host element), once enableSymbolSearch ran.

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

function symbolPicker(shell: WidgetContext | HTMLElement): SymbolPickerLike | null

See also: SymbolPickerLike. From @luxalgo/vela/plugin: WidgetContext.

venueOf

The row's venue: the listing prefix the data declares, else the provider name.

function venueOf(d: SymbolDescriptor): string

From @luxalgo/vela/plugin: SymbolDescriptor.

Classes

SymbolPicker class

class SymbolPicker implements SymbolPickerLike {
    constructor(ctx: WidgetContext, opts?: SymbolPickerOptions);
    readonly isOpen: boolean;
    open(opts?: SymbolPickerOpenOptions): void;
    close(): void;
    type(text: string): void;
    destroy(): void;
}
MemberTypeDescription
constructor(ctx: WidgetContext, opts?: SymbolPickerOptions)
isOpenboolean
open()(opts?: SymbolPickerOpenOptions) => void
close()() => void
type()(text: string) => voidText typed at the chart while the picker opens: it extends the query.
destroy()() => void

See also: SymbolPickerLike, SymbolPickerOpenOptions, SymbolPickerOptions. From @luxalgo/vela/plugin: WidgetContext.

Interfaces and types

SymbolMarket

type SymbolMarket =
    | 'stocks'
    | 'etfs'
    | 'crypto'
    | 'perp'
    | 'futures'
    | 'forex'
    | 'commodities'
    | 'economic'
    | 'other';

SymbolPickerLike

What Pro opens for "search a symbol": implement it to swap in a picker of your own.

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

interface SymbolPickerLike {
    open(opts?: SymbolPickerOpenOptions): void;
    close(): void;
    readonly isOpen: boolean;
    destroy(): void;
    type?(text: string): void;
}
MemberTypeDescription
open()(opts?: SymbolPickerOpenOptions) => void
close()() => void
isOpenboolean
destroy()() => void
type?()(text: string) => voidText typed at the chart while the picker opens; it extends the query (else the picker reopens on it).

See also: SymbolPickerOpenOptions.

SymbolPickerMode

type SymbolPickerMode = 'chart' | 'watchlist' | 'select';

SymbolPickerOpenOptions

interface SymbolPickerOpenOptions {
    query?: string;
    mode?: SymbolPickerMode;
    onSelect?: (symbol: string, descriptor: SymbolDescriptor) => void;
    isListed?: (symbol: string) => boolean;
    onToggle?: (symbol: string, descriptor: SymbolDescriptor) => void;
}
MemberTypeDescription
query?stringThe search to open on.
mode?SymbolPickerModechart (default): a pick opens it on the chart. watchlist: rows add and remove. select: report the pick.
onSelect?(symbol: string, descriptor: SymbolDescriptor) => voidCalled with the picked symbol (venue-pinned: binance:BTCUSDT, NASDAQ:AAPL).
isListed?(symbol: string) => booleanWatchlist mode: whether a symbol is listed, and toggling it.
onToggle?(symbol: string, descriptor: SymbolDescriptor) => void

See also: SymbolPickerMode. From @luxalgo/vela/plugin: SymbolDescriptor.

SymbolPickerOptions

interface SymbolPickerOptions {
    inspector?: boolean;
    quotes?: QuoteSource | null;
    sparkline?: boolean;
    venueIcon?: (venue: string) => string | undefined;
}
MemberTypeDescription
inspector?booleanThe inspector beside the results (default true).
quotes?QuoteSource | nullThe inspector's quote. Default: none (the quote section is left out).
sparkline?booleanThe quote's sparkline of recent closes, under the price (default true).
venueIcon?(venue: string) => string | undefinedA venue's logo (NASDAQ, binance).

See also: QuoteSource.

SymbolPickerSection

A section of the picker's inspector, for the highlighted symbol.

interface SymbolPickerSection {
    id: string;
    order?: number;
    render(symbol: SymbolDescriptor, ctx: SymbolPickerSectionContext): Node | null;
}
MemberTypeDescription
idstring
order?numberSections sort by order (the built-in ones: quote 0, details 10, listings 50).
render()(symbol: SymbolDescriptor, ctx: SymbolPickerSectionContext) => Node | null

See also: SymbolPickerSectionContext. From @luxalgo/vela/plugin: SymbolDescriptor.

SymbolPickerSectionContext

interface SymbolPickerSectionContext {
    shell: WidgetContext;
    pool(): readonly SymbolDescriptor[];
    select(symbol: SymbolDescriptor): void;
    logo(symbol: SymbolDescriptor, size?: number): HTMLElement;
}
MemberTypeDescription
shellWidgetContext
pool()() => readonly SymbolDescriptor[]Every symbol the providers list.
select()(symbol: SymbolDescriptor) => voidPick a symbol, as a click on its row would.
logo()(symbol: SymbolDescriptor, size?: number) => HTMLElement

From @luxalgo/vela/plugin: SymbolDescriptor, WidgetContext.

SymbolQuery

interface SymbolQuery {
    text: string;
    tab?: string;
    venue?: string | null;
    limit?: number;
}
MemberTypeDescription
textstring
tab?string
venue?string | nullOnly this venue (venueOf, case-insensitive).
limit?number

SymbolTab

interface SymbolTab {
    id: string;
    label: string;
    markets: readonly SymbolMarket[] | null;
}
MemberTypeDescription
idstring
labelstring
marketsreadonly SymbolMarket[] | nullThe markets the tab lists; null lists every market.

See also: SymbolMarket.

Constants

MARKET_LABELS

const MARKET_LABELS: Record<SymbolMarket, string>;

See also: SymbolMarket.

SYMBOL_TABS

const SYMBOL_TABS: readonly SymbolTab[];

See also: SymbolTab.

On this page