List Prices
Overview
This page instructs you how to retrieve the current prices of the instruments that are available for trading using the FCLite API. List prices are the latest bid and ask prices that are offered by the FXCM trading platform, and they are updated in real-time. List prices are different from historical prices, which are the past prices of the instruments that have been recorded over a period of time. You can use this information to monitor the market conditions and allow you to execute trades using the FCLite API.
How to Use List Prices: You can use the list prices page to view the current prices for any instrument that is supported by the FCLite API. You can select the instrument through whatever method you want to present to the user or even hard code it, and see the bid and ask prices, the spread, the volume, and the timestamp of the latest update.
You can also use the FCLite API to subscribe to real-time price updates for an instrument, and receive a callback function with the price data. You can use the getPriceUpdate method to subscribe to price updates, and the unsubscribePriceUpdate method to stop receiving price updates. For more information about how to use the FCLite API to get the price updates, please refer to the Get a price update for an instrument page.
Examples: You can use the list prices to monitor the market conditions and execute trades using the FCLite API. For example, you can use the list prices to determine the best entry and exit points for your trades, and to place market, limit, stop, and trailing stop orders. You can also use the list prices to calculate the profit/loss, margin, and rollover interest of your open positions. For more information about how to use the FCLite API to perform trading operations, please refer to the Trading section.
Step 1
Log into the system. Refer to the Logging in page.
Step 2
Create a price update listener and a price update callback. You need to do this to receive real-time price updates for an instrument. You also need to subscribe the listener and the callback to the session.
// Create a price update listener
class PriceUpdateListener extends FXConnectLite.IPriceUpdateListener {
onPriceUpdate(session, instrument, bid, ask, spread, volume, timestamp) {
console.log("Price update for " + instrument + ":");
console.log("Bid: " + bid);
console.log("Ask: " + ask);
console.log("Spread: " + spread);
console.log("Volume: " + volume);
console.log("Timestamp: " + timestamp);
}
}
// Create a price update callback
class PriceUpdateCallback extends FXConnectLite.IPriceUpdateCallback {
onPriceUpdateResponse(session, instrument, error) {
if (error) {
console.log("Price update failed for " + instrument + ": " + error.message);
} else {
console.log("Price update succeeded for " + instrument);
}
}
}
// Subscribe the listener and the callback to the session
session.subscribePriceUpdate(new PriceUpdateListener());
Step 3:
Use the getPriceUpdate method to subscribe to price updates for an instrument. You need to do this to get the latest bid and ask prices, the spread, the volume, and the timestamp of each update. You also need to provide the instrument name as a parameter.
// Use the getPriceUpdate method to subscribe to price updates for an instrument
let instrument = "EUR/USD"; // The instrument name
session.getPriceUpdate(instrument, new PriceUpdateCallback());
Step 4:
Use the unsubscribePriceUpdate method to stop receiving price updates for an instrument. You need to do this when you no longer need the price updates. You also need to provide the instrument name as a parameter.
// Use the unsubscribePriceUpdate method to stop receiving price updates for an instrument
let instrument = "EUR/USD"; // The instrument name
session.unsubscribePriceUpdate(instrument, new PriceUpdateCallback());
In conclusion, this page provides a comprehensive documentation of the list prices functionality in the FCLite API, a powerful tool for trading with various instruments and markets. It covers the basic concepts and features of FCLite, such as accounts, orders, positions, prices, margins, rollovers, and market data. By following this documentation, users can learn how to leverage FCLite to create and execute their own trading strategies.
| Table of Contents | |
|---|---|
| Get Price Updates for an Instrument The article teaches how to receive price updates for an instrument. |
|
| Get Historical Prices for an Instrument The article teaches how to receive historical prices for an instrument. |