API Documentation

Language: C++ Java Python
Basic: Intro/Trade Quote Category Status Symbol Options
Detailed: Trade Quote

Introduction to Symbols

This guide assumes you have already read the "Getting Started With Trades" guide. All symbols will receive either a NxMSG_SYMBOLSPIN message or an add NxMSG_SYMBOLCHANGE message. Near the start of the tape, a symbol spin mesage is sent for all existing symbols. If a new symbol is added afterwards, then it receives a Symbol Change message instead. By looking at both of these message types it is possible to get a complete list of symbols.

Code

#include "stdio.h"
#include "NxCoreAPI_Wrapper_C++.h"
NxCoreClass NxCore;

int OnNxCoreCallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMsg) {
    if (pNxCoreMsg->MessageType == NxMSG_SYMBOLSPIN) {
        const NxCoreHeader& header = pNxCoreMsg->coreHeader;
        char* symbol = header.pnxStringSymbol->String;
        const char* exchange = NxCore.GetDefinedString(NxST_EXCHANGE, header.ListedExg);

        printf("symbol %s is listed on %s\n", symbol, exchange);
    }
    if (pNxCoreMsg->MessageType == NxMSG_SYMBOLCHANGE && pNxCoreMsg->coreData.SymbolChange.Status == NxSS_ADD) {
        const NxCoreHeader& header = pNxCoreMsg->coreHeader;
        char* symbol = header.pnxStringSymbol->String;
        const char* exchange = NxCore.GetDefinedString(NxST_EXCHANGE, header.ListedExg);

        printf("new symbol %s is listed on %s", symbol, exchange);
    }
    return NxCALLBACKRETURN_CONTINUE;
}

int main(int argc, char* argv[]) {
    if (argc < 3)
        return 1;

    if (NxCore.LoadNxCore(argv[1])){
        int returnValue = NxCore.ProcessTape(argv[2], 0, 0, 0, OnNxCoreCallback);
        NxCore.ProcessReturnValue(returnValue);
    }
    else
        printf("loading library failed\n");

    return 0;
}

Symbol Spin

Near the start of each tape a Symbol Spin message is sent for every symbol present at that time. coreHeader will be populated with the symbol information. Usually it will not be necessary to process the SymbolSpin object in coreData.

if (pNxCoreMsg->MessageType == NxMSG_SYMBOLSPIN) {
    const NxCoreHeader& header = pNxCoreMsg->coreHeader;
    char* symbol = header.pnxStringSymbol->String;
    const char* exchange = NxCore.GetDefinedString(
        NxST_EXCHANGE, header.ListedExg);
    ...
}

Symbol Change

Symbol Change messages can either be sent for newly added symbols or symbols that the source feed reports as deleted. The Status field indicates whether it is an added or deleted symbol.

if (pNxCoreMsg->MessageType == NxMSG_SYMBOLCHANGE
    && pNxCoreMsg->coreData.SymbolChange.Status == NxSS_ADD) {
    const NxCoreHeader& header = pNxCoreMsg->coreHeader;
    char* symbol = header.pnxStringSymbol->String;
    const char* exchange = NxCore.GetDefinedString(
        NxST_EXCHANGE, header.ListedExg);
    ...
}

Next:
Options