Symbols
API reference for the symbol search dialog, custom symbol sections, and symbology helper functions.
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 | nullFrom @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): SymbolMarketSee 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): () => voidSee 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): stringFrom @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 | nullSee 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): stringFrom @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;
}| Member | Type | Description |
|---|---|---|
constructor | (ctx: WidgetContext, opts?: SymbolPickerOptions) | |
isOpen | boolean | |
open() | (opts?: SymbolPickerOpenOptions) => void | |
close() | () => void | |
type() | (text: string) => void | Text 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;
}| Member | Type | Description |
|---|---|---|
open() | (opts?: SymbolPickerOpenOptions) => void | |
close() | () => void | |
isOpen | boolean | |
destroy() | () => void | |
type?() | (text: string) => void | Text 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;
}| Member | Type | Description |
|---|---|---|
query? | string | The search to open on. |
mode? | SymbolPickerMode | chart (default): a pick opens it on the chart. watchlist: rows add and remove. select: report the pick. |
onSelect? | (symbol: string, descriptor: SymbolDescriptor) => void | Called with the picked symbol (venue-pinned: binance:BTCUSDT, NASDAQ:AAPL). |
isListed? | (symbol: string) => boolean | Watchlist 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;
}| Member | Type | Description |
|---|---|---|
inspector? | boolean | The inspector beside the results (default true). |
quotes? | QuoteSource | null | The inspector's quote. Default: none (the quote section is left out). |
sparkline? | boolean | The quote's sparkline of recent closes, under the price (default true). |
venueIcon? | (venue: string) => string | undefined | A 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;
}| Member | Type | Description |
|---|---|---|
id | string | |
order? | number | Sections 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;
}| Member | Type | Description |
|---|---|---|
shell | WidgetContext | |
pool() | () => readonly SymbolDescriptor[] | Every symbol the providers list. |
select() | (symbol: SymbolDescriptor) => void | Pick 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;
}| Member | Type | Description |
|---|---|---|
text | string | |
tab? | string | |
venue? | string | null | Only this venue (venueOf, case-insensitive). |
limit? | number |
SymbolTab
interface SymbolTab {
id: string;
label: string;
markets: readonly SymbolMarket[] | null;
}| Member | Type | Description |
|---|---|---|
id | string | |
label | string | |
markets | readonly SymbolMarket[] | null | The 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.