# Symbol Search

The *Symbol Search* is a button on the top toolbar that opens a dialog containing a search box.
*Symbol Search* is used to search and display instruments that match the entered full or partial instrument name.

## Display symbols

The way symbols appear in the *Symbol Search* depends on how you provide the data.

- If you use the built-in [UDF adapter], you can either implement a symbol [group request] or a [single request].
    The first method is suitable when you have a short list of symbols.
- If you implement a custom datafeed via [Datafeed API], use the [`searchSymbols`] method to return all results at once.
    Alternatively, if you need to handle a large number of symbols efficiently, you can implement [`searchSymbolsPaginated`].
    This method loads results in pages on demand as the user scrolls down the list.

## Hide Symbol Search

If you do not want users to change the displayed instrument,
you can hide the *Symbol Search*.
To do this, include the `header_symbol_search` [featureset] in the [`disabled_features`] array.

## Open/close Symbol Search

To programmatically open the Symbol Search, call the [`executeActionById`] method with the `symbolSearch` action ID.

```js
widget.activeChart().executeActionById("symbolSearch");
```

To programmatically close the Symbol Search, call the [`closePopupsAndDialogs`] method.
This method closes any active dialog on the chart.

```js
widget.closePopupsAndDialogs();
```

## Set request delay

If you want to reduce the number of search requests when users enter symbol names in the search box,
you can set a request delay in milliseconds.
To do this, use the [`symbol_search_request_delay`] property of the [Widget Constructor].
You can check out the [Widget Constructor tutorial][tutorial-request-delay] on YouTube for an implementation example.

## Override symbol names

Sometimes symbol names can be too long/short or implicitly reflect the meaning of the symbol name.
In these cases, you can use the [`symbol_search_complete`] property of the [Widget Constructor].
This property overrides the entered symbol name with whatever human-friendly form you want.
The overridden symbol name will then be requested by your server and plotted.

You can check out the [Widget Constructor tutorial][tutorial-symbol-search-complete] on YouTube for an implementation example.

## Case-insensitive search

By default, all letters that users type are displayed in uppercase. To allow case-insensitive search, disable the [`uppercase_instrument_names`](../customization/Featuresets.md#uppercase_instrument_names) featureset.

## Filters

When users click *Symbol Search*, the search dialog appears.
The widget has predefined optional filters by symbol type and exchange.
To use them, pass a [`DatafeedConfiguration`] object with the [`symbols_types`] and [`exchanges`] properties
as a parameter to the callback of the [`onReady`] method.

## Symbol grouping

The search dialog can display symbols grouped by a root name.
For example, to group futures `ABC2023`, `ABC2024`, and `ABC2025` by the root name `ABC`,
provide a regular expression to the library.
The expression should consist of two capture groups,
where the first is the root name and the second is the expiration date.

To enable grouping, provide an object with regular expressions to parse symbol names in the [`symbols_grouping`] property
of the [`DatafeedConfiguration`] interface.
Then pass the `DatafeedConfiguration` object as a parameter to the callback of the [`onReady`] method.

## Display logos

If you want to display logos for symbols and exchanges within the search results, follow the steps below:

1. Enable the corresponding [featuresets][featureset]: `show_symbol_logos` and `show_exchange_logos`.
2. Provide URLs for symbols and exchanges in the [`logo_urls`] and [`exchange_logo`] properties
    of the [`SearchSymbolResultItem`] object.
    Pass the object as a parameter to the callback of the [`searchSymbols`] method.

## Enable spread operators

**Spread operators** are operators that allow comparison between a financial instrument, such as a stock,
and an additional variable, such as another financial instrument or a numerical value.

To display spread operators in the *Symbol Search*, include the [`show_spread_operators`] featureset in the [`enabled_features`] array.

![Spread operators in the Search Symbol](/img/spread-operators-in-symbol-search.png)

[`closePopupsAndDialogs`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.IChartingLibraryWidget#closepopupsanddialogs
[Datafeed API]: https://charting-library-docs.xstaging.tv/latest/connecting_data/datafeed-api.md
[`DatafeedConfiguration`]: /api/interfaces/Charting_Library.DatafeedConfiguration.md
[`disabled_features`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.ChartingLibraryWidgetOptions#disabled_features
[`enabled_features`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.ChartingLibraryWidgetOptions#enabled_features
[`exchange_logo`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.SearchSymbolResultItem#exchange_logo
[`exchanges`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.DatafeedConfiguration#exchanges
[`executeActionById`]: https://charting-library-docs.xstaging.tv/latest/ui_elements/Chart.md#execute-action-by-id
[featureset]: https://charting-library-docs.xstaging.tv/latest/customization/Featuresets.md
[`logo_urls`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.SearchSymbolResultItem#logo_urls
[`onReady`]: https://charting-library-docs.xstaging.tv/latest/connecting_data/datafeed-api/required-methods.md#onready
[`searchSymbols`]: https://charting-library-docs.xstaging.tv/latest/connecting_data/datafeed-api/required-methods.md#searchsymbols
[`searchSymbolsPaginated`]: https://charting-library-docs.xstaging.tv/latest/connecting_data/datafeed-api/additional-methods.md#searchsymbolspaginated
[`SearchSymbolResultItem`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.SearchSymbolResultItem
[`show_spread_operators`]: https://charting-library-docs.xstaging.tv/latest/customization/Featuresets.md#show_spread_operators
[group request]: https://charting-library-docs.xstaging.tv/latest/connecting_data/UDF.md#symbol-group-request
[single request]: https://charting-library-docs.xstaging.tv/latest/connecting_data/UDF.md#symbol-search
[`symbol_search_complete`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.ChartingLibraryWidgetOptions#symbol_search_complete
[`symbol_search_request_delay`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.ChartingLibraryWidgetOptions#symbol_search_request_delay
[`symbols_grouping`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.DatafeedConfiguration#symbols_grouping
[`symbols_types`]: https://charting-library-docs.xstaging.tv/latest/api/interfaces/Charting_Library.DatafeedConfiguration#symbols_types
[tutorial-request-delay]: https://www.youtube.com/watch?v=bdvmM3FNnSY&t=727s
[tutorial-symbol-search-complete]: https://www.youtube.com/watch?v=bdvmM3FNnSY&t=3606s
[UDF adapter]: https://charting-library-docs.xstaging.tv/latest/connecting_data/UDF.md
[Widget Constructor]: https://charting-library-docs.xstaging.tv/latest/configuration/Widget-Constructor.md

---

## Sitemap

- [All documentation pages](https://charting-library-docs.xstaging.tv/llms.txt)
- [Full page map with headings](https://charting-library-docs.xstaging.tv/docs_map.md)
