JTools Table of Contents

Project Location: \JTools_FuturesDepthMon

The Futures Depth Montage is another application I initially wrote to test a new server and at the same time, provide a new tool to view futures depth and depth stats. I have recently converted it over to the JTools/NxCore framework.

The Futures Depth Montage demonstrates several key concepts related to both NxCore/GUI systems intended for real world use, including:
  • How to use MMQuotes and StateMMQuotes in NxCore (MMQuotes contain futures depth).
  • How to construct future names using the futures root information.
  • How to avoid using costly string compares when processing data by making use of each symbol's userdata members.
  • How to keep the entire application integer based (only converting to floating point when a GUI element is actually populated).
  • How to process data rapidly onto the GUI (even when running historical tapes at full blast) without losing responsiveness.


The fields in the Futures Depth Montage include:

Composite Stats in upper section of application:
  • Symbol - The specific future the user is listening to.
  • Name - Name of the future.
  • Listen Time - Amount of time listening to the specific future.
  • LTrade Time - Time of the last trade.
  • Last - Price of the last trade.
  • Size - Size of the last trade.
  • Av Size - Average size of trades.
  • NetChg - Net change of price from the previous trading day.
  • Spread - Spread of the Depth Level 1 Bid and Ask.
Montage stats (Bid Depth and Ask Depth):
  • D#- The depth level.
  • Time - Time of the last quote.
  • Price - Price of the quote.
  • Diff - Diff in price from one depth level to the next.
  • Size - Size of the quote for the reporting exchange.
  • Summ - Summ of depth level sizes.

Symbol Convention:

Since this application is specific to futures, you may enter symbols with or without the lowercase 'f'. Examples would be "fES.U12" (the standard NxCore convention for futures) or just "ES.U12".

Furthermore, at any point in time two exchanges may use the same future symbol to represent different futures (while this is rare, it does happen). Should this occur you may get a future you were not expecting when entering the symbol. To correct this you would also specify the exchange the symbol is listed on. For instance NG.U12 was listed (at the time of this writing) on both the NYMX (as Sept12 Natural Gas futures) and on the CBOT (as Sept12 5 Year US Int Rate Swap futures). As an example of how to specify the listing exchange in the symbol:
  • NG.U12:25 - Natural Gas future on the NYMX exchange (exchange # 25).
  • NG.U12:24 - 5 Year US Int Rate Swap future on the CBOT exchange (exchange #24).

Note that not all future exchanges provide depth. The exchange designators correspond to the default NxCore exchange codes found here: NxCore Exchange Codes

You may enter a new symbol at any time. Simply type in the symbol and press the ENTER key. If the symbol is valid, the display will clear and immediately populate with with the current depth quotes and price information (through the use of NxCoreStateGetMMQuotes and NxCoreStateGetLastTrade). After that the stats and montage list are populated with all streaming trade and MMQuote messages (NxMSG_TRADE and NxMSG_MMQUOTE).

If the symbol entered is not valid, a "Symbol Not Found" message is displayed in the Name field.

You can cancel listening to a symbol by simply clearing the symbol and pressing the ENTER key.

If you have not started NxCore prior to entering a symbol then NxCore will be started when you press ENTER. When doing this, it may take a couple seconds for the symbol's name to appear as NxCore has just started and the category information (with company names) does not become available for the first few minutes of the tape. When entering symbols after the tape has been started all information is delivered immediately.

One further caveat - if you have started NxCore using an NxCore State File (as opposed to an NxCore historical tape) the company names will most likely not be available. This is because the state file will (most likely) be from a timeframe beyond the Category 8 messages (which occur in the first few minutes of the tape) and as such, they are not available at the point where the state file begins to process the tape. No other aspect of the application is effected when running from state files.


While the application was written with the intention of viewing equities in real time, you can also blast through a historical tape as fast as possible and the application will remain snappy and responsive. This is accomplished through a variety of mechanisms:
  • The use of the userdata1 field contained in each NxCore symbol string which is unique (and remains static) to all issues in the system. By using this field to designate when a symbol has interest set, all string compares can be eliminated during processing of the stream. It cannot be over emphasized how much processing time is saved when eliminating string compares in a whole-market feed.

  • The application was intended for a human to view. While quotes may change 1000's of times a second, a human can simply not process every change in that time frame. The human brain will see a seamless display if the display is updating approx. 24 times a second. Now, updating any GUI element is about the most processing intensive item you can do in any one single line of code. So, if the human brain cannot distinguish detail at 24 times a second, why update the display any more than that? The Quote Montage display list in this application is updated from a timer which remains constant as the application runs. The timer is fired every 40 milliseconds, which equates to 25 updates per second. Additionally, any item that has not changed during a refresh cycle is not updated. This does mean keeping track of the values set and doing simple compares at every refresh, but doing those compares is far less expensive than a GUI field update.

  • All values are stored, used and calculated using the raw NxCore price integer (as opposed to converting every price field to a double for each message). The price type of each item is also stored and the only time a price is converted into a double is when it is actually used to update a GUI fields and be displayed to the user.

JTools Table of Contents