Table of Contents


NxCoreTrade

The structure NxCoreTrade is defined in NxCoreAPI.h as:


struct NxCoreTrade {
    int               Price;
    unsigned char     PriceType;
    unsigned char     PriceFlags;
    unsigned char     TradeCondition;
    unsigned char     ConditionFlags;
    unsigned char     VolumeType;
    unsigned char     BATECode;
    unsigned char     alignment[2];
    unsigned int      Size;
    unsigned int      ExgSExgSequence;
    unsigned int      RecordsBack;
    NxCTAnalysis      nxAnalysis;
    unsigned __int64  TotalVolume;
    unsigned int      TickVolume;
    int               Open;
    int               High;
    int               Low;
    int               Last;
    int               Tick;
    int               NetChange;
    unsigned char     alignment2[4];
    char              ExtTradeConditions[4];
};

Price

Contains the price value of this trade record update and is used together with PriceType

PriceType

Determines how to interpret the integer price as a floating point number. You can convert the PriceType and Price to a floating point number in double format. See concept_Prices.html for more information on working with PriceTypes.

PriceFlags

PriceFlags is a bit mapped entity that indicates the type of trade represented in the update message. The bits are mapped as follows:

If one or more of the four least significant bits are set ( NxTPF_SETLAST, NxTPF_SETHIGH, NxTPF_SETLOW, NxTPF_SETOPEN) then the Price member represents a change to the trading session's Last, High, Low, and/or Open values, respectively. If the Price is equal to the Open, High, Low, or Last value and does not change it, then these bits will not be set.

The bits NxTPF_EXGCANCEL and NxTPF_EXGINSERT indicate the trade message is a canceled trade, or an inserted trade respectively. Only an Exchange can set these bits. Cancel and Insert type trade messages are discussed in more detail at the bottom of this page.

ExgSequenceExgSequence
#define Value Comments
NxTPF_SETLAST 0x01 Update the 'last' price field with the trade price.
NxTPF_SETHIGH 0x02 Update the session high price.
NxTPF_SETLOW 0x04 Update the session low price.
NxTPF_SETOPEN 0x08 Indicates trade report is a type of opening report. For snapshot indicies, this is the "open" field. See TradeConditions for the types that update this flag.
NxTPF_EXGINSERT 0x10 Trade report was inserted, not real-time. Often follows EXGCANCEL for trade report corrections.
NxTPF_EXGCANCEL 0x20 Cancel message. The data in this trade report reflects the state of the report when first sent, including the SETLAST/increment volume, etc flags.
NxTPF_SETTLEMENT0x40 price is settlement

TradeCondition

Trade condition assigned by exchange, from the NxST_TRADECONDITION table.

For a list of all Trade Conditions and what they mean, see NxTradeCondition.

ConditionFlags

Every trade message sent by the exchange has a field that indicates if special conditions apply to the trade. Example are FormT, Out Of Sequence, Average Price, etc. Trade Conditions may affect whether the trade is eligible to update the session open, high, low, volume and/or last fields. Each exchange has their own set of rules and exceptions to the rules.

Nanex has spent a lot of effort mapping the trade conditions, and the results of that effort is condensed into the 3 bits that make up the member ConditionFlags which are defined in NxCoreAPI.h as follows:

The NxTCF_NOLAST bit is set if the Trade Condition indicates the trade is not eligible to update the last. Similarly the NxTCF_NOHIGH and NxTCF_NOLOW bits are set if the Trade Condition indicates the trade is not elgible to update the high or low, respectively. The bits are set in this way to make it easy to test a trade report for unusual conditions -- the ConditionFlag member is non-zero.

The Nanex Core Processors use the ConditionFlags to quickly and easily maintain an internal Session high/low/last record based on the NxFilter. When a trade record that set the high, low, or session last is canceled by the exchange (the high/low are frequently cancelled), the Nanex Core Processors use the ConditionFlags to determine the next eligible high, low or last trade record.

#define Value Comments
NxTCF_NOLAST 0x01 Not eligible to update last price.
NxTCF_NOHIGH 0x02 Not eligible to update high price.
NxTCF_NOLOW 0x04 Not eligible to update low price.

VolumeType

The VolumeType member indicates how to interpret the Size member field. The possible values of VolumeType are defined in NxCoreAPI.h as follows:

#define Value Comments
NxTVT_INCRVOL 0 Most frequent -- incremental volume, updates trading session's TotalVolume. Note: it may be zero -- which updates the TickVolume but leaves TotalVolume unchanged
NxTVT_NONINCRVOL 1 Non-incremental volume. Rarely used outside of indexes. Intraday and Open detail in NYSE stocks. Indicates the Size member does not update the total volume: because that volume has already been added. This type is rarely used: Trade Conditions -- Open Detail, and Intraday Detail in NYSE and AMEX stocks, and certain indexes that are updated in a snapshot fashion and do not have volume or do not have volume available.
NxTVT_TOTALVOL 2 Size *is* the total volume -- as used by a few indexes that are updated as snapshots of the current values, and this volume type indicates the Size member represents the total volume of the session. The value of Size member will grow with each successive update. Symbols that update in a snapshot fashion will have all trade messages with this VolumeType.
NxTVT_TOTALVOLx100 3 Size *is* the total volume/100. Size should be multiplied by 100 to get the true volume. This is very RARE -- only one or two Dow Jones Indexes currently use this type.

The members TotalVolume and TickVolume have been updated as indicated by VolumeType.

BATECode

BATE stands for 'B'id, 'A'sk, 'T'rade, 'E'xception. BATE codes are not used in Equities, Equity Options or Indexes, but may be used for other types of products (Futures, Future Options, Commodities, etc). This field is set to an upper case character indicating the BATE code. The value 'E' (exception) is not used, as it is mainly a historic artifact. The value of zero is used if the BATE code field does not apply.

Size

The Size member represents the number of shares or contracts. Size usually represents the size of the trade, but it can also be interpreted otherwise, depending on the value of the member VolumeType. See VolumeType (above) for more information.

ExgSequence

The ExgSequence member contains the value of the Exchange assigned Sequence number. Exchange Sequence numbers increase in value, though not necessarily in increments of one. Exchange Sequence numbers are used to positively identify trades and can be used when processing Exchange cancel and correction messages.

Note: As of October 24, 2016, Nasdaq-listed instruments have a unique sequence number per symbol per reporting exchange. Prior to this date, each Nasdaq-listed instrument had a unique sequence number regardless of reporting exchange.

Note 2: As of July 29, 2013, OPRA does not report a unique exchange sequence number. They report a block sequence number that is passed through as ExgSequence. For more information click here to see the OPRA spec sheet.
From page 12 of the PDF (as pulled on Jan 24, 2017):

From page 48 of the PDF (as pulled on Jan 24, 2017):

RecordsBack

The member RecordsBack will always be non-zero for Insert and Cancel trade record updates. For cancel messages, the value of RecordsBack indicates how many records to go back to find the trade record to cancel. You can also use the ExgSequence member to locate the trade record to cancel. For Insert trade record updates, RecordsBack indicates how many records to go back to find the insertion point. The Insertion point is right after the record that is the number of records back in RecordsBacks.

nxAnalysis

The Nanex Core Processors perform real-time analysis on the data stream and store the results in the structure NxCTAnalysis member.

TotalVolume

TickVolume is the cumulative count of each trade message with the VolumeType of NxTVT_INCRVOL. TotalVolume is the cumulative sum of the Size member of all trade updates with the VolumeType NxTVT_INCRVOL, or, for those types that update as snapshots, TotalVolume is the value of the Size member for the most recent trade update with a VolumeType NxTVT_TOTALVOL or NxTVT_TOTALVOLX100. Trade updates with the PriceFlag of NxTPF_EXGCANCEL, subtract from TickVolume and TotalVolume what the original trade update added.

Note that TotalVolume is a 64-bit number to accommodate a few high volume stocks and some DOW indexes.

The members TotalVolume and TickVolume have been updated as indicated by VolumeType.

TickVolume

TickVolume is the cumulative count of each trade message with the VolumeType of NxTVT_INCRVOL. TotalVolume is the cumulative sum of the Size member of all trade updates with the VolumeType NxTVT_INCRVOL, or, for those types that update as snapshots, TotalVolume is the value of the Size member for the most recent trade update with a VolumeType NxTVT_TOTALVOL or NxTVT_TOTALVOLX100. Trade updates with the PriceFlag of NxTPF_EXGCANCEL, subtract from TickVolume and TotalVolume what the original trade update added.

Note that TotalVolume is a 64-bit number to accommodate a few high volume stocks and some DOW indexes.

The members TotalVolume and TickVolume have been updated as indicated by VolumeType.

Open

These price members are integer prices that use the member PriceType to indicate the decimal location.

The member Last will equal the member Price if the PriceFlags indicate the trade update is a trade that is qualified to set the Last price: FormT prices, for example, are not qualified to set the Last, according to exchange procedures.

The first trade of a session that can set the Last price also sets the Open member. The Open member is also updated for specific trade conditions which indicate an opening price. The members High and Low are set to the highest and lowest prices of the session that are qualified to update the session high and low.

Tick is the price change from the previous trade update that qualified to set the Last.

NetChange is the change in value from the Last member and the previous session's close, adjusted for dividends and distributions. When a stock goes ex-dividend, the previous session's close will be reduced in price by the amount of the dividend. This information is generally disseminated by exchanges one to two hours before the market opens for the regular trading session.

These members will adjust for price corrections.

High

These price members are integer prices that use the member PriceType to indicate the decimal location.

The member Last will equal the member Price if the PriceFlags indicate the trade update is a trade that is qualified to set the Last price: FormT prices, for example, are not qualified to set the Last, according to exchange procedures.

The first trade of a session that can set the Last price also sets the Open member. The Open member is also updated for specific trade conditions which indicate an opening price. The members High and Low are set to the highest and lowest prices of the session that are qualified to update the session high and low.

Tick is the price change from the previous trade update that qualified to set the Last.

NetChange is the change in value from the Last member and the previous session's close, adjusted for dividends and distributions. When a stock goes ex-dividend, the previous session's close will be reduced in price by the amount of the dividend. This information is generally disseminated by exchanges one to two hours before the market opens for the regular trading session.

These members will adjust for price corrections.

Low

These price members are integer prices that use the member PriceType to indicate the decimal location.

The member Last will equal the member Price if the PriceFlags indicate the trade update is a trade that is qualified to set the Last price: FormT prices, for example, are not qualified to set the Last, according to exchange procedures.

The first trade of a session that can set the Last price also sets the Open member. The Open member is also updated for specific trade conditions which indicate an opening price. The members High and Low are set to the highest and lowest prices of the session that are qualified to update the session high and low.

Tick is the price change from the previous trade update that qualified to set the Last.

NetChange is the change in value from the Last member and the previous session's close, adjusted for dividends and distributions. When a stock goes ex-dividend, the previous session's close will be reduced in price by the amount of the dividend. This information is generally disseminated by exchanges one to two hours before the market opens for the regular trading session.

These members will adjust for price corrections.

Last

These price members are integer prices that use the member PriceType to indicate the decimal location.

The member Last will equal the member Price if the PriceFlags indicate the trade update is a trade that is qualified to set the Last price: FormT prices, for example, are not qualified to set the Last, according to exchange procedures.

The first trade of a session that can set the Last price also sets the Open member. The Open member is also updated for specific trade conditions which indicate an opening price. The members High and Low are set to the highest and lowest prices of the session that are qualified to update the session high and low.

Tick is the price change from the previous trade update that qualified to set the Last.

NetChange is the change in value from the Last member and the previous session's close, adjusted for dividends and distributions. When a stock goes ex-dividend, the previous session's close will be reduced in price by the amount of the dividend. This information is generally disseminated by exchanges one to two hours before the market opens for the regular trading session.

These members will adjust for price corrections.

Note the member Last. For trade updates eligible to update the last price (the trade condition meets the exchange rule criterion), the members Price and Last will be equal. You can determine if a trade is qualified to update the last by inspecting the PriceFlags member, which is discussed next. The most common situation that you will see Price not equal to Last is during pre-market and post-market trading in equities. The Price field will update with each FormT trade, while the Last field will not.

Tick

These price members are integer prices that use the member PriceType to indicate the decimal location.

The member Last will equal the member Price if the PriceFlags indicate the trade update is a trade that is qualified to set the Last price: FormT prices, for example, are not qualified to set the Last, according to exchange procedures.

The first trade of a session that can set the Last price also sets the Open member. The Open member is also updated for specific trade conditions which indicate an opening price. The members High and Low are set to the highest and lowest prices of the session that are qualified to update the session high and low.

Tick is the price change from the previous trade update that qualified to set the Last.

NetChange is the change in value from the Last member and the previous session's close, adjusted for dividends and distributions. When a stock goes ex-dividend, the previous session's close will be reduced in price by the amount of the dividend. This information is generally disseminated by exchanges one to two hours before the market opens for the regular trading session.

These members will adjust for price corrections.

NetChange

These price members are integer prices that use the member PriceType to indicate the decimal location.

The member Last will equal the member Price if the PriceFlags indicate the trade update is a trade that is qualified to set the Last price: FormT prices, for example, are not qualified to set the Last, according to exchange procedures.

The first trade of a session that can set the Last price also sets the Open member. The Open member is also updated for specific trade conditions which indicate an opening price. The members High and Low are set to the highest and lowest prices of the session that are qualified to update the session high and low.

Tick is the price change from the previous trade update that qualified to set the Last.

NetChange is the change in value from the Last member and the previous session's close, adjusted for dividends and distributions. When a stock goes ex-dividend, the previous session's close will be reduced in price by the amount of the dividend. This information is generally disseminated by exchanges one to two hours before the market opens for the regular trading session.

These members will adjust for price corrections.

Cancel, Cancel Replace, Insert messages

When a cancel or insert message occurs, the Open, High, Low, Last, Tick, PreviousClose, TickVolume, and TotalVolume have not been corrected yet.

All cancel/insert messages will be immediately preceded by a TradeCorrection category and immediately followed by a TradeReportSummary category. All subsequent Trade messages will contain the adjusted data.

If you need to immediately see the adjustments, and don't want to handle the category message yourself, you can use this code:


    case NxMSG_CATEGORY:
    {
        switch (pNxCoreMessage->coreData.Category.pnxStringCategory->Atom)
        {
            case nxST_CATEGORY::TradeReportSummary: // from NxCoreTableHelper.h
            {
                const NxCoreHeader& ch = pNxCoreMessage->coreHeader;
                NxString *nx = ch.pnxOptionHdr ?
                               ch.pnxOptionHdr->pnxsDateAndStrike :
                               ch.pnxStringSymbol;

                NxCoreStateOHLCTrade ntohlc;
                int rc = nxCoreClass.GetStateData((char*) &ntohlc,
                                                  sizeof(ntohlc),
                                                  NxSTATETYPE_OHLCTRADE,
                                                  0,
                                                  0,
                                                  nx);
                if (rc)
                {
                    break;
                }

                // save your stuff here!!!!

                break;
            }
        }
        break;
    }


ExtTradeCondition

Only applies to .nx2 and .nx3 tape formats. Each of the 4 characters represents the NxCore-mapped trade conditions available in both NYSE's CTA SIP and Nasdaq's UTP SIP. The existing single NxCore field TradeCondition remains the same for backwards compatibility. The value 255 (unsigned) denotes "not set" as the value 0 is a valid trade condition.

For more information about extended trade conditions, see ExtTradeCondition.