Table of Contents


NxMSG_MMQUOTE message

The second parameter to the NxCoreCallback function, NxCoreMessage, holds the symbol and session information in pNxCoreMessage->coreHeader, and data information in pNxCoreMessage->coreData.MMQuote, which is a NxCoreMMQuote data structure.

Sent for every Market Maker Quote ("level 2") from either Nasdaq SuperMontage, Intermarket quotes on Nasdaq issues (e.g. Cincinnati -- ISLD, pacific -- ARCA), or Nasdaq Intermarket quotes on listed (NYSE/AMEX) securities. A typical trading day will have 40+ million or so of these messages. MMQuotes contain Market Maker identifiers and quote types in addition to bid and ask prices, sizes, condition codes and price/size changes. For depth messages, the market makers will be D1/D2/D3/D4/D5/D6/D7/D8/D9/D10 to signify the 5 or 10 levels of depth

Simplest example

Here's the simplest example.

#include "NxCoreAPI.h"
int processNxCoreMMQuote(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMsg)
{
    return NxCALLBACKRETURN_CONTINUE;
}
int __stdcall OnNxCoreCallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMsg)
{
    switch( pNxCoreMsg->MessageType ) {
        case NxMSG_STATUS:       break;
        case NxMSG_EXGQUOTE:     break;
        case NxMSG_MMQUOTE:      return processNxCoreMMQuote(pNxCoreSys, pNxCoreMsg);
        case NxMSG_TRADE:        break;
        case NxMSG_CATEGORY:     break;
        case NxMSG_SYMBOLCHANGE: break;
        case NxMSG_SYMBOLSPIN:   break;
    }
    return NxCALLBACKRETURN_CONTINUE;
}

Example

Here's an example of printing out every Level 2 quote that happens

#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <stdio.h>
#include "NxCoreAPI.h"
#include "NxCoreAPI_class.h"    
  
NxCoreClass nxCoreClass;    
  
int __stdcall nxCoreCallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMessage)
{
    switch (pNxCoreMessage->MessageType)
    {
        case NxMSG_MMQUOTE:
        {
            const NxCoreHeader&   ch = pNxCoreMessage->coreHeader;
            const NxCoreMMQuote&  mm = pNxCoreMessage->coreData.MMQuote;
            const NxCoreQuote&    cq = mm.coreQuote;
            const NxTime& t = pNxCoreSys->nxTime;    
       
            char buf[1024] = {0};
            char* p = buf;    
    
            if (cq.BidPriceChange || cq.BidSizeChange)
            {
                p += sprintf(p, "MM_bid(%ld @ %.2lf)[%s|%ld] ",
                    cq.BidSize,
                    nxCoreClass.PriceToDouble(cq.BidPrice, cq.PriceType),
                    mm.pnxStringMarketMaker->String,
                    ch.ReportingExg);
            }
            if (cq.AskPriceChange || cq.AskSizeChange)
            {
                p += sprintf(p, "MM_ask(%ld @ %.2lf)[%s|%ld] ",
                    cq.AskSize,
                    nxCoreClass.PriceToDouble(cq.AskPrice, cq.PriceType),
                    mm.pnxStringMarketMaker->String,
                    ch.ReportingExg);
            }
            if (p > buf)
            {
                printf("%.2d:%.2d:%.2d.%.3d %s %s\n",
                    (int) t.Hour, (int) t.Minute, (int) t.Second, (int) t.Millisecond,
                    pNxCoreMessage->coreHeader.pnxStringSymbol->String, buf);
            }    
    
            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;
    }
    nxCoreClass.ProcessTape(argv[1], 0, NxCF_EXCLUDE_CRC_CHECK, 0, nxCoreCallback);
    return 0;
}