The article teaches how to get a list of subscribed instruments.
How to get a list of subscribed instruments Overview
In this article you will learn how to use the API to get a list of subscribed instruments.
Before you can get a list of subscribed instruments, you need to:
Create an instance of the instruments manager
Get a list of subscribed instruments
Step 1: Create an instance of the instrumentsManager
The first step is to create an instance of the instrumentsManager.
This is an object that provides methods for managing instruments.
You can use the IInstrumentsManager interface to access its methods and properties.
Below you can see some example code to create an instance of the instrumentsManager:
Create an instance of the instrumentsManager Hide
typescriptjavascriptsession.getInstrumentsManager().refresh(); // refresh it before using it to make sure it contains the latest info. let instrumentsManager = session.getInstrumentsManager();
For more information about the IInstrumentsManager interface, see the API reference.
Step 2: Get a list of subscribed instruments.
The next step is to get a list of instruments that you have subscribed to.
Subscribing to an instrument means that you will receive updates on its data, such as its price, volume, or spread.
You can use the getSubscribedInstruments method of the instruments manager to get a list of subscribed instruments.
This method returns an array of instrument symbols.
Below, you can see some example code to get a list of subscribed instruments:
Obtain a list of instruments Hide
typescriptjavascriptlet subscribedInstruments = instrumentsManager.getSubscribedInstruments();
For more information about the getSubscribedInstruments method, see the API reference.
Conclusion:
You have learned how to use the API to get a list of subscribed instruments. You have created an instance of the instruments manager and gotten a list of subscribed instruments. You can now use this knowledge to build your own applications that work with subscribed instruments.
Download the sample TypeScript, JavaScript.