API Documentation

Language: C++ Java Python C C#
Basic: Intro/Trade Quote Category Status Symbol Options
Detailed: Trade Quote

Detailed Quotes

This guide assumes you have already read the "Introduction to Quotes" guide. This guide will processing market maker quotes and NBBO from exchange quotes.

Code

#include "stdio.h"
#include "NxCoreAPI_Wrapper_C.h"

int OnNxCoreCallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMsg) {
    if (pNxCoreMsg->MessageType == NxMSG_MMQUOTE) {

        const NxCoreHeader* pHeader = &pNxCoreMsg->coreHeader;
        char* symbol = pHeader->pnxStringSymbol->String;
        const NxTime* pTimestamp = &pHeader->nxExgTimestamp;

        const NxCoreMMQuote* pQuote = &pNxCoreMsg->coreData.MMQuote;
        const NxCoreQuote* pCoreQuote = &pQuote->coreQuote;
        char* marketMaker = pQuote->pnxStringMarketMaker->String;
        int sizeBid = pCoreQuote->BidSize;
        int sizeAsk = pCoreQuote->AskSize;
        double priceBid = pfNxCorePriceToDouble(pCoreQuote->BidPrice, pCoreQuote->PriceType);
        double priceAsk = pfNxCorePriceToDouble(pCoreQuote->AskPrice, pCoreQuote->PriceType);

        printf("Market Maker Quote for %s at %02d:%02d:%02d by: %s Bid: %d lots at $%.2f Ask: %d lots at $%.2f\n",
            symbol, pTimestamp->Hour, pTimestamp->Minute, pTimestamp->Second,
            marketMaker, sizeBid, priceBid, sizeAsk, priceAsk);
    }
    if(pNxCoreMsg->MessageType == NxMSG_EXGQUOTE) {
        
        const NxCoreHeader* pHeader = &pNxCoreMsg->coreHeader;
        char* symbol = pHeader->pnxStringSymbol->String;
        const NxTime* pTimestamp = &pHeader->nxExgTimestamp;
        
        const NxCoreExgQuote* pQuote = &pNxCoreMsg->coreData.ExgQuote;
        if (!pQuote->BBOChangeFlags)
            return NxCALLBACKRETURN_CONTINUE;
        int sizeBid = pQuote->BestBidSize;
        int sizeAsk = pQuote->BestAskSize;
        double priceBid = pfNxCorePriceToDouble(pQuote->BestBidPrice, pQuote->coreQuote.PriceType);
        double priceAsk = pfNxCorePriceToDouble(pQuote->BestAskPrice, pQuote->coreQuote.PriceType);
        
        printf("New NBBO Quote for %s at %02d:%02d:%02d Bid: %d lots at $%.2f Ask: %d lots at $%.2f\n",
            symbol, pTimestamp->Hour, pTimestamp->Minute, pTimestamp->Second,
            sizeBid, priceBid, sizeAsk, priceAsk);
    }
    return NxCALLBACKRETURN_CONTINUE;  
}

int main(int argc, char* argv[]) {
    if (argc < 3)
        return 1;

    if (LoadNxCore(argv[1])){
        int returnValue = pfNxCoreProcessTape(argv[2], 0, 0, 0, OnNxCoreCallback);
        processReturnValue(returnValue);
    }
    else
        printf("loading library failed\n");

    return 0;
}

Market Maker Quote

NxMSG_MMQUOTE type messages are used for both Market Maker quotes (often referred to as Level 2 quotes) as well as market by price books. The pnxStringMarketMaker field contains either the Market Maker ID or "D" followed by the depth in the book.

if (pNxCoreMsg->MessageType == NxMSG_MMQUOTE) {
    ...
        const NxCoreMMQuote* pQuote = &pNxCoreMsg->coreData.MMQuote;
        const NxCoreQuote* pCoreQuote = &pQuote->coreQuote;
        char* marketMaker = pQuote->pnxStringMarketMaker->String;
        int sizeBid = pCoreQuote->BidSize;
        int sizeAsk = pCoreQuote->AskSize;
        double priceBid = pfNxCorePriceToDouble(
		    pCoreQuote->BidPrice, pCoreQuote->PriceType);
        double priceAsk = pfNxCorePriceToDouble(
		    pCoreQuote->AskPrice, pCoreQuote->PriceType);
    ...
}

NBBO Quote

For feeds with multiple reporting exchanges, an NBBO will be maintained in the ExgQuote object. BBOChangeFlags is a bitmap of which fields in the NBBO changed as the result of the exchange quote in coreQuote. The price type for the NBBO prices is PriceType in coreQuote.

if(pNxCoreMsg->MessageType == NxMSG_EXGQUOTE) {
    ...
    const NxCoreExgQuote* pQuote = &pNxCoreMsg->coreData.ExgQuote;
    if (!pQuote->BBOChangeFlags)
        return NxCALLBACKRETURN_CONTINUE;
    int sizeBid = pQuote->BestBidSize;
    int sizeAsk = pQuote->BestAskSize;
    double priceBid = pfNxCorePriceToDouble(
	    pQuote->BestBidPrice, pQuote->coreQuote.PriceType);
    double priceAsk = pfNxCorePriceToDouble(
	    pQuote->BestAskPrice, pQuote->coreQuote.PriceType);
    ...
}

Next:
Category