API Documentation

Exchanges in NxCore

NxCore uses concepts of a integer Listed Exchange (ListedExg) and Reporting Exchange (ReportingExg).

ListedExg

ListedExg identifies the Listed Exchange where the trading instrument resides. For example, as of this writing the stock IBM is listed at the NYSE exchange, while Microsoft is listed on the Nasdaq National Market. The combination of the ListedExg and the symbol uniquely identifies a trading instrument.

Note: All U.S. Options are set to OPRA for the Listed Exchange.

ReportingExg

The ReportingExg identifies where a trade or quote originated. For instruments that only trade on one exchange, such as most futures contracts and indexes, the ReportingExg will always equal the ListedExg. For instruments that trade on more than one exchange, equities for example, ReportingExg may differ from the ListedExg.

All Equity Options trading in the U.S. use the ListedExg of OPRA. Trades on option contracts use the ReportingExg data member to indicate which exchange originated the trade (CBOE, ISEX, Boston, PHIL, PACX, AMEX, etc). Customers receiving the NBBO options feed will need to examine pNxCoreMessage->coreData.ExgQuote.BestBidExg and pNxCoreMessage->coreData.ExgQuote.BestAskExg fields. Customers receiving the full options feed (ASAP or split-OPRA) should use the ReportingExg data member as they do with Trades.

Example 1.

IBM is listed on the NYSE with the symbol IBM.

NYSE stocks also trade on regional exchanges, and recently are now being quoted and traded on Nasdaq through the Intermarket system. Quotes from the NYSE floor for IBM will have the ReportingExg indicating NYSE, and quote for IBM from the Pacific Stock Exchange will have the ReportingExg set to PACIFIC. Boston, Philadelphia, Chicago, Cincinnati, and Nasdaq also send quotes for IBM, and the ReportingExg is set accordingly.

Each of these individual quotes is sometimes referred to as a Regional Quote (the quotes are updated using the NxMSG_EXGQUOTE MessageType).

The NYSE also provides a Consolidated quote which is also known as the Best Bid/Offer, BBO, Best Bid/Ask, National Best, NBBO, or simply Best. The Consolidate Quote is a combination of the Best Bid and Best Ask as determined by exchange rules and procedures ( usually it's simple: best bid is the highest price or if prices equal, largest size, or if size equal, earliest timestamp, and the inverse for best ask). The Best Bid may come from the same exchange as the Best Ask, or they may come from different exchanges. Each quote message within the Nanex Financial Stream identifies the Regional Quote and within the quote message, the Best Bid/Ask (price,size,condition and exchange) as determined by the exchange.

Example 2.

General Motors is listed on the NYSE and has the symbol GM.

General Motors is also listed on the Toronto Stock Exchange and also has the symbol GM. Trades and quotes pertaining to the NYSE General Motors stock will have the ListedExg set to NYSE. Trades and quotes pertaining to the Toronto General Motors stock will have the ListedExg set to Toronto.

Getting all exchange identifies and converting them to strings

A list of Exchange Identifiers can be found at table_NxST_EXCHANGE.html.

Code to convert an integer exchange to a full exchange string

char* fullExchangeFromExg(char* buf, int exg)
{
    const char* p = pfNxCoreGetDefinedString(NxST_EXCHANGE, exg);
    
// If no return string exit
    if (p == 0) return 0;
    
// Copy string into buf
    strcpy(buf, p);
    
    return buf;
}

Code to convert an integer exchange to a exchange prefix string

char* exchangePrefixFromExg(char* buf, int exg)
{
    const char* p = pfNxCoreGetDefinedString(NxST_EXCHANGE, exg);
    
// If no return string exit
    if (p == 0) return 0;
    	
// Copy string up to '|' character
    int i=0;
    while (p[i]!='|') buf[i]=p[i++];
    buf[i]=0;
    
    return buf;
}

Code to convert an integer exchange to a exchange name string

char* exchangeNameFromExg(char* buf, int exg)
{
    const char* p = pfNxCoreGetDefinedString(NxST_EXCHANGE, exg);
    
// If no return string exit
    if (p == 0) return 0;
    
// Find '|' character in string
    const char* pipe = strchr(p, '|');
    
// Copy string from '|' character +1 to end of string into buf
    int end = strlen(pipe) - 1;
    strncpy(buf, pipe + 1, end);
    buf[end] = 0;
    
    return buf;
}

Code to print all exchanges

void dumpAllExchanges()
{
    for (int ixString = 0;; ++ixString)
    {
        const char* p = pfNxCoreGetDefinedString(NxST_EXCHANGE, ixString);
        if (p == 0) // no more
        {
            break;
        }
        if (*p == 0) // not defined index
        {
            continue;
        }
        printf("%d %s\n", ixString, p);
    }
}