Table of Contents


NxString

NxString is defined in NxCoreAPI.h as follows:


struct NxString {
    int            UserData1;
    int            UserData2;
    unsigned short Atom;
    char           String[1];
};

All members of NxCoreAPI use pointers to NxStrings rather than NxString structures. The pointer to an NxString remains constant for the entire duration of a tape, allowing you to store a pointer to an NxString rather than copying its contents.

NxString members

UserData1

A 32-bit memory space that you can assign a values that will be preserved and returned in all future callback functions for each NxString within a NxString group. You can use these members to expand the API and save a significant amount of cpu processing and memory space. You can change these values during any callback function. The NxCoreAPI code does not read or write to UserData1 during the processing of a tape.

UserData2

A 32-bit memory space that you can assign a values that will be preserved and returned in all future callback functions for each NxString within a NxString group. You can use these members to expand the API and save a significant amount of cpu processing and memory space. You can change these values during any callback function. The NxCoreAPI code does not read or write to UserData2 during the processing of a tape.

Atom

The member Atom is a 16 bit number assigned by NxCoreAPI.dll to each NxString within a group and remains constant during the NxString's lifetime (basically, only for the current tape>. Each NxString group will have 65536 or fewer members. You must not change the value of Atom.

For Symbol and Option Contract NxStrings, Atoms are assigned based on the previous trading day's activity, with the most active Symbol being assigned 1. Atom could be 0 if NxString is NxOptionHdr.pnxsUnderlying and you're not subscribed to the underlying's exchange.

The Atom is typically not very useful outside of following situations:

As of December 2008, NYMEX Atoms exceed 64K, so you will need to check if the Atom == NxATOM_MAX_16BIT, and if it is, use the GetSymbolAtom32() function (NxCoreClass.GetSymbolAtom32()) to get the real atom.

String

A character array which holds a string of characters plus one null (0) character. String is defined as a one byte array in the structure to satisfy compiler requirements.

There is one exception to NxString.String terminating with a null character -- the pnxsDateAndString member of pnxOptionHdr has exactly 2 characters in the String member and does not terminate with a null character. The member pnxsDateAndString holds the standard alpha characters for the expiration date and strike for options contracts. Be sure that you do not use pnxsDateAndString->String in code that is expecting a null terminated string. In many cases, there will actually be a null (0) character at the location pnxsDateAndString->String[2], but occassionally, this value will not be null.

Example Memory Organization of an NxString in Assembly


;Example Memory layout for NxString with UserData1=1,UserData2=2,Atom=3,and String = "eMSFT":
UserData1   dd  0x01000000  ; 4 bytes for UserData1
UserData2   dd  0x02000000  ; 4 bytes for UserData2
Atom        dw  0x0300      ; 2 bytes for Atom
String      db  'eMSFT',0   ; 6 bytes. 5 for 'eMSFT' plus 1 for null terminator -- note: for option contracts,
                            ; the pnxsDateAndStrike member is a NxString containing just 2 alpha characters
                            ; (one for the expiration date code, and one for the strike code) and does NOT
                            ; include a terminating null terminator.

NxString Groups

There are several groups of NxStrings as shown in the table below.

Group Found in Comments
Symbol
Names
NxCoreHeader.pnxStringSymbol
NxOptionHdr.pnxsUnderlying
Each symbol from the same Listed Exchange has it's own pointer to a NxString. The Atom members of these strings are assigned based on the symbols activity in the previous trading session. A symbol with the ATOM value 1 was the most active symbol within it's listed Exchange, the symbol with the ATOM 2 was the 2nd most active, etc.
Each Option Contract that has the same underlying symbol (the underlying) will have the same pointer value in pnxsUnderlying, but the underlying's Atom could be 0 if you're not subscribed to the underlying's exchange.
Option
Contracts
NxOptionHdr.pnxsDateAndStrike The String member of pnxsDateAndStrike holds exactly 2 characters: the expiration and strike character codes. NxString pointers are unique for each option contract, i.e. the option contract IBM AB will have a different NxString pointer than MSQ AB even though both NxStrings have the same values for the pnxsDateAndStrike.String members ('A' and 'B').
Option
Series Chain
NxOptionHdr.pnxsSeriesChain All Option Contracts belonging to any Option Series in the Chain will have the same pointer value in pnxsSeriesChain.
Option Special
Settlements
NxOptionHdr.pnxsSpecialSettle All Option Series with the same Special Settlement formula will have the same pointer value in pnxsSpecialSettle.
Market Maker
Identifiers
MMQuote.pnxStringMarketMaker Market Maker NxStrings are assigned system-wide: they are shared by all symbols from all exchanges in the system. For example, the NxString containing "MLCO" in this member will be the same for MSFT, INTC, IBM, etc.
Category
Names
NxCoreCategory.pnxStringCategory Each Category Name has it's own unique pointer to NxString

All variables of the type 'NxString' in their names (SymbolStringIx, MarketMakerStringIx, and CategoryStringIx) are special pointers to null-terminated (zero) character strings. They work just like other character pointers, but they also have several special properties that you can use to significantly speed up processing time and reduce memory usage. Those properties are:

Example Usage

The code below takes advantage that pointers to NxStrings remain constant for the duration of a tape. It tests the static variable which is initially zero. Once the initial strcmp of the category name NxTradeReportSummary is found, it saves the value of the pointer pnxStringCategory. All future callbacks only need to compare the saved pointer againsts the pointer value of pnxStringCategory, rather than the contents of the string:


int OnNxCoreAPICallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMsg)
{
    if( pNxCoreMsg->MessageType == NxMSG_CATEGORY ) {
        static char* pNxCatTRS;

        if( pNxCatTRS == 0 ) { // if 0, has not yet been set.
            if( strcmp(pNxCoreMsg->coreData.Category.pnxsStringCategory,"NxTradeReportSummary") == 0 ) { // string compare expensive.
                pNxCatTRS = pNxCoreMsg->coreData.Category.pnxsStringCategory;   // remember pointer value.
            }
        }

        if( pNxCatTRS == pNxCoreMsg->coreData.Category.pnxsStringCategory )
            processTradeReportSummary(pNxCoreSys,pNxCoreMsg);
    }
}