API Documentation

General

How do I ensure that I always use the correct DLLs and header files

You can use the header files from \Program Files\Nanex\NxCoreAPI, but you MUST copy the NxCoreAPI.dll to another location and always run it from there. This is for two reasons:

  1. to prevent the update from failing because the DLL is in use by your program
  2. to ensure that you have time to test the new DLL with your program.

Got a message about a "install failed" for new nxcoreapi version

You are running the NxCoreAPI.dll from \Program Files\Nanex\NxCoreAPI, and thus it cannot be changed. Read the above FAQ question as to how to change it. It is not imperative that you use the new one immediately -- you could wait until close, and the install will retry.

What hosts/ports does NxCore use?

Please contact nanex support (support@nanex.net) for host and port information.

How do I slow down the processing and/or simulate real-time speed like it is done in NxCoreAPI Viewer?

A very simple and close approximation during active trading is to sleep 25 milliseconds on every NxCore Clock change. During inactive periods of time, processing will be faster than real-time, but in many cases this is a desired feature. The following code illustrates how to accomplish this:


int __stdcall nxCoreAPICallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMsg)
{
    switch( pNxCoreMsg->MessageType ) {
        case NxMSG_STATUS:
            if( pNxCoreSys->ClockUpdateInterval )
                ::Sleep(25);
            break;
    }
    return NxCALLBACKRETURN_CONTINUE;
}

NxCoreAccess stopped seeing my network drives as archive drives?

If NxCoreAccess is started at boot time or by the NxCoreAccessService, it has a different permission level --- which doesn't have access to network drives.
Just start NxCoreAccess again (while it's running) and it will replace the current running one and (since started by you) will now have elevated privileges.

If I'm looking at a symbol in a tape, occassionally I see 2 NxLastQuote category messages, one with a reasonable price and one with an unreasonable price .. why do I see both?

A. When looking at categories, always check the Session Date which the category applies to: pNxCoreMessage->coreHeader.nxSessionDate. For some categories in some contexts, we may send out more than one of the same category for the same symbol. Those are always sent with most recent SessionDate first.

How do I speed up processing of a tape/stream?

There are six (6) main areas to talk about when we talk with customers about optimizing processing speed, these are broken down below:

1. Can you use the controlFlags in your call to ProcessTape to speed things up?

At a minimum I recommend using NxCF_EXCLUDE_CRC_CHECK. That will get you roughly 30% faster decoding right there. If you are not processing options, then use NxCF_EXCLUDE_OPRA and if you are not processing market maker quotes, use NxCF_EXCLUDE_QUOTES2. If you are not interested in exchange quotes, use NxCF_EXCLUDE_QUOTES.

2. Does using state files make sense for your needs?

If you need to quickly access (jump to) any particular time during a day, over and over, then this makes sense. You could have a process that generates state files automatically, and then when you want to access a tape file at a specific time you load up the state file closest in time, but still before, the time in question and begin processing from there. For example, if you had state files generating every 10 minutes, and wished to look at data from 09:48, you would load the state file from 09:40, and then only have to process eight minutes of tape before you got to where you wanted to be. SampleApp 10 demonstrates saving and loading from state files. Documentation for state files can be found here .

3. Do you need to process all quotes and trades or do you have a list of symbols (or types of symbols) you are interested in?

If you only want to look at a subset of all symbols, using UserData1 and UserData2 to "pair down" what data you are processing is a great way to speed up the process. We explain and give code examples for this process in our documentation here.

4. Have you multi-threaded your process?

While the NxCoreAPI is single-threaded, you can call ProcessTape in multiple threads or have multiple applications access the same tape. Using the ExcludeOpraExch function, you can process a subset of your tape on each thread.

5. Have you thoroughly optimized your callback?

Keep in mind that you callback is called for every message on the tape. Optimizing that code has a HUGE effect on overall performance. We see customer code frequently with O(n) or even O(n^2) searches in every callback: those are going to take a VERY long time when they are called millions of times.

6. Last, and certainly least, you can "throw hardware at the problem".

In almost every scenario, processing time scales linearly with single threaded CPU performance. You could always purchase/rent/lease/etc more CPU speed to process more quickly.