API Documentation

Example (code and executable here)

Here's an example of SigHiLo processing

#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <stdio.h>    
  
#include "NxCoreAPI.h"
#include "NxCoreAPI_class.h"    
  
static NxCoreClass nxCoreClass;    
  
static const char *symbol = "eAAPL"; // Symbol to use if no arg passed in    
  
static int __stdcall nxCoreCallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMessage)
{
    switch (pNxCoreMessage->MessageType)
    {
        case NxMSG_TRADE:
        {
            NxString *nx = pNxCoreMessage->coreHeader.pnxStringSymbol;    
  
            // If this symbol has been stamped with a 1, exit, not the sym we are looking for
            if (nx->UserData1 == 1)
            {
                break;
            }    
  
            // If UserData is 0, and the symbol is not a match to the one we are looking for...
            if (nx->UserData1 == 0 && strcmp(nx->String, symbol))
            {
                // Stamp it with a 1 
                nx->UserData1 = 1;
                break;
            }    
  
            // Otherwise this is the symbol we want, stamp it with a 2
            nx->UserData1 = 2;    
  
   
            // Set a trade data ptr
            const NxCoreTrade  &nt = pNxCoreMessage->coreData.Trade;    
  
            // ignore any trades that
            if ((nt.PriceFlags & NxTPF_EXGCANCEL) || // are cancels
                nt.nxAnalysis.FilterLevel >= 6)      // are dubious based on filtering
            {
                break;
            }    
  
            const NxCoreHeader &ch = pNxCoreMessage->coreHeader;    
  
            const NxTime &et = ch.nxExgTimestamp;    
  
            int secs = et.MsOfDay / 1000 - (nt.nxAnalysis.SigHiLoSeconds + 15);    
  
            NxTime st;
            st.Hour   = secs / 3600;
            st.Minute = (secs / 60) % 60;
            st.Second = secs % 60;    
  
            const char *p = nt.nxAnalysis.SigHiLoType == NxRTA_SIGHL_LOWEST  ? "Lowest" :
                            nt.nxAnalysis.SigHiLoType == NxRTA_SIGHL_LOW     ? "Low" :
                            nt.nxAnalysis.SigHiLoType == NxRTA_SIGHL_HIGH    ? "High" :
                            nt.nxAnalysis.SigHiLoType == NxRTA_SIGHL_HIGHEST ? "Highest" : "Same";    
  
            printf("%.2d:%.2d:%.2d %6ld %.2lf %8s %6ld %.2d:%.2d:%.2d %d %ld\n",
                (int) et.Hour, (int) et.Minute, (int) et.Second,
                nt.Size,
                nxCoreClass.PriceToDouble(nt.Price, nt.PriceType),
                p,
                nt.nxAnalysis.SigHiLoSeconds,
                (int) st.Hour, (int) st.Minute, (int) st.Second,
                ch.ReportingExg,
                nt.ExgSequence
                );    
  
            break;
        }
    }    
  
    return NxCALLBACKRETURN_CONTINUE;
}    
  
int main(int argc, char** argv)
{
    if (!nxCoreClass.LoadNxCore("NxCoreAPI.dll") &&
        !nxCoreClass.LoadNxCore("C:\\Program Files\\Nanex\\NxCoreAPI\\NxCoreAPI.dll"))
    {
        fprintf(stderr, "Can't find NxCoreAPI.dll\n");
        return -1;
    }    
  
    // Pass a symbol as the second argument, otherwise the default of 'eAAPL' will be used
    if (argc > 2)
    {
        symbol = argv[2];
    }    
  
    nxCoreClass.ProcessTape(argv[1], 0, NxCF_EXCLUDE_CRC_CHECK | NxCF_EXCLUDE_QUOTES | NxCF_EXCLUDE_QUOTES2 | NxCF_EXCLUDE_OPRA, 0, nxCoreCallback);    
  
    return 0;
}