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

import net.nanex.NxCoreClass;
class SymbolSample extends NxCoreClass{

    @Override
    public int OnNxCoreCallback(NxCoreSystem nxCoreSys, NxCoreMessage nxCoreMsg) {
        if (nxCoreMsg.MessageType == defines.NxMSG_SYMBOLSPIN) {
            NxCoreHeader header = nxCoreMsg.coreHeader;
            String symbol = header.pnxStringSymbol.String;
            String exchange = GetDefinedString(defines.NxST_EXCHANGE, header.ListedExg);

            System.out.println("symbol " + symbol + " is listed on " + exchange);
        }
        if (nxCoreMsg.MessageType == defines.NxMSG_SYMBOLCHANGE && nxCoreMsg.coreData.SymbolChange.Status == defines.NxSS_ADD) {
            NxCoreHeader header = nxCoreMsg.coreHeader;
            String symbol = header.pnxStringSymbol.String;
            String exchange = GetDefinedString(defines.NxST_EXCHANGE, header.ListedExg);

            System.out.println("new symbol " + symbol + " is listed on " + exchange);
        }
        return defines.NxCALLBACKRETURN_CONTINUE;
    }
	    
    public static void main(String args[]) {
        TradeSample nxCore = new TradeSample();

        if (args.length > 1 && nxCore.LoadNxCore(args[0]) != 0){
            int returnValue = nxCore.ProcessTape(args[1], 0, 0, 0);
            nxCore.ProcessReturnValue(returnValue);
        }
        else
            System.out.println("loading library failed");
    }
}

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 (nxCoreMsg.MessageType == defines.NxMSG_SYMBOLSPIN) {
    NxCoreHeader header = nxCoreMsg.coreHeader;
    String symbol = header.pnxStringSymbol.String;
    String exchange = GetDefinedString(
        defines.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 (nxCoreMsg.MessageType == defines.NxMSG_SYMBOLCHANGE
    && nxCoreMsg.coreData.SymbolChange.Status == defines.NxSS_ADD) {
    NxCoreHeader header = nxCoreMsg.coreHeader;
    String symbol = header.pnxStringSymbol.String;
    String exchange = GetDefinedString(
        defines.NxST_EXCHANGE, header.ListedExg);
    ...
}

Next:
Options