|JTOOLS LEVEL2 VIEWER
JTools Table of Contents
Project Location: \JTools_Level2Viewer
The Level 2 Viewer sorts and displays NASDAQ Level 2 Market Maker data. The
application demonstrates several key concepts related to both NxCore/GUI
systems intended for real world use, including:
- How to use MMQuotes, ExgQuotes, StateMMQuotes and StateExgQuotes in NxCore.
- How to avoid using costly string compares when processing data by making
use of each market makers string pointer.
- 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 Level 2 Viewer include:
|Composite Stats in upper section of
- Symbol - The specific stock the user is listening to.
- Name - Name of the stock.
- 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.
|Level2 stats (Bid Depth and Ask Depth):
- MMID- Market Maker or Exchange ID.
- Time - Time of the last quote.
- Price - Price of the quote.
- Size - Size of the quote for the reporting exchange.
Since this application is specific to equities, you may enter symbols with or
without the lowercase 'e'. Examples would be "eIBM" (the standard
NxCore convention for equities) or just "IBM".
Furthermore, because a symbol may be duplicated on more than one listing
exchange. For instance GE is listed on both the NYSE and Canadian exchange, and
represent different companies. While the symbols default to the US symbols, it
is possible to specify the listing exchange the symbol. As an example of how to
specify the listing exchange in the symbol:
- GE or GE:3 - General Electric on the NYSE exchange (exchange # 3).
- GE:19 - Granville Pacific Capital Corp on the CDNX exchange (exchange #19).
The exchange designators correspond to the default NxCore exchange codes found
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 quotes from each exchange and the most recent
price information (through the use ofNxCoreStateGetMMQuotes,
NxCoreStateGetExgQuotes and NxCoreStateGetLastTrade). After that the stats and
level 2 lists are populated with all streaming trade and quote messages
(NxMSG_TRADE, NxMSG_MMQUOTE and NxMSG_EXGQUOTE).
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 4 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
- The use of the Market Maker string pointers to eliminate string comparisons
during processing of the stream. Again, it cannot be over emphasized how much
processing time is saved when eliminating string compares in a whole-market
- 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