NxCoreStateMMQuote
One of a number of market maker quotes in NxCoreStateMMQuotes.StateMMQuotes
The struct NxCoreStateMMQuote is defined in NxCoreAPI.h as:
struct NxCoreStateMMQuote { int AskPrice; int BidPrice; int AskSize; int BidSize; NxString* pnxStringMarketMaker; unsigned char MarketMakerType; unsigned char QuoteType; unsigned char alignment[2]; };
Represents the value of the current ask from the market maker identified as pnxStringMarketMaker.
Use PriceType to convert to double: nxCoreClass.PriceToDouble(AskPrice, PriceType)
Represents the value of the current bid from the market maker identified as pnxStringMarketMaker.
Use PriceType to convert to double: nxCoreClass.PriceToDouble(BidPrice, PriceType)
Represents the size of the current Ask from the market maker identified as pnxStringMarketMaker. For most equities, the AskSize represents the number of round lots (a round lot is 100 shares in this case). For options contracts, the AskSize represents the number of option contracts. The size fields are set to the values as sent by the exchanges.
Represents the size of the current Bid from the market maker identified as pnxStringMarketMaker. For most equities, the BidSize represents the number of round lots (a round lot is 100 shares in this case). For options contracts, the BidSize represents the number of option contracts. The size fields are set to the values as sent by the exchanges.
Described here
Described here
Described here
Here's an example of getting the MM quote information for every symbol that trades
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include "NxCoreAPI.h" #include "NxCoreAPI_Wrapper_C++.h" NxCoreClass NxCore; int __stdcall nxCoreCallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMessage) { switch (pNxCoreMessage->MessageType) { case NxMSG_TRADE: { // If this is an option exit out....options don't have market maker data which is what we // want to retrive below. if (pNxCoreMessage->coreHeader.pnxStringSymbol->String[0]=='o') return NxCALLBACKRETURN_CONTINUE; const NxCoreHeader& ch = pNxCoreMessage->coreHeader; const NxTime& t = pNxCoreSys->nxTime; // First get exchange quotes so we have a list of possible exchanges to query for MM states NxCoreStateExgQuotes q; int rc = NxCore.StateGetExgQuotes(&q, pNxCoreMessage->coreHeader.pnxStringSymbol); if (rc != 0) { break; } char buf[16 * 1024]; // Cycle through the exchanges returned in exg state quotes for (int eqi = 0; eqi < q.StateQuoteCount; eqi++) { // Now get the Market Maker state quotes for symbol and for the specific exchange NxCoreStateMMQuotes mmq; rc = NxCore.StateGetMMQuotes(q.StateExgQuotes[eqi].ReportingExg, &mmq, pNxCoreMessage->coreHeader.pnxStringSymbol); if (rc != 0) { continue; } char* p = buf; bool printThis = false; p += sprintf(p, "\n Exg[%d] ", q.StateExgQuotes[eqi].ReportingExg); // Now cycle through the state quotes and print data for (int i = 0; i < mmq.StateQuoteCount; i++) { const NxCoreStateMMQuote& mm = mmq.StateMMQuotes[i]; if (mm.BidPrice > 0 && mm.BidSize > 0) { printThis = true; p += sprintf(p, "\n %s_bid(%ld @ %.2lf) ", mm.pnxStringMarketMaker->String, mm.BidSize, NxCore.PriceToDouble(mm.BidPrice, mmq.PriceType)); } if (mm.AskPrice > 0 && mm.AskSize > 0) { printThis = true; p += sprintf(p, "\n %s_ask(%ld @ %.2lf) ", mm.pnxStringMarketMaker->String, mm.AskSize, NxCore.PriceToDouble(mm.AskPrice, mmq.PriceType)); } } if (printThis) { printf("%02d:%02d:%02d.%03d %s %s\n", (int) t.Hour, (int) t.Minute, (int) t.Second, (int) t.Millisecond, pNxCoreMessage->coreHeader.pnxStringSymbol->String, buf); } } break; } } return NxCALLBACKRETURN_CONTINUE; } int main(int argc, char** argv) { if (!NxCore.LoadNxCore("NxCoreAPI64.dll") && !NxCore.LoadNxCore("NxCoreAPI.dll")) { fprintf(stderr, "loading library failed\n"); return -1; } NxCore.ProcessTape(argv[1], 0, NxCF_EXCLUDE_CRC_CHECK, 0, nxCoreCallback); return 0; } |
import net.nanex.NxCoreClass; class StateMMQuoteSample extends NxCoreClass{ @Override public int OnNxCoreCallback(NxCoreSystem nxCoreSys, NxCoreMessage nxCoreMsg) { switch (nxCoreMsg.MessageType) { case defines.NxMSG_TRADE: NxCoreHeader ch = nxCoreMsg.coreHeader; NxTime t = nxCoreSys.nxTime; // If this is an option exit out....options don't have market maker data which is what we // want to retrive below. if (ch.pnxStringSymbol.String.charAt(0)=='o') return defines.NxCALLBACKRETURN_CONTINUE; // First get exchange quotes so we have a list of possible exchanges to query for MM states NxCoreStateExgQuotes q = StateGetExgQuotes(ch.ListedExg, ch.pnxStringSymbol.String); if(q == null) break; // Cycle through the exchanges returned in exg state quotes for(int eqi = 0; eqi < q.StateQuoteCount; eqi++) { // Now get the Market Maker state quotes for symbol and for the specific exchange. // Due to lack of pointers in Java, the parameters are slightly different for StateGetMMQuotes // The parameters are Reporting Exchange, Listed Exchange, and Symbol String NxCoreStateMMQuotes mmq = StateGetMMQuotes(q.StateExgQuotes[eqi].ReportingExg, ch.ListedExg, ch.pnxStringSymbol.String); if(mmq == null) continue; String quoteString = ""; boolean printThis = false; quoteString += String.format("\n Exg[%d] ", q.StateExgQuotes[eqi].ReportingExg); // Now cycle through the state quotes and print data for(int i = 0; i < mmq.StateQuoteCount; i++) { NxCoreStateMMQuote mm = mmq.StateMMQuotes[i]; if (mm.BidPrice > 0 && mm.BidSize > 0) { printThis = true; quoteString += String.format("\n %s_bid(%d @ %.2f) ", mm.pnxStringMarketMaker.String, mm.BidSize, PriceToDouble(mm.BidPrice, mmq.PriceType)); } if (mm.AskPrice > 0 && mm.AskSize > 0) { printThis = true; quoteString += String.format("\n %s_ask(%d @ %.2f) ", mm.pnxStringMarketMaker.String, mm.AskSize, PriceToDouble(mm.AskPrice, mmq.PriceType)); } } if (printThis) { System.out.println( String.format("%02d:%02d:%02d.%03d %s %s", t.Hour, t.Minute, t.Second, t.Millisecond, ch.pnxStringSymbol.String, quoteString)); } } break; } return defines.NxCALLBACKRETURN_CONTINUE; } public static void main(String args[]) { StateMMQuoteSample nxCore = new StateMMQuoteSample(); if (nxCore.LoadNxCore("NxCoreAPI64.dll") != 0){ nxCore.ProcessTape(args[0], 0, 0, 0); } else System.out.println("loading library failed"); } } |
import NxCore tapePath = "" def OnNxCoreCallback(NxCoreSys, NxCoreMsg): if NxCoreMsg.MessageType == NxCore.NxMSG_TRADE: ch = NxCoreMsg.coreHeader t = NxCoreSys.nxTime # If this is an option exit out....options don't have market maker data which is what we # want to retrive below. if ch.pnxStringSymbol.String[0] == 'o':# If an option.... return NxCore.NxCALLBACKRETURN_CONTINUE #First get exchange quotes so we have a list of possible exchanges to query for MM states q = NxCore.StateGetExgQuotes(ch.ListedExg, ch.pnxStringSymbol.String) if not q: return NxCore.NxCALLBACKRETURN_CONTINUE # Cycle through the exchanges returned in exg state quotes for eqi in range(q.StateQuoteCount): # Now get the Market Maker state quotes for symbol and for the specific exchange. # Due to lack of pointers in Java, the parameters are slightly different for StateGetMMQuotes # The parameters are Reporting Exchange, Listed Exchange, and Symbol String mmq = NxCore.StateGetMMQuotes(q.StateExgQuotes[eqi].ReportingExg, ch.ListedExg, ch.pnxStringSymbol.String) if not mmq: return NxCore.NxCALLBACKRETURN_CONTINUE printThis = False; quoteString = "\n Exg[{}] ".format(q.StateExgQuotes[eqi].ReportingExg); # Now cycle through the state quotes and print data for i in range(mmq.StateQuoteCount): mm = mmq.StateMMQuotes[i] if mm.BidPrice > 0 and mm.BidSize > 0: printThis = True quoteString += "\n {}_bid({} @ {:.2f}) ".format( mm.pnxStringMarketMaker.String, mm.BidSize, NxCore.PriceToFloat(mm.BidPrice, mmq.PriceType)) if mm.AskPrice > 0 and mm.AskSize > 0 : printThis = True quoteString += "\n {}_ask({} @ {:.2f}) ".format( mm.pnxStringMarketMaker.String, mm.AskSize, NxCore.PriceToFloat(mm.AskPrice, mmq.PriceType)) if printThis: print("{:02d}:{:02d}:{:02d}.{:03d} {} {}" .format(t.Hour, t.Minute, t.Second, t.Millisecond, ch.pnxStringSymbol.String, quoteString)) return NxCore.NxCALLBACKRETURN_CONTINUE if NxCore.LoadNxCore("NxCoreAPI64.dll"): NxCore.ProcessTape(tapePath, 0, 0, 0, OnNxCoreCallback) else: print("loading library failed") |