Interface: IWatchListApi
Charting Library.IWatchListApi
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
▸ createList(listName?
, symbols?
): WatchListSymbolList
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;
Parameters
Name | Type | Description |
---|---|---|
listName? | string | name 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
defaultList
▸ defaultList(): string
[]
Get a default list of symbols.
Returns
string
[]
default list of symbols
deleteList
▸ deleteList(listId
): void
Delete a watchlist of symbols
Parameters
Name | Type | Description |
---|---|---|
listId | string | watchlist ID |
Returns
void
getActiveListId
▸ getActiveListId(): string
Get the ID of the current watchlist. If there is no WatchList then null
will be returned.
Returns
string
id of active watchlist
getAllLists
▸ getAllLists(): WatchListSymbolListMap
Get all watchlists. If there is no WatchList then null
will be returned.
Returns
object of all watchlists
getList
▸ getList(id?
): string
[]
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.
Parameters
Name | Type | Description |
---|---|---|
id? | string | Watchlist ID |
Returns
string
[]
list of symbols for watchlist
onActiveListChanged
▸ onActiveListChanged(): ISubscription
<EmptyCallback
>
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.
Returns
onListAdded
▸ onListAdded(): ISubscription
<WatchListSymbolListAddedCallback
>
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.
Returns
ISubscription
<WatchListSymbolListAddedCallback
>
onListChanged
▸ onListChanged(): ISubscription
<WatchListSymbolListChangedCallback
>
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.
Returns
ISubscription
<WatchListSymbolListChangedCallback
>
onListRemoved
▸ onListRemoved(): ISubscription
<WatchListSymbolListRemovedCallback
>
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.
Returns
ISubscription
<WatchListSymbolListRemovedCallback
>
onListRenamed
▸ onListRenamed(): ISubscription
<WatchListSymbolListRenamedCallback
>
Subscription for when a list is renamed. Use the subscribe
method of the returned ISubscription object to subscribe to the notifications.
Returns
ISubscription
<WatchListSymbolListRenamedCallback
>
renameList
▸ renameList(listId
, newName
): void
Rename the watchlist.
Parameters
Name | Type | Description |
---|---|---|
listId | string | ID of the watchlist |
newName | string | New name to set for the watchlist |
Returns
void
saveList
▸ saveList(list
): boolean
Save a list of symbols.
Parameters
Name | Type |
---|---|
list | WatchListSymbolList |
Returns
boolean
If there is no watchList or an equivalent list already exists, false
will be returned. Otherwise, true
will be returned.
setActiveList
▸ setActiveList(id
): void
Make the watchlist with the specified id
active.
Parameters
Name | Type | Description |
---|---|---|
id | string | watchlist ID |
Returns
void
setList
▸ setList(symbols
): void
Obsolete. Use updateList
instead.
Set the list of symbols for the watchlist. It will replace the entire list.
Parameters
Name | Type | Description |
---|---|---|
symbols | string [] | symbol IDs |
Returns
void
updateList
▸ updateList(listId
, symbols
): void
Edit the list of symbols for a watchlist.
Parameters
Name | Type | Description |
---|---|---|
listId | string | ID of the watchlist |
symbols | string [] | Symbols to be set for the watchlist. Any list item that has the ### prefix is considered a section divider in the watchlist. |
Returns
void