Example Code Disclaimer: ALL EXAMPLE CODE IS PROVIDED ON AN “AS IS” AND “AS AVAILABLE” BASIS FOR ILLUSTRATIVE PURPOSES ONLY. LSEG MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, AS TO THE OPERATION OF EXAMPLE CODE, OR THE INFORMATION, CONTENT OR MATERIALS USED IN CONNECTION WITH EXAMPLE CODE. YOU EXPRESSLY AGREE THAT YOUR USE OF EXAMPLE CODE IS AT YOUR SOLE RISK
The purpose of these examples is to show retrieving JSON-formatted market content from a WebSocket server. The examples are as follows:
- market_price: Retrieves market-price content for TRI.N.
- market_price_batch_view: Retrieves market-price content for TRI.N, IBM.N, and T.N, using a batch request. It also specifies a view that requests content only for fields BID, ASK, and BIDSIZE.
- market_price_authentication: Retrieves market-price content for TRI.N, after authenticating with an authentication server.
- market_price_posting: Retrieves market-price content for TRI.N, and posts market-price content back to it.
- market_price_ping: Retrieves market-price content for TRI.N, and monitors connection health by sending ping messages.
market_price forms the basis of the other examples, which implement additional features. To see the code specific to each feature, a diff tool can be used to compare the market_price source file with that of the appropriate example.
These applications are intended as basic usage examples. Some of the design choices were made to favor simplicity and readability over performance. This application is not intended to be used for measuring performance.
node market_price.js [--hostname hostname] [--port port] [--app_id appID] [--user user] [--snapshot]
node market_price_batch_view.js [--hostname hostname ] [--port port] [--app_id appID] [--user user]
node market_price_authentication.js [--hostname hostname ] [--port port] [--app_id appID] [--user user] [--password password] [--auth_port port]
node market_price_posting.js [--hostname hostname ] [--port port] [--app_id appID] [--user user]
Pressing the CTRL+C buttons terminates any example.
- Install Node.js
- Go to: https://nodejs.org/en/download/
- Follow installation instructions for your machine
- Install libraries
cdtostreamingtools/Applications/Examples/node- Run:
npm install ip optimist ws request
- Run examples
cdtostreamingtools/Applications/Examples/node- To run
market_price.jswith options:node market_price.js --hostname <hostname>
- Install Node.js package
- (Instructions are from https://nodejs.org/en/download/package-manager/ )
- Run (as root):
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -yum -y install nodejs
- Install libraries
cdtostreamingtools/Applications/Examples/node- Run:
npm install ip optimist ws request
- Run examples
cdtostreamingtools/Applications/Examples/node- To run
market_price.jswith options:node market_price.js --hostname <hostname>
-
market_price.js- Source file for the market_price example. -
market_price_batch_view.js- Source file for the market_price_batch_view example. -
market_price_authentication.js- Source file for the market_price_authentication example. -
market_price_posting.js- Source file for the market_price_posting example. -
market_price_ping.js- Source file for the market_price_ping example.
- Node 22.13.0