Skip to main content

IWatchListApi

Interface

An API object for interacting with the Watchlist widget. The Watchlist is a widget that allows users to track price movements and volume of specific financial instruments in real-time. Watchlists also allow users to quickly switch between the symbols. The Watchlist widget is displayed on the widget panel on the right side of the chart.

Notes about watchlist contents

Watchlist items should be symbol names which your datafeed resolveSymbol method can resolve. This means that generally shorter names such as AAPL can be used if your datafeed understands it. However, it is recommend that you provide the symbol names as they appear within the LibrarySymbolInfo object, for example, NASDAQ:AAPL.

Methods

createList

Create a list of symbols with listName name. If the listName parameter is not provided or there is no WatchList then null will be returned;

Signature

createList(listName?: string, symbols?: string[]) => WatchListSymbolList

Parameters

NameTypeDescription
listName?stringname for the watchlist
symbols?string[]Symbol IDs for the watchlist. Any list item that has the ### prefix is considered a section divider in the watchlist.

Returns

WatchListSymbolList

WatchListSymbolList


defaultList

Get a default list of symbols.

Signature

defaultList() => string[]

Returns

default list of symbols

string[]


deleteList

Delete a watchlist of symbols

Signature

deleteList(listId: string) => void

Parameters

NameTypeDescription
listIdstringwatchlist ID

Returns

void


getActiveListId

Get the ID of the current watchlist. If there is no WatchList then null will be returned.

Signature

getActiveListId() => string

Returns

id of active watchlist

string


getAllLists

Get all watchlists. If there is no WatchList then null will be returned.

Signature

getAllLists() => WatchListSymbolListMap

Returns

object of all watchlists

WatchListSymbolListMap


getList

Get a list of symbols. If the id parameter is not provided, the current list will be returned. If there is no watchList, null will be returned.

Signature

getList(id?: string) => string[]

Parameters

NameTypeDescription
id?stringWatchlist ID

Returns

list of symbols for watchlist

string[]


onActiveListChanged

Subscription for when the active watchlist is changed to a different list. Use the subscribe method of the returned ISubscription object to subscribe to the notifications.

Signature

onActiveListChanged() => ISubscription<EmptyCallback>

Returns

ISubscription<EmptyCallback>


onListAdded

Subscription for when a new list is added to the watchlist widget. Use the subscribe method of the returned ISubscription object to subscribe to the notifications.

Signature

onListAdded() => ISubscription<WatchListSymbolListAddedCallback>

Returns

ISubscription<WatchListSymbolListAddedCallback>


onListChanged

Subscription for when the symbols of the active watchlist are changed. Use the subscribe method of the returned ISubscription object to subscribe to the notifications.

Signature

onListChanged() => ISubscription<WatchListSymbolListChangedCallback>

Returns

ISubscription<WatchListSymbolListChangedCallback>


onListRemoved

Subscription for when a list is removed from the watchlist widget. Use the subscribe method of the returned ISubscription object to subscribe to the notifications.

Signature

onListRemoved() => ISubscription<WatchListSymbolListRemovedCallback>

Returns

ISubscription<WatchListSymbolListRemovedCallback>


onListRenamed

Subscription for when a list is renamed. Use the subscribe method of the returned ISubscription object to subscribe to the notifications.

Signature

onListRenamed() => ISubscription<WatchListSymbolListRenamedCallback>

Returns

ISubscription<WatchListSymbolListRenamedCallback>


renameList

Rename the watchlist.

Signature

renameList(listId: string, newName: string) => void

Parameters

NameTypeDescription
listIdstringID of the watchlist
newNamestringNew name to set for the watchlist

Returns

void


saveList

Save a list of symbols.

Signature

saveList(list: WatchListSymbolList) => boolean

Parameters

NameType
listWatchListSymbolList

Returns

If there is no watchList or an equivalent list already exists, false will be returned. Otherwise, true will be returned.

boolean


setActiveList

Make the watchlist with the specified id active.

Signature

setActiveList(id: string) => void

Parameters

NameTypeDescription
idstringwatchlist ID

Returns

void


setList

Obsolete. Use updateList instead.

Set the list of symbols for the watchlist. It will replace the entire list.

Signature

setList(symbols: string[]) => void

Parameters

NameTypeDescription
symbolsstring[]symbol IDs

Returns

void


updateList

Edit the list of symbols for a watchlist.

Signature

updateList(listId: string, symbols: string[]) => void

Parameters

NameTypeDescription
listIdstringID of the watchlist
symbolsstring[]Symbols to be set for the watchlist. Any list item that has the ### prefix is considered a section divider in the watchlist.

Returns

void