Skip to content

Get instrument Details

Overview

This page shows you how to get and display various details of an individual instrument using the instrument class and its methods. An instrument is a tradable asset that has a symbol, a type, a price, and other information. You will learn how to create an instrument object, which represents an instrument, and how to access different information about the instrument, such as its symbol, type, price precision, contract currency, and trading status. You will also learn how to handle different types of instruments, such as CFDs and instruments that have dividends.

The instrument class provides access to instrument information, such as symbol, type, price precision, contract currency, trading status, etc. You can use this class to get various details of an individual instrument that you are interested in trading with FCLite.

To create an instance of the instrument class, you need to pass the offer ID of the instrument as an argument to the constructor method. The offer ID is a unique identification number of the instrument offer. You can get the offer ID from the offers collection, which contains all the available instruments for trading. For example, the following code creates an instrument object for EUR/USD:

// Get the offer ID of EUR/USD from the offers collection
var offer_id = offers.find("EUR/USD").getOfferId();

// Create an instrument object for EUR/USD using the offer ID
var instrument = new Instrument(offer_id);

The instrument class has various methods that return different information about the instrument.

For example: you can use the getSymbol method to get the symbol of the instrument, the getInstrumentType method to get the type of the instrument, the getDigits method to get the instrument price precision, etc.

The following code shows how to use some of the methods of the instrument class:

// Get the symbol of the instrument
var symbol = instrument.getSymbol();
console.log("Symbol:", symbol);

// Get the type of the instrument
var instrument_type = instrument.getInstrumentType();
console.log("Type:", instrument_type);

// Get the instrument price precision
var digits = instrument.getDigits();
console.log("Digits:", digits);

// Get the contract currency of the instrument
var contract_currency = instrument.getContractCurrency();
console.log("Contract currency:", contract_currency);

// Get the trading status of the instrument
var trading_status = instrument.getTradingStatus();
console.log("Trading status:", trading_status);

Note

Some of the methods of the instrument class only make sense for certain types of instruments. For example, the getContractMultiplier method only applies to some CFD instruments, and the getDividendBuy and getDividendSell methods only apply to instruments that have dividends. You can check the instrument type before using these methods to avoid errors or confusion.

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