Skip to content

Searching for Instruments

Overview

This page explains how to use the FCLite API to search for instruments by various criteria, such as symbol, type, trading status, etc. The page shows how to use the core.interfaces.tradingdata.instruments interface to access the instrument information, and how to use the Instrument class and its methods and properties to get or set the instrument attributes. The page also provides code snippets and examples of how to use the FCLite API to perform different types of instrument searches, such as keyword search, partial symbol search.

To search for instruments, programmers can use the following methods from the instrument class:

  • getSymbol: This method returns the symbol of the instrument, such as EUR/USD or UK100/GBP. This can be used to find instruments by their unique identifiers.
  • getInstrumentType: This method returns the type of the instrument, such as FOREX, INDICES, COMMODITY, etc. This can be used to filter instruments by their categories.
  • getTradingStatus: This method returns the trading status of the instrument, such as open, closed, or suspended. This can be used to check the availability of instruments for trading.
  • getSubscriptionStatus: This method returns the subscription status of the instrument, such as subscribed, unsubscribed, or pending. This can be used to manage the instruments that the programmer wants to receive updates on.
  • getInstrumentByPriceStreamId: Gets a data of a specific instrument by its price stream ID
  • getInstrumentDescriptorsByType: Gets a data of all instrument descriptors of a specific type, such as FOREX, INDICES, etc.
  • getInstrumentDescriptorsByTradingStatus: Gets a data of all instrument descriptors of a specific trading status, such as open, closed, or suspended
  • getInstrumentDescriptorsBySubscriptionStatus: Gets a data of all instrument descriptors of a specific subscription status, such as subscribed, unsubscribed, or pending

These methods can be used to find instruments by different criteria, and to access their properties and methods.

**For example:" you can use the getInstrumentBySymbol method to get an instrument object by its symbol, and then use the getTradingStatus method to check if the instrument is open for trading. You can also use the getInstrumentDescriptorsByType method to get a list of instrument descriptors of a specific type, and then loop through the list to display their symbols and prices.

Here is a code snippet of how to use some of these methods:

// Get an instrument object by its symbol
var instrument = core.interfaces.tradingdata.instruments.getInstrumentBySymbol("EUR/USD");

// Check the trading status of the instrument
var status = instrument.getTradingStatus();

// Print the status
console.log("The trading status of EUR/USD is " + status);

// Get a list of instrument descriptors of type FOREX
var descriptors = core.interfaces.tradingdata.instruments.getInstrumentDescriptorsByType(Instrument.TYPE_FOREX);

// Loop through the list and print the symbol and price of each instrument descriptor
for (var i = 0; i < descriptors.length; i++) {
    var descriptor = descriptors[i];
    var symbol = descriptor.getSymbol();
    var price = descriptor.getPrice();
    console.log(symbol + ": " + price);
}
Table of Contents
Get Available Instruments
The article teaches how to get a list of available instruments.
Get Subscribed Instruments
The article teaches how to get a list of subscribed instruments.
Subscribe to Instruments
API Command used to subscribe and unsubscribe to/from an instrument
Get Instrument By Symbol
The article teaches how to get an instrument using its symbol.
Search for Instruments
API Command used to search for an instrument
Instrument Details
API Command used to get the details of an instrument