API Documentation

Syntax

Removes a permission ID from being processed from the tape

    typedef int(__stdcall *NxCoreExcludeOpraExch) (int);
    #define cszNxCoreExcludeOpraExch			"sNxCoreExcludeOpraExch"
    int ExcludeOpraExch(int removeID);

Parameters

removeKey

This key is a bitwise OR combination of a control flag and a permission ID. The control flag to remove a permission ID is NxPERMID_REMOVE(0x00100000) A list permission IDs can be found in the NxST_PERMID string table.

Return Value

Returns one of the following values

#define in NxCoreAPI.h Int Description
NxAPIERR_NO_ERROR 0 The operation was completed succesfully
1 The permission table has not been loaded or the permission is invalid
NxAPIERR_NOT_CALLBACK_THREAD -1 Function was called from thread other than callback thread
NxAPIERR_BAD_PARAMETERS -2 removeKey value was invalid

Proper use

To avoid tape errors, this function should not be used to split individual symbols. So, if a symbol comes under more than one permission ID, then you can either remove none or all of those permission ID.

Example

Here's an example of how to process CTA and UTP on separate threads. This example utilizes NxCoreTableHelper.h.

#include <stdio.h>
#include <vector>
#include <thread>
#include <iomanip>

#include <NxCoreAPI_Wrapper_C++.h>     
#include "NxCoreTableHelper.h"


struct ThreadData {
    int threadNum;
    std::vector<int> permissions;
    bool removed = false;
};

#define MAXID 128
NxCoreClass NxCore;
thread_local ThreadData myThreadData;

void onNxCoreStatus(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMsg) {
    //Print time
    if (pNxCoreSys->ClockUpdateInterval >= NxCLOCK_MINUTE && pNxCoreSys->nxTime.Hour < 24) {
        cout.fill('0');
        cout << "Thread: " << myThreadData.threadNum << " NxCoreTime: " <<
            setw(2) << (int)pNxCoreSys->nxTime.Hour << ":" <<
            setw(2) << (int)pNxCoreSys->nxTime.Minute << ":" <<
            setw(2) << (int)pNxCoreSys->nxTime.Second << endl;
    }
    
    //Log Errors. Errors NxCA_EXCEPTION_OPTSYMBOL(10) and NxCA_EXCEPTION_SYMBOL(11) indicate 
    //a permission was removed that shouldn't be. See Proper Use section for more details.
    if (pNxCoreSys->Status == NxCORESTATUS_ERROR)
        cout << "Tape Error: " << pNxCoreSys->StatusData << " on thread " << myThreadData.threadNum << endl;
    
    //Remove unwanted permissions
    if (!myThreadData.removed) {
        for (int perm = 1; perm < MAXID; ++perm) {
            if (std::find(myThreadData.permissions.begin(), myThreadData.permissions.end(), perm) != myThreadData.permissions.end())// this permission should be processed on this thread, so do not remove
                continue;
            int removeKey = NxPERMID_REMOVE | perm;
            int result = NxCore.ExcludeOpraExch(removeKey);
            if (result != 0) {//non-zero result indicates failure
                if (result == -1)
                    cout << "Function was called from thread other than callback thread" << endl;
                if (result == -2)
                    cout << "removeKey value was invalid" << endl;
                return;// could not remove permission during this status message. Try again next status message.
            }
        }
        //successfully removed all permissions
        myThreadData.removed = true;
    }
}

int __stdcall nxCoreCallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMsg) {
    switch (pNxCoreMsg->MessageType) {
    case NxMSG_STATUS:
        onNxCoreStatus(pNxCoreSys, pNxCoreMsg);
            break;
    }
    return NxCALLBACKRETURN_CONTINUE;
}

void thProcess(const char* tapepath, int threadNum, std::vector<int> permissions) {
    //save thread information to thread_local object to be used during callback
    myThreadData.permissions = permissions;
    myThreadData.threadNum = threadNum;

    int returnValue = NxCore.ProcessTape(tapepath, 0, NxCF_EXCLUDE_CRC_CHECK, 0, (NxCoreCallback)nxCoreCallback);
    cout << "Thread " << threadNum << " completed: Status follows..." << endl;
    NxCore.ProcessReturnValue(returnValue);
}

int main(int argc, char* argv[])
{
    if (NxCore.LoadNxCore("NxCoreAPI64.dll")) {
        std::vector<std::thread> threads;

        //Create CTA feed thread
        threads.push_back(std::thread(thProcess, argc > 1 ? argv[1] : "", 0,
        std::vector<int>{nxST_PERMID::NYSEQTE, nxST_PERMID::AMEXQTE, nxST_PERMID::NYSETRD, nxST_PERMID::AMEXTRD, nxST_PERMID::NYSECORP, nxST_PERMID::AMEXCORP}
        ));
        //Create UTP feed thread
        threads.push_back(std::thread(thProcess, argc > 1 ? argv[1] : "", 1,
        std::vector<int>{nxST_PERMID::NASDQTE, nxST_PERMID::NASDTRD}
        ));
        
        //Wait for threads to finish
        for (std::thread& thread : threads)
            thread.join();

        // Unload NxCore DLL
        NxCore.UnloadNxCore();
    }
    else {
        cout << "loading library failed" << endl;
        return -1;
    }
    return 0;
}
import java.util.*;
import net.nanex.NxCoreClass;
class ExcludeOpraExchSample {
    public static void main(String args[]) throws InterruptedException {

        Thread[] threads = {
            //create CTA feed thread
            //permissions: NYSEQTE(13), AMEXQTE(14), NYSETRD(17), AMEXTRD(18), NYSECORP(90), AMEXCORP(91)
            new Thread(new NxCoreThread(args.length > 0 ?  args[0] : "", 1, Arrays.asList(13, 14, 17, 18, 90, 91))),
            //create UTP feed thread
            //permissions: NASDQTE(6), NASDTRD(9)
            new Thread(new NxCoreThread(args.length > 0 ? args[0] : "", 2, Arrays.asList(1, 6, 9)))
        };
        for(Thread thread : threads)
            thread.start();
        for(Thread thread : threads)
            thread.join();
    }
}

class NxCoreThread extends NxCoreClass implements Runnable {
    private String tapepath;
    private int threadNum;
    private List<Integer> permissions;
    private boolean removed = false;
    private final int MAXID = 128;
    
    public NxCoreThread(String tapePath, int threadNum, List<Integer> permissions) {
        this.tapepath = tapePath;
        this.threadNum = threadNum;
        this.permissions = permissions;
    }
    
    public void run() {
        if(LoadNxCore("NxCoreAPI64.dll") != 0){
            int returnValue = ProcessTape(tapepath, 0, defines.NxCF_EXCLUDE_CRC_CHECK, 0);
            ProcessReturnValue(returnValue);
        }
        else
            System.out.println("loading library failed");
    }
    
    void onNxCoreStatus( NxCoreSystem nxCoreSys, NxCoreMessage nxCoreMsg) {
        //Print time
        if (nxCoreSys.ClockUpdateInterval >= defines.NxCLOCK_MINUTE && nxCoreSys.nxTime.Hour < 24) {
            System.out.println(String.format("Thread: %d NxCoreTime: %02d:%02d:%02d",
                threadNum,
                nxCoreSys.nxTime.Hour,
                nxCoreSys.nxTime.Minute,
                nxCoreSys.nxTime.Second));
        }
        
        //Log Errors. Errors NxCA_EXCEPTION_OPTSYMBOL(10) and NxCA_EXCEPTION_SYMBOL(11) indicate 
        //a permission was removed that shouldn't be. See Proper Use section for more details.
        if (nxCoreSys.Status == defines.NxCORESTATUS_ERROR)
            System.out.println("Tape Error: " + nxCoreSys.StatusData + " on thread " + threadNum);
        
        //Remove unwanted permissions
        if (!removed) {
            for (int perm = 1; perm < MAXID;perm ++) {
                if (permissions.contains(perm))// this permission should be processed on this thread, so do not remove
                    continue;
                int removeKey = defines.NxPERMID_REMOVE | perm;
                int result = ExcludeOpraExch(removeKey);
                if (result != 0) {//non-zero result indicates failure
                    if (result == -1)
                        System.out.println("Function was called from thread other than callback thread");
                    if (result == -2)
                        System.out.println("removeKey value was invalid");
                    return;// could not remove permission during this status message. Try again next status message.
                }
            }
            //Successfully removed unwanted permissions
            removed = true;
        }
    }
    
    @Override
    public int OnNxCoreCallback( NxCoreSystem nxCoreSys, NxCoreMessage nxCoreMsg) {
        if (nxCoreMsg.MessageType == defines.NxMSG_STATUS)
            onNxCoreStatus(nxCoreSys, nxCoreMsg);
        return defines.NxCALLBACKRETURN_CONTINUE;
    }
}
import NxCore
from multiprocessing import Process

tapePath = ""

MAXID = 128

#Process varibles
permissions = set()
removed = False
threadNum = 0

def onNxCoreStatus(NxCoreSys, NxCoreMsg):
    #Print time
    if NxCoreSys.ClockUpdateInterval >= NxCore.NxCLOCK_MINUTE and NxCoreSys.nxTime.Hour < 24:
        print("Thread: {} NxCoreTime: {:02d}:{:02d}:{:02d}".format(
            threadNum,
            NxCoreSys.nxTime.Hour,
            NxCoreSys.nxTime.Minute,
            NxCoreSys.nxTime.Second))
    
    #Log Errors. Errors NxCA_EXCEPTION_OPTSYMBOL(10) and NxCA_EXCEPTION_SYMBOL(11) indicate 
    #a permission was removed that shouldn't be. See Proper Use section for more details.
    if NxCoreSys.Status == NxCore.NxCORESTATUS_ERROR:
        print("Tape Error: {} on thread {}".format(NxCoreSys.StatusData, threadNum))
    
    #Remove unwanted permissions
    global removed
    if not removed:
        print(permissions)
        for perm in range(1, MAXID):
            if perm in permissions:# this permission should be processed on this thread, so do not remove
                continue
            removeKey = NxCore.NxPERMID_REMOVE | perm
            result = NxCore.ExcludeOpraExch(removeKey)
            if result != 0:#non-zero result indicates failure
                if result == -1:
                    print("Function was called from thread other than callback thread")
                if result == -2:
                    print("removeKey value was invalid")
                return# could not remove permission during this status message. Try again next status message.
        #Successfully removed unwanted permissions
        removed = True

def OnNxCoreCallback(NxCoreSys, NxCoreMsg):
    if NxCoreMsg.MessageType == NxCore.NxMSG_STATUS:
        onNxCoreStatus(NxCoreSys, NxCoreMsg)
    return NxCore.NxCALLBACKRETURN_CONTINUE

def NxCoreThread(permissionList, threadNumber):
    #set variables specific to this process
    global permissions
    global threadNum
    permissions = set(permissionList)
    threadNum = threadNumber
    
    #start processing NxCore Tape
    if NxCore.LoadNxCore("NxCoreAPI64.dll"):
        returnValue = NxCore.ProcessTape(tapePath, 0, NxCore.NxCF_EXCLUDE_CRC_CHECK, 0, OnNxCoreCallback)
        ProcessReturnValue(returnValue)
    else:
        print("loading library failed")
    
    
if __name__ == "__main__":
    threads = []
    #create CTA feed thread
    #permissions: NYSEQTE(13), AMEXQTE(14), NYSETRD(17), AMEXTRD(18), NYSECORP(90), AMEXCORP(91)
    threads.append(Process(target=NxCoreThread, args=([13, 14, 17, 18, 90, 91],1 )))
    #create UTP feed thread
    #permissions: NASDQTE(6), NASDTRD(9)
    threads.append(Process(target=NxCoreThread, args=([6,9],2 )))

    for thread in threads:
        thread.start()

    for thread in threads:
        thread.join()