API Documentation


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      ExgSequence;
  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     ExtTradeConditions[4];//.nx2 and .nx3 only!  For .nxc this is "alignment[4]".


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


Determines how to interpret the integer price as a floating point number. This value applies to Price, Open, High, Low, Last, Tick, and NetChange. 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 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 sessions 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.

#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_SETTLEMENT 0x40 price is settlement


Trade condition assigned by exchange, from the NxST_TRADECONDITION table

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


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.


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.


BATE stands for 'B'id, 'A'sk, 'T'rade, 'E'xception. BATE codes are only used for some commodities. 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.


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.


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.


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.


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


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 TotalVolume what the original trade update added.

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


TickVolume is the cumulative count of each trade message with the VolumeType of NxTVT_INCRVOL. Trade updates with the PriceFlag of NxTPF_EXGCANCEL, decrement TickVolume.


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 member High is set to the highest price of the session that is qualified to update the session high.


The member Low is set to the lowest price of the session that is qualified to update the session low.


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.


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


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.


*.nx2 and .nx3 tapes only*

Extended 4 byte sales conditions from CTA/UTP, if any. A value of 255 indicates no additional trade condition exists for this "slot". For example, [32,255,1,255], indicating a "RegularSettle" and "FormT" trade.

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 :

                NxCoreStateOHLCTrade ntohlc;
                int rc = nxCoreClass.GetStateData((char*) &ntohlc,
                if (rc)

                // save your stuff here!!!!