API Documentation

NxMSG_SYMBOLSPIN message

The second parameter to the NxCoreCallback function, NxCoreMessage, holds the symbol and session information in pNxCoreMessage->coreHeader, and data information in pNxCoreMessage->coreData.SymbolSpin, which is a NxCoreSymbolSpin data structure. The Symbol Spin Message uses the simple structure NxCoreSymbolSpin. (Note: You do not need to process symbol spin messages; they are provided for convenience only.)

NxCoreSymbolSpin Messages are automatically sent once for each Symbol that has traded previous to the start of the NxCore Tape. You can also force Symbol Spin messages at any time in your call back function by calling the exported function sNxCoreSpinSymbols. Symbol Spin messages provide a convenient and efficient method for iterating Symbol Sets without having to create and maintain a container to hold them. The system symbol spin is useful for preallocating storage before market open to minimize allocations and reallocations during active trading.

Since some symbols do not trade every day, NxCore only removes symbols for which the listing exchange sends an explicit delete message. It is therefore important to use Category messages, specifically Category 16 - OHLC and Category 27 - NxLastTrade to determine if a tape might include data for a symbol.

A Symbol Spin message uses the data members of NxCoreMessage.coreHeader to identify the symbol or option contract. The coreData member SymbolSpin contains iteration information regarding the spin

Simplest example

Here's the simplest example.

#include <NxCoreAPI.h>
int processNxCoreSymbolSpin(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMsg)
{
    return NxCALLBACKRETURN_CONTINUE;
}
int __stdcall OnNxCoreCallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMsg)
{
    switch( pNxCoreMsg->MessageType ) {
        case NxMSG_STATUS:       break;
        case NxMSG_EXGQUOTE:     break;
        case NxMSG_MMQUOTE:      break;
        case NxMSG_TRADE:        break;
        case NxMSG_CATEGORY:     break;
        case NxMSG_SYMBOLCHANGE: break;
        case NxMSG_SYMBOLSPIN:   return processNxCoreSymbolSpin(pNxCoreSys, pNxCoreMsg);
    }
    return NxCALLBACKRETURN_CONTINUE;
}

Automatic spin example

Here's an example of processing a spin, printing each symbol in the spin and determining when the spin is starting and when the spin is complete.

#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <stdio.h>
#include "NxCoreAPI.h"
#include "NxCoreAPI_class.h"    
 
NxCoreClass nxCoreClass;    
 
void PrintSymbol(const NxCoreMessage *pNxCoreMsg)
{
    // If a valid option header 
    if (pNxCoreMsg->coreHeader.pnxOptionHdr)
    {
        // If pnxsDateAndStrike->String[1] == ' ', then this symbol is in new OSI format. 	
        if (pNxCoreMsg->coreHeader.pnxOptionHdr->pnxsDateAndStrike->String[1]==' ')			
        {
        // Construct OSI symbol
        printf("Symbol:  %s%02d%02d%02d%c%08d\n",               
               pNxCoreMsg->coreHeader.pnxStringSymbol->String,
               pNxCoreMsg->coreHeader.pnxOptionHdr->nxExpirationDate.Year-2000,
               pNxCoreMsg->coreHeader.pnxOptionHdr->nxExpirationDate.Month,
               pNxCoreMsg->coreHeader.pnxOptionHdr->nxExpirationDate.Day,
               (pNxCoreMsg->coreHeader.pnxOptionHdr->PutCall == 0) ? 'C' : 'P',
               pNxCoreMsg->coreHeader.pnxOptionHdr->strikePrice);
        }
        // Otherwise the symbol is in old OPRA format.
        else
        {
            printf("Symbol: %s%c%c\n",                   
                   pNxCoreMsg->coreHeader.pnxStringSymbol->String,
                   pNxCoreMsg->coreHeader.pnxOptionHdr->pnxsDateAndStrike->String[0],
                   pNxCoreMsg->coreHeader.pnxOptionHdr->pnxsDateAndStrike->String[1]);	  
        }
    }
    // Else non-option, print symbol only
    else
        printf("Symbol: %s\n",pNxCoreMsg->coreHeader.pnxStringSymbol->String); 			 
}    
 
int __stdcall nxCoreCallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMessage)
{
    switch (pNxCoreMessage->MessageType)
    {
        case NxMSG_SYMBOLSPIN:
             PrintSymbol(pNxCoreMessage);            
             break;
        
        case NxMSG_STATUS:
        {
            switch (pNxCoreSys->Status)
            {
                case NxCORESTATUS_SYMBOLSPIN:
                {
                    if (pNxCoreSys->StatusData == NxCSSYMBOLSPIN_STARTING)
                    {
                        printf("\nInitial Symbol Spin Starting!\n");
                    }
                    if (pNxCoreSys->StatusData == NxCSSYMBOLSPIN_COMPLETE)
                    {
                        printf("\nInitial Symbol Spin Complete!\n");
                    }
                    break;
                }
            }
            break;
        }
    }    
 
    return NxCALLBACKRETURN_CONTINUE;
}    
 
int main(int argc, char** argv)
{
    if (!nxCoreClass.LoadNxCore("NxCoreAPI.dll") &&
        !nxCoreClass.LoadNxCore("C:\\Program Files\\Nanex\\NxCoreAPI\\NxCoreAPI.dll"))
    {
        fprintf(stderr, "Can't find NxCoreAPI.dll\n");
        return -1;
    }    
 
    nxCoreClass.ProcessTape(argv[1], 0, NxCF_EXCLUDE_CRC_CHECK, 0, nxCoreCallback);    
 
    return 0;
}