Table of Contents


NxMSG_SYMBOLCHANGE message

The second parameter to the NxCoreCallback function, NxCoreMessage, holds the symbol and session information in pNxCoreMessage->coreHeader, and data information in pNxCoreMessage->coreData.SymbolChange, which is a NxCoreSymbolChange data structure.

Sent when an issue changes symbols or trading venues (switches exchanges). The most frequent user of this message type are Nasdaq equities changing between Pink Sheets, Bulletin Board, Over-The-Counter, or when the adding/removing the fifth letter 'E' because of a change in delinquency filing status. Also, when option symbols change, each option contract in the series generates one of these messages. Usually the only task you need to perform to handle this type of message is to transfer any UserData1 or UserData2 values from the old symbol to the new symbol.

Simplest example

Here's the simplest example.

#include "NxCoreAPI.h"
int processNxCoreSymbolChange(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: return processNxCoreSymbolChange(pNxCoreSys, pNxCoreMsg);
        case NxMSG_SYMBOLSPIN:   break;
    }
    return NxCALLBACKRETURN_CONTINUE;
}

Example

Here's a simple example that prints out all symbol adds, deletes and changes.

#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <stdio.h>    
  
#include "NxCoreAPI.h"
#include "NxCoreAPI_class.h"    
 
static NxCoreClass nxCoreClass;    
 
inline const char* symbol(char* sym, NxString* nx, NxOptionHdr* oh)
{
    // If an option
    if (oh)
    {
        // If pnxsDateAndStrike->String[1] == ' ', then this symbol is in new OSI format. 	
        if (oh->pnxsDateAndStrike->String[1]==' ')	
        {
            sprintf(sym,"%s%02d%02d%02d%c%08d",
                    nx->String,
                    oh->nxExpirationDate.Year-2000,
                    oh->nxExpirationDate.Month,
                    oh->nxExpirationDate.Day,
                    (oh->PutCall == 0) ? 'C' : 'P',
                    oh->strikePrice);
        }
        // Otherwise the symbol is in old OPRA format.
        else
        {
            sprintf(sym,"%s%c%c",
                    nx->String,
                    oh->pnxsDateAndStrike->String[0],
                    oh->pnxsDateAndStrike->String[1]);
        }
    }
    // otherwise a non-option
    else
    {
        sprintf(sym, "%s", nx->String);
    }    
 
    return sym;
}    
 
int __stdcall nxCoreCallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMessage)
{
    switch (pNxCoreMessage->MessageType)
    {
        case NxMSG_SYMBOLCHANGE:
        {
            const NxCoreSymbolChange& sc = pNxCoreMessage->coreData.SymbolChange;
            const NxCoreHeader&       ch = pNxCoreMessage->coreHeader;
            char symN[128];
            char symO[128];    
 
            switch (sc.Status)
            {
                case NxSS_ADD:
                {
                    printf("%.2d:%.2d:%.2d.%.3d ADD %s:%ld\n",
                        (int) pNxCoreSys->nxTime.Hour,
                        (int) pNxCoreSys->nxTime.Minute,
                        (int) pNxCoreSys->nxTime.Second,
                        (int) pNxCoreSys->nxTime.Millisecond,
                        symbol(symN, ch.pnxStringSymbol, ch.pnxOptionHdr), ch.ListedExg);
                    break;
                }
                case NxSS_DEL:
                {
                    printf("%.2d:%.2d:%.2d.%.3d DEL %s:%ld\n",
                        (int) pNxCoreSys->nxTime.Hour,
                        (int) pNxCoreSys->nxTime.Minute,
                        (int) pNxCoreSys->nxTime.Second,
                        (int) pNxCoreSys->nxTime.Millisecond,
                        symbol(symO, ch.pnxStringSymbol, ch.pnxOptionHdr), ch.ListedExg);
                    break;
                }
                case NxSS_MOD:
                {
                    printf("%.2d:%.2d:%.2d.%.3d MOD %s:%ld -> %s:%ld\n",
                        (int) pNxCoreSys->nxTime.Hour,
                        (int) pNxCoreSys->nxTime.Minute,
                        (int) pNxCoreSys->nxTime.Second,
                        (int) pNxCoreSys->nxTime.Millisecond,
                        symbol(symN, sc.pnxsSymbolOld,   sc.pnxOptionHdrOld), sc.ListedExgOld,
                        symbol(symO, ch.pnxStringSymbol, ch.pnxOptionHdr), ch.ListedExg);
                    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;
}