Basic: | Intro/Trade | Quote | Category | Status | Symbol | Options |
Detailed: | Trade | Quote |
Introduction to Quotes
Quotes discussed on this page are considered level 1 quotes or exchange quotes. The best exchange quotes form the NBBO quote which will be covered in the detailed quote guide.
Code
#include "stdio.h" #include "NxCoreAPI_Wrapper_C++.h" NxCoreClass NxCore; int OnNxCoreCallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMsg) { if(pNxCoreMsg->MessageType == NxMSG_EXGQUOTE) { const NxCoreHeader& header = pNxCoreMsg->coreHeader; char* symbol = header.pnxStringSymbol->String; const NxTime& timestamp = header.nxExgTimestamp; const char* exchange = NxCore.GetDefinedString(NxST_EXCHANGE, header.ReportingExg); const NxCoreQuote& coreQuote = pNxCoreMsg->coreData.ExgQuote.coreQuote; 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("Quote for %s on Exchange %s at %02d:%02d:%02d Bid: %d lots at $%.2f Ask: %d lots at $%.2f\n", symbol, exchange, 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; }
Callback Function
Since we only want to process quotes we check that MessageType equals NxMSG_EXGQUOTE. |
int OnNxCoreCallback( const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMsg) { if(pNxCoreMsg->MessageType == NxMSG_EXGQUOTE) { ... } return NxCALLBACKRETURN_CONTINUE; } |
Message Header
In addition to symbol and timestamp, the coreHeader also contains the exchange that sent the message. The exchange is sent as a number corresponding to NxST_EXCHANGE. The name of the exchange can be found using GetDefinedString. |
const NxCoreHeader& header = pNxCoreMsg->coreHeader; char* symbol = header.pnxStringSymbol->String; const NxTime& timestamp = header.nxExgTimestamp; const char* exchange = NxCore.GetDefinedString( NxST_EXCHANGE, header.ReportingExg); |
Quote Message
The ExgQuote object in the coreData object in NxCoreMessage contains details of the quote when MessageType is NxMSG_EXGQUOTE. For this simple example we will just use the contents of the coreQuote object. The other parts of the ExgQuote object will be covered in the advanced quote guide. Note quote sizes sent by most feeds are the number of lots, not the number of shares. Lots are usually 100 shares. |
const NxCoreQuote& coreQuote = pNxCoreMsg->coreData.ExgQuote.coreQuote; int sizeBid = coreQuote.BidSize; int sizeAsk = coreQuote.AskSize; double priceBid = NxCore.PriceToDouble( coreQuote.BidPrice, coreQuote.PriceType); double priceAsk = NxCore.PriceToDouble( coreQuote.AskPrice, coreQuote.PriceType); |
Next:
Category
Detailed Quote