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
using System; using NxCoreAPI; class DetailedQuoteSample { static unsafe int OnNxCoreCallback(NxCoreSystem* pNxCoreSys, NxCoreMessage* pNxCoreMsg) { if (pNxCoreMsg->MessageType == NxCore.NxMSG_MMQUOTE) { NxCoreHeader* pHeader = &pNxCoreMsg->coreHeader; String symbol = new String(&pHeader->pnxStringSymbol->String); NxTime* pTimestamp = &pHeader->nxExgTimestamp; NxCoreMMQuote* pQuote = &pNxCoreMsg->coreData.MMQuote; NxCoreQuote* pCoreQuote = &pQuote->coreQuote; String marketMaker = new String(&pQuote->pnxStringMarketMaker->String); int sizeBid = pCoreQuote->BidSize; int sizeAsk = pCoreQuote->AskSize; double priceBid = NxCore.PriceToDouble(pCoreQuote->BidPrice, pCoreQuote->PriceType); double priceAsk = NxCore.PriceToDouble(pCoreQuote->AskPrice, pCoreQuote->PriceType); Console.WriteLine("Market Maker Quote for {0:s} at {1:d2}:{2:d2}:{3:d2} by: {4:s} Bid: {5:d} lots at ${6:f2} Ask: {7:d} lots at ${8:f2}", symbol, pTimestamp->Hour, pTimestamp->Minute, pTimestamp->Second, marketMaker, sizeBid, priceBid, sizeAsk, priceAsk); } if (pNxCoreMsg->MessageType == NxCore.NxMSG_EXGQUOTE) { NxCoreHeader* pHeader = &pNxCoreMsg->coreHeader; String symbol = new String(&pHeader->pnxStringSymbol->String); NxTime* pTimestamp = &pHeader->nxExgTimestamp; NxCoreExgQuote* pQuote = &pNxCoreMsg->coreData.ExgQuote; if (pQuote->BBOChangeFlags == 0) return NxCore.NxCALLBACKRETURN_CONTINUE; int sizeBid = pQuote->BestBidSize; int sizeAsk = pQuote->BestAskSize; double priceBid = NxCore.PriceToDouble(pQuote->BestBidPrice, pQuote->coreQuote.PriceType); double priceAsk = NxCore.PriceToDouble(pQuote->BestAskPrice, pQuote->coreQuote.PriceType); Console.WriteLine("New NBBO Quote for {0:s} on at {1:d2}:{2:d2}:{3:d2} Bid: {4:d} lots at ${5:f2} Ask: {6:d} lots at ${7:f2}", symbol, pTimestamp->Hour, pTimestamp->Minute, pTimestamp->Second, sizeBid, priceBid, sizeAsk, priceAsk); } return NxCore.NxCALLBACKRETURN_CONTINUE; } static unsafe void Main(string[] args) { if (args.Length < 1) return; int returnValue = NxCore.ProcessTape(args[0], null, 0, 0, DetailedQuoteSample.OnNxCoreCallback); NxCore.processReturnValue(returnValue); } }
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 == NxCore.NxMSG_MMQUOTE) { ... NxCoreMMQuote* pQuote = &pNxCoreMsg->coreData.MMQuote; NxCoreQuote* pCoreQuote = &pQuote->coreQuote; String marketMaker = new String(&pQuote->pnxStringMarketMaker->String); int sizeBid = pCoreQuote->BidSize; int sizeAsk = pCoreQuote->AskSize; double priceBid = NxCore.PriceToDouble( pCoreQuote->BidPrice, pCoreQuote->PriceType); double priceAsk = NxCore.PriceToDouble( 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 == NxCore.NxMSG_EXGQUOTE) { ... NxCoreExgQuote* pQuote = &pNxCoreMsg->coreData.ExgQuote; if (pQuote->BBOChangeFlags == 0) return NxCore.NxCALLBACKRETURN_CONTINUE; int sizeBid = pQuote->BestBidSize; int sizeAsk = pQuote->BestAskSize; double priceBid = NxCore.PriceToDouble( pQuote->BestBidPrice, pQuote->coreQuote.PriceType); double priceAsk = NxCore.PriceToDouble( pQuote->BestAskPrice, pQuote->coreQuote.PriceType); ... } |
Next:
Category