Market Depth

R. Todd Gafford -

This sample demonstrates methods for requesting and processing market depth data. There is a link to download the sample at the end of this article.

Before you run this sample, you need to have a current Interactive Data client account. If you do not yet have an account, click here to find out about setting up a trial.

To run the sample from a command line, go to the folder in which you unzipped the sample (see attachment below) and enter the following command:

Windows
> MarketDepthSample.exe [-h <host>] -u <username> -p <password> [-m <mode> -t <type> -x <source> -f <filter>
-s <symbols> -csv <nodisp>]
Linux
$ export LD_LIBRARY_PATH=./
$ chmod a+x MarketDepthSample
$ ./MarketDepthSample [-h <host>] -u <username> -p <password> [-m <mode> -t <type> -x <source> -f <filter>
-s <symbols> -csv <nodisp>]

where:

Argument Value Description
-h <host> is the address to use to connect to the Interactive Data Consolidated Feed Network.
-u <username> is the username for your client (required field)
-p <password> is the password for your client (required field)
-m <mode> Specifies the type of request to submit to the Level 2 service. The following requests types are supported:
  • info
    Instructs the Level 2 service to provide information regarding the types of depth available for a given instrument.

  • stream
    Instructs the Level 2 service to provide streaming depth updates for the given instrument(s).

  • netorder
    Instructs the Level 2 service to provide streaming net-order imbalance updates for the given instrument(s).
-t <type> Specifies the type of depth to provide. Available depth types include:
  1. Order Book
  2. Book By Price
  3. Book By Market Participant
  4. Book By Level
  5. Book By Market Participant Extended

You may enter either the number or full description for the depth type. Here are two examples:

-t 4
-t "Book By Level"

NOTE: If you enter the full description you must encapsulate it with quotes.

-x <source> Specifies the venue from which to retrieve Level 2 data. Refer to the following article for a list of available sources: Available Depth Sources

For example:
   -x 1
NOTE: The above example sets the depth source to NASDAQ.
-f <filter> Instructs the Level 2 data service to provide filtered data. The following filters are supported:
  1. Odd Lots Only
  2. Board Lots Only

You may enter either the number or full description for the depth filter. Here are two examples:

-f 1
-f "Board Lots Only"

NOTE: If you enter the full description you must encapsulate it with quotes.

-s <symbols> is a comma separated list of symbols for which to make a history request. Multiple symbols must
be enclosed in quotes with no spaces between symbols. For example: IBM,GE,WFM
-csv <nodisp> When this option is set the application will format the output to be suitable for a comma-separated value (CSV) file. When this option is not set, the application will format the output for display within the console window. To use this option you must also provide output file instructions. For example:
   MarketDepthSample -u name -p pwd -csv nodisp >> output.csv
When you provide output instructions, no information will display on the console window. All output will be written to the file you specify.

Note: If you do not enter a value for <host>, <type>, <source>, <filter>, or <symbols> the sample will user default values.

<username> and <password> must be entered at the command line.