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 combination of a control flag and a permission ID. 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 "NxCoreAPI_Wrapper_C++.h"  // NxCore C++ wrapper with NxCoreClass
#include <thread>
#include <cstdio>
#include <NxCoreTableHelper.h>

#define THREADS 2
#define MAXID 128
NxCoreClass NxCore;
typedef struct {
	std::thread *myThread;
	int         threadNum;
	bool        removed;
} ThreadData;

int g_remove[THREADS][MAXID] = {
{nxST_PERMID::NASDQTE, nxST_PERMID::NASDTRD},
{nxST_PERMID::NYSEQTE, nxST_PERMID::AMEXQTE, nxST_PERMID::NYSETRD, nxST_PERMID::AMEXTRD, nxST_PERMID::NYSECORP, nxST_PERMID::AMEXCORP}
};//nxST_PERMID::NYSECORP and nxST_PERMID::AMEXCORP should be included if you receive NYSE and AMEX corportate actions

thread_local ThreadData *myThreadData;

void ThreadProc(ThreadData *threadData);
int  OnNxCoreCallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMsg);

inline char *PrintTime(const NxCoreSystem* pNxCoreSys, char *timeBuf) {
	sprintf(timeBuf, "Thread %d: NxCoreTime: %02d:%02d:%02d ", myThreadData->threadNum,
		pNxCoreSys->nxTime.Hour, pNxCoreSys->nxTime.Minute, pNxCoreSys->nxTime.Second);
	return timeBuf;
}

int main(int argc, char* argv[])
{
	ThreadData thread[THREADS];

	if (NxCore.LoadNxCore("NxCoreAPI64.dll"))
    {
		for(int i = 0; i < THREADS; ++i) {
			thread[i].removed = 0;
			thread[i].threadNum = i;
			thread[i].myThread = new std::thread(ThreadProc, &thread[i]);
		}

		// Wait for threads to exit.
		for(int i = 0; i < THREADS; ++i) {
			thread[i].myThread->join();
			delete thread[i].myThread;
		}

		// Unload NxCore DLL
		NxCore.UnloadNxCore();
    }
    else {
	  cout << "Failed to load NxCore Library: " << dlerror() << endl;
	  exit(EXIT_FAILURE);
	}
	exit(EXIT_SUCCESS);
}

void ThreadProc(ThreadData *threadData) {
	int returnValue;
	myThreadData = threadData;
	returnValue = NxCore.ProcessTape("", nullptr, 0, 0, (NxCoreCallback)OnNxCoreCallback);
	cout << "Thread " << threadData->threadNum << " completed: Status follows..." << endl;
	NxCore.ProcessReturnValue(returnValue);
}

int OnNxCoreCallback(const NxCoreSystem* pNxCoreSys,const NxCoreMessage* pNxCoreMsg) {
	char timeBuf[64];
	switch (pNxCoreSys->Status) {
	case NxCORESTATUS_RUNNING:
		if ((pNxCoreSys->ClockUpdateInterval >= NxCLOCK_MINUTE)	&& (pNxCoreSys->nxTime.Hour < 24)) {
			cout << PrintTime(pNxCoreSys, timeBuf) << endl;
		}
		if (!myThreadData->removed) {
			for (int i = 0; i < MAXID; ++i) {
				if (g_remove[myThreadData->threadNum][i] == 0)
					continue;
				int removeKey, result;
				removeKey = NxPERMID_REMOVE | g_remove[myThreadData->threadNum][i];
				result = NxCore.ExcludeOpraExch(removeKey);
				switch (result) {
				case 0:
					g_remove[myThreadData->threadNum][i] = 0;
					break;
				case -1:
					cout << "Function was called from thread other than callback thread" << endl;
					break;
				case -2:
					cout << "removeKey value was invalid" << endl;
					break;
				case 1: //The permission table has not been loaded and the permission ID will be removed later or an invalid permission ID was passed in
					break;
				}
			}
			int j = 0;
			for (int i = 0; i < MAXID; ++i) {
				if (g_remove[myThreadData->threadNum][i] != 0)
					break;
				j++;
			}
			if (j == MAXID) {
				myThreadData->removed = true;
			}
		}
		break;
	case NxCORESTATUS_ERROR:
		cout << "Tape Error: " << pNxCoreSys->StatusData << " on thread " << myThreadData->threadNum << endl;
		break;
	}
    return NxCALLBACKRETURN_CONTINUE;
}