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

import NxCore

def OnNxCoreCallback(NxCoreSys, NxCoreMsg):
    if NxCoreMsg.MessageType == NxCore.NxMSG_MMQUOTE:

        header = NxCoreMsg.coreHeader
        symbol = header.pnxStringSymbol.String
        timestamp = header.nxExgTimestamp

        core_quote = NxCoreMsg.coreData.MMQuote.coreQuote
        market_maker =  NxCoreMsg.coreData.MMQuote.pnxStringMarketMaker.String
        size_bid = core_quote.BidSize
        size_ask = core_quote.AskSize
        price_bid = NxCore.PriceToFloat(core_quote.BidPrice, core_quote.PriceType)
        price_ask = NxCore.PriceToFloat(core_quote.AskPrice, core_quote.PriceType)

        print("Market Maker Quote for {} at {:02d}:{:02d}:{:02d} by: {} Bid: {} at ${:.2f} Ask: {} at ${:.2f}" \
            .format(symbol, timestamp.Hour, timestamp.Minute, timestamp.Second, market_maker, size_bid, price_bid, size_ask, price_ask))
    if NxCoreMsg.MessageType == NxCore.NxMSG_EXGQUOTE:

        header = NxCoreMsg.coreHeader
        symbol = header.pnxStringSymbol.String
        timestamp = header.nxExgTimestamp

        quote = NxCoreMsg.coreData.ExgQuote
        if not quote.BBOChangeFlags:
            return NxCore.NxCALLBACKRETURN_CONTINUE
        size_bid = quote.BestBidSize
        size_ask = quote.BestAskSize
        price_bid = NxCore.PriceToFloat(quote.BestBidPrice, quote.coreQuote.PriceType)
        price_ask = NxCore.PriceToFloat(quote.BestAskPrice, quote.coreQuote.PriceType)

        print("New NBBO Quote for {} at {:02d}:{:02d}:{:02d} Bid: {} lots at ${:.2f} Ask: {} lots at ${:.2f}"
            .format(symbol, timestamp.Hour, timestamp.Minute, timestamp.Second, size_bid, price_bid, size_ask, price_ask))
    return NxCore.NxCALLBACKRETURN_CONTINUE

if NxCore.LoadNxCore("NxCoreAPI64.dll"):
    NxCore.ProcessTape("demo.XU.nx2", 0, 0, 0, OnNxCoreCallback)
    NxCore.ProcessReturnValue(returnValue)
else:
    print("loading library failed")

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 NxCoreMsg.MessageType == NxCore.NxMSG_MMQUOTE:
    ...
    core_quote = NxCoreMsg.coreData.MMQuote.coreQuote
    market_maker =  NxCoreMsg.coreData.MMQuote.pnxStringMarketMaker.String
    size_bid = core_quote.BidSize
    size_ask = core_quote.AskSize
    price_bid = NxCore.PriceToFloat(
        core_quote.BidPrice, core_quote.PriceType)
    price_ask = NxCore.PriceToFloat(
        core_quote.AskPrice, core_quote.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 NxCoreMsg.MessageType == NxCore.NxMSG_EXGQUOTE:
    ...
    quote = NxCoreMsg.coreData.ExgQuote
    if not quote.BBOChangeFlags:
        return NxCore.NxCALLBACKRETURN_CONTINUE
    size_bid = quote.BestBidSize
    size_ask = quote.BestAskSize
    price_bid = NxCore.PriceToFloat(
        quote.BestBidPrice, quote.coreQuote.PriceType)
    price_ask = NxCore.PriceToFloat(
        quote.BestAskPrice, quote.coreQuote.PriceType)

Next:
Category