API Documentation

Language: C++ Java Python
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"
NxCoreClass NxCore;

int OnNxCoreCallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMsg) {
    if (pNxCoreMsg->MessageType == NxMSG_MMQUOTE) {
        
        const NxCoreHeader& header = pNxCoreMsg->coreHeader;
        char* symbol = header.pnxStringSymbol->String;
        const NxTime& timestamp = header.nxExgTimestamp;
        
        const NxCoreMMQuote& quote = pNxCoreMsg->coreData.MMQuote;
        const NxCoreQuote& coreQuote = quote.coreQuote;
        char* marketMaker = quote.pnxStringMarketMaker->String;
        int sizeBid = coreQuote.BidSize;
        int sizeAsk = coreQuote.AskSize;
        double priceBid = NxCore.PriceToDouble(coreQuote.BidPrice, coreQuote.PriceType);
        double priceAsk = NxCore.PriceToDouble(coreQuote.AskPrice, coreQuote.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, timestamp.Hour, timestamp.Minute, timestamp.Second,
            marketMaker, sizeBid, priceBid, sizeAsk, priceAsk);
    }
    if(pNxCoreMsg->MessageType == NxMSG_EXGQUOTE) {
        
        const NxCoreHeader& header = pNxCoreMsg->coreHeader;
        char* symbol = header.pnxStringSymbol->String;
        const NxTime& timestamp = header.nxExgTimestamp;
        
        const NxCoreExgQuote& quote = pNxCoreMsg->coreData.ExgQuote;
        if (!quote.BBOChangeFlags)
            return NxCALLBACKRETURN_CONTINUE;
        int sizeBid = quote.BestBidSize;
        int sizeAsk = quote.BestAskSize;
        double priceBid = NxCore.PriceToDouble(quote.BestBidPrice, quote.coreQuote.PriceType);
        double priceAsk = NxCore.PriceToDouble(quote.BestAskPrice, quote.coreQuote.PriceType);

        printf("New NBBO Quote for %s at %02d:%02d:%02d Bid: %d lots at $%.2f Ask: %d lots at $%.2f\n",
            symbol, timestamp.Hour, timestamp.Minute, timestamp.Second,
            sizeBid, priceBid, sizeAsk, priceAsk);
    }
    return NxCALLBACKRETURN_CONTINUE;
}

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

    if (NxCore.LoadNxCore(argv[1])){
        int returnValue = NxCore.ProcessTape(argv[2], 0, 0, 0, OnNxCoreCallback);
        NxCore.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& quote = pNxCoreMsg->coreData.MMQuote;
    const NxCoreQuote& coreQuote = quote.coreQuote;
    char* marketMaker = quote.pnxStringMarketMaker->String;
    int sizeBid = coreQuote.BidSize;
    int sizeAsk = coreQuote.AskSize;
    double priceBid = NxCore.PriceToDouble(
        coreQuote.BidPrice, coreQuote.PriceType);
    double priceAsk = NxCore.PriceToDouble(
        coreQuote.AskPrice, coreQuote.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& quote = pNxCoreMsg->coreData.ExgQuote;
    if (!quote.BBOChangeFlags)
        return NxCALLBACKRETURN_CONTINUE;
    int sizeBid = quote.BestBidSize;
    int sizeAsk = quote.BestAskSize;
    double priceBid = NxCore.PriceToDouble(
        quote.BestBidPrice, quote.coreQuote.PriceType);
    double priceAsk = NxCore.PriceToDouble(
        quote.BestAskPrice, quote.coreQuote.PriceType);
    ...
}

Next:
Category