API Documentation

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 <stdio.h>
#include "NxCoreAPI.h"
#include "NxCoreAPI_Wrapper_C++.h"              
              
NxCoreClass NxCore;
 
const char* getSymbol(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("%02d:%02d:%02d.%03d ADD %s:%d\n",
                        (int) ch.nxExgTimestamp.Hour,
                        (int) ch.nxExgTimestamp.Minute,
                        (int) ch.nxExgTimestamp.Second,
                        (int) ch.nxExgTimestamp.Millisecond,
                        getSymbol(symN, ch.pnxStringSymbol, ch.pnxOptionHdr), ch.ListedExg);
                    break;
                case NxSS_DEL:
                    printf("%02d:%02d:%02d.%03d DEL %s:%d\n",
                        (int) ch.nxExgTimestamp.Hour,
                        (int) ch.nxExgTimestamp.Minute,
                        (int) ch.nxExgTimestamp.Second,
                        (int) ch.nxExgTimestamp.Millisecond,
                        getSymbol(symO, ch.pnxStringSymbol, ch.pnxOptionHdr), ch.ListedExg);
                    break;
                case NxSS_MOD:
                    printf("%02d:%02d:%02d.%03d MOD %s:%ld -> %s:%d\n",
                        (int) ch.nxExgTimestamp.Hour,
                        (int) ch.nxExgTimestamp.Minute,
                        (int) ch.nxExgTimestamp.Second,
                        (int) ch.nxExgTimestamp.Millisecond,
                        getSymbol(symN, sc.pnxsSymbolOld,   sc.pnxOptionHdrOld), sc.ListedExgOld,
                        getSymbol(symO, ch.pnxStringSymbol, ch.pnxOptionHdr), ch.ListedExg);
                    break;
            }
            break;
    }
    return NxCALLBACKRETURN_CONTINUE;
}

int main(int argc, char** argv)
{
    if (!NxCore.LoadNxCore("NxCoreAPI64.dll") &&
        !NxCore.LoadNxCore("NxCoreAPI.dll"))
    {
        printf("loading library failed\n");
        return -1;
    }
    NxCore.ProcessTape(argv[1], 0, NxCF_EXCLUDE_CRC_CHECK, 0, nxCoreCallback);
    return 0;
}
import net.nanex.NxCoreClass;
class SymbolChangeSample extends NxCoreClass{
    
    String getSymbol( NxString nx, NxOptionHdr oh) {
        // If an option
        if (oh != null) {
            // If oh.pnxsDateAndStrike.String.charAt(1) == ' ', then this symbol is in new OSI format.     
            if (oh.pnxsDateAndStrike.String.charAt(1) == ' ') {
                return String.format("%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 {
                return String.format("%s%c%c",
                        nx.String,
                        oh.pnxsDateAndStrike.String.charAt(0),
                        oh.pnxsDateAndStrike.String.charAt(1));
            }
        }
        // otherwise a non-option
        return String.format("%s", nx.String);
    }
    
    @Override
    public int OnNxCoreCallback(NxCoreSystem nxCoreSys, NxCoreMessage nxCoreMsg) {
        switch (nxCoreMsg.MessageType) {
            case defines.NxMSG_SYMBOLCHANGE:
                NxCoreSymbolChange sc = nxCoreMsg.coreData.SymbolChange;
                NxCoreHeader       ch = nxCoreMsg.coreHeader;
    
                switch (sc.Status)
                {
                    case defines.NxSS_ADD:
                        System.out.println(String.format("%02d:%02d:%02d.%03d ADD %s:%d",
                            ch.nxExgTimestamp.Hour,
                            ch.nxExgTimestamp.Minute,
                            ch.nxExgTimestamp.Second,
                            ch.nxExgTimestamp.Millisecond,
                            getSymbol(ch.pnxStringSymbol, ch.pnxOptionHdr), ch.ListedExg));
                        break;
                    
                    case defines.NxSS_DEL:
                        System.out.println(String.format("%02d:%02d:%02d.%03d DEL %s:%d",
                            ch.nxExgTimestamp.Hour,
                            ch.nxExgTimestamp.Minute,
                            ch.nxExgTimestamp.Second,
                            ch.nxExgTimestamp.Millisecond,
                            getSymbol(ch.pnxStringSymbol, ch.pnxOptionHdr), ch.ListedExg));
                        break;
                    
                    case defines.NxSS_MOD:
                        System.out.println(String.format("%02d:%02d:%02d.%03d MOD %s:%d -> %s:%d",
                            ch.nxExgTimestamp.Hour,
                            ch.nxExgTimestamp.Minute,
                            ch.nxExgTimestamp.Second,
                            ch.nxExgTimestamp.Millisecond,
                            getSymbol(sc.pnxsSymbolOld,   sc.pnxOptionHdrOld), sc.ListedExgOld,
                            getSymbol(ch.pnxStringSymbol, ch.pnxOptionHdr), ch.ListedExg));
                        break;
                }
            break;
        }
        return defines.NxCALLBACKRETURN_CONTINUE;
    }

    public static void main(String args[]) {
        SymbolChangeSample nxCore = new SymbolChangeSample();

        if (nxCore.LoadNxCore("NxCoreAPI64.dll") != 0){
            nxCore.ProcessTape(args[0], 0, defines.NxCF_EXCLUDE_CRC_CHECK, 0);
        }
        else
            System.out.println("loading library failed");
    }
}
import NxCore

tapePath = ""
def getSymbol(nx, oh):
    # If an option
    if oh:
        # If oh.pnxsDateAndStrike.String[1] == ' ', then this symbol is in new OSI format.     
        if oh.pnxsDateAndStrike.String[1] == ' ':    
            return "{}{:02d}{:02d}{:02d}{}{:08d}".format(
                nx.String,
                oh.nxExpirationDate.Year-2000,
                oh.nxExpirationDate.Month,
                oh.nxExpirationDate.Day,
                'C' if oh.PutCall == 0 else 'P',
                oh.strikePrice)
        # Otherwise the symbol is in old OPRA format.
        else:
            return "{}{}{}".format(
                nx.String,
                oh.pnxsDateAndStrike.String[0],
                oh.pnxsDateAndStrike.String[1])
    # otherwise a non-option
    return nx.String
    
def OnNxCoreCallback(NxCoreSys, NxCoreMsg):
    if NxCoreMsg.MessageType == NxCore.NxMSG_SYMBOLCHANGE:
        sc = NxCoreMsg.coreData.SymbolChange
        ch = NxCoreMsg.coreHeader
        
        if sc.Status == NxCore.NxSS_ADD:
            print("{:02d}:{:02d}:{:02d}.{:03d} ADD {}:{}".format(
                ch.nxExgTimestamp.Hour,
                ch.nxExgTimestamp.Minute,
                ch.nxExgTimestamp.Second,
                ch.nxExgTimestamp.Millisecond,
                getSymbol(ch.pnxStringSymbol, ch.pnxOptionHdr), ch.ListedExg))
        if sc.Status == NxCore.NxSS_DEL:
            print("{:02d}:{:02d}:{:02d}.{:03d} DEL {}:{}".format(
                ch.nxExgTimestamp.Hour,
                ch.nxExgTimestamp.Minute,
                ch.nxExgTimestamp.Second,
                ch.nxExgTimestamp.Millisecond,
                getSymbol(ch.pnxStringSymbol, ch.pnxOptionHdr), ch.ListedExg))
        if sc.Status == NxCore.NxSS_MOD:
            print("{:02d}:{:02d}:{:02d}.{:03d} MOD {}:{} -> {}:{}".format(
                ch.nxExgTimestamp.Hour,
                ch.nxExgTimestamp.Minute,
                ch.nxExgTimestamp.Second,
                ch.nxExgTimestamp.Millisecond,
                getSymbol(sc.pnxsSymbolOld,   sc.pnxOptionHdrOld), sc.ListedExgOld,
                getSymbol(ch.pnxStringSymbol, ch.pnxOptionHdr), ch.ListedExg))
    return NxCore.NxCALLBACKRETURN_CONTINUE

if NxCore.LoadNxCore("NxCoreAPI64.dll"):
    returnValue = NxCore.ProcessTape(tapePath, 0, NxCore.NxCF_EXCLUDE_CRC_CHECK, 0, OnNxCoreCallback)
else:
    print("loading library failed")