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 net.nanex.NxCoreClass; class DetailedQuoteSample extends NxCoreClass{ @Override public int OnNxCoreCallback(NxCoreSystem nxCoreSys, NxCoreMessage nxCoreMsg) { if (nxCoreMsg.MessageType == defines.NxMSG_MMQUOTE) { NxCoreHeader header = nxCoreMsg.coreHeader; String symbol = header.pnxStringSymbol.String; NxTime timestamp = header.nxExgTimestamp; NxCoreMMQuote quote = nxCoreMsg.coreData.MMQuote; NxCoreQuote coreQuote = quote.coreQuote; String marketMaker = quote.pnxStringMarketMaker.String; int sizeBid = coreQuote.BidSize; int sizeAsk = coreQuote.AskSize; double priceBid = PriceToDouble(coreQuote.BidPrice, coreQuote.PriceType); double priceAsk = PriceToDouble(coreQuote.AskPrice, coreQuote.PriceType); System.out.println("Market Maker Quote for " + symbol + " at " + String.format("%02d:%02d:%02d", timestamp.Hour, timestamp.Minute, timestamp.Second) + " by: " + marketMaker + " Bid: " + sizeBid + " lots at $" + String.format("%.2f", priceBid) + " Ask: " + sizeAsk + " lots at $" + String.format("%.2f", priceAsk)); } if (nxCoreMsg.MessageType == defines.NxMSG_EXGQUOTE) { NxCoreHeader header = nxCoreMsg.coreHeader; String symbol = header.pnxStringSymbol.String; NxTime timestamp = header.nxExgTimestamp; NxCoreExgQuote quote = nxCoreMsg.coreData.ExgQuote; if (quote.BBOChangeFlags == 0) return defines.NxCALLBACKRETURN_CONTINUE; int sizeBid = quote.BestBidSize; int sizeAsk = quote.BestAskSize; double priceBid = PriceToDouble(quote.BestBidPrice, quote.coreQuote.PriceType); double priceAsk = PriceToDouble(quote.BestAskPrice, quote.coreQuote.PriceType); System.out.println("New NBBO Quote for " + symbol + " at " + String.format("%02d:%02d:%02d", timestamp.Hour, timestamp.Minute, timestamp.Second) + " Bid: " + sizeBid + " lots at $" + String.format("%.2f", priceBid) + " Ask: " + sizeAsk + " lots at $" + String.format("%.2f", priceAsk)); } return defines.NxCALLBACKRETURN_CONTINUE; } public static void main(String args[]) { TradeSample nxCore = new TradeSample(); if (args.length > 1 && nxCore.LoadNxCore(args[0]) != 0){ int returnValue = nxCore.ProcessTape(args[1], 0, 0, 0); nxCore.ProcessReturnValue(returnValue); } else System.out.println("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 == defines.NxMSG_MMQUOTE) { ... NxCoreMMQuote quote = nxCoreMsg.coreData.MMQuote; NxCoreQuote coreQuote = quote.coreQuote; String marketMaker = quote.pnxStringMarketMaker.String; int sizeBid = coreQuote.BidSize; int sizeAsk = coreQuote.AskSize; double priceBid = PriceToDouble( coreQuote.BidPrice, coreQuote.PriceType); double priceAsk = 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 (nxCoreMsg.MessageType == defines.NxMSG_EXGQUOTE) { ... NxCoreExgQuote quote = nxCoreMsg.coreData.ExgQuote; if (quote.BBOChangeFlags == 0) return defines.NxCALLBACKRETURN_CONTINUE; int sizeBid = quote.BestBidSize; int sizeAsk = quote.BestAskSize; double priceBid = PriceToDouble( quote.BestBidPrice, quote.coreQuote.PriceType); double priceAsk = PriceToDouble( quote.BestAskPrice, quote.coreQuote.PriceType); ... } |
Next:
Category