Introduction
NxCoreTrade has a member named nxAnalysis which contains the results of the real-time analysis performed by the Nanex Core Processors. The analysis is geared to helping you determine if a trade price is suspect and should be included or discarded from your trading engine. Although a lot of effort was put into the algorithms that determine these results, you should know that there are times when even traders with many years of experience will not be able to determine a "bad" price from a good price, even many records after the fact. You should heed the market axiom, "when in doubt, stay out".
The Nanex RealTime Analysis Engine (Analysis Engine) observes price changes and updates an internal table of the results which it then uses to determine statistically where 95% of the price changes are found. It then sets the member FilterThreshold to a value slightly higher than the 95th percentile. FilterThreshold is an integer price value and uses the NxCoreTrade.PriceType member to indicate the decimal position.
When a price change exceeds the FilterThreshold trigger, the Analysis Engine then does a more in depth look at other information. Because the analysis is done in real-time, the NxRAE Engine has no information about the next trade or any other future events. The engine then makes adjustments for any mitigating circumstances found during the in-depth analysis, and then sets the FilterLevel to a number from 2 to 7 depending on the severity of the price change.
If there are not enough mitigating factors, the Analysis Engine will set the member Filtered to the value 1. Trades with a Filtered member set to 1 are excluded from Significant High Low (SigHiLo) calculations discussed below.
Some mitigating circumstances are:
NxCTAnalysis
NOTE: Analysis fields are only applied to trades eligible to set the official last sale price, which can be determined by looking at TradeConditions.
The structure NxCTAnalysis is defined in NxCoreAPI.h as:
struct NxCTAnalysis { int FilterThreshold; unsigned char Filtered; unsigned char FilterLevel; unsigned char SigHiLoType; unsigned char alignment; unsigned int SigHiLoSeconds; int QteMatchDistanceRGN; int QteMatchDistanceBBO; unsigned char QteMatchTypeRGN; unsigned char QteMatchTypeBBO; unsigned char QteMatchFlagsRGN; unsigned char QteMatchFlagsBBO; };
The Analysis Engine compares each trade record against the last 15 - 60 minutes of the most recent quotes looking for the best matching price. It does this look-up in realtime, for both the regional quote records, and the best bid/ask quote records. Some symbols only trade through one exchange, in which those cases the best quote is equal to the regional quote. The search algorithm will first accept an exact match within the very most recent quotes, and then if it has to go further back, it will expand its search to also include near matches.
The results of the match are placed in 3 members for the Best Quote match results: QteMatchTypeBBO, QteMatchFlagsBBO, and QteMatchDistanceBBO; and 3 members for the Regional Quote Match results: QteMatchTypeRGN, QteMatchFlagsRGN, and QteMatchDistanceRGN
The table below illustrates the relationship between the FilterThreshold and the FilterLevel
Filter Level |
Price Change vs Threshold | If FilterThreshold is "0.05" and Price change is | Comments |
---|---|---|---|
2 |
PriceChange >= 1 x Threshold. PriceChange <= 2 x Threshold. |
>=0.05 and <= 0.10 | FilterLevel 2 is often a good early warning indicator that trading activity is picking up. It also occurs when trades are reported late but not marked as late. This setting rarely results in Filtered being set to 1. |
3 |
PriceChange > 2 x Threshold. PriceChange < 5 x Threshold. |
> 0.10 and < 0.25 | Where Level 2 is more often noise, level 3 and above usually indicate a bad price, or a market with severe imbalances. Issues that suddenly come alive may fall into this category. Sets Filtered to 1 more often than level 2. |
4 |
PriceChange >= 5 x Threshold. PriceChange < 10 x Threshold. |
>= 0.25 and < 0.50 | Unless there are a lot of good mitigating circumstances, FilterLevels 4 and above often result in the Filtered being set to 1. |
5 |
PriceChange >= 10 x Threshold. PriceChange < 20 x Threshold. |
>= 0.50 and < 1.00 | Severe price change, Filtered set to 1 |
6 |
PriceChange >= 20 x Threshold. PriceChange < 40 x Threshold. |
>= 1.00 and < 2.00 | Severe price change, Filtered set to 1 |
7 |
PriceChange >= 40 x Threshold. | >= 2.00 | Severe price change, Filtered set to 1 |
A value slightly higher than the 95th percentile of the statistical price changes of this symbol. Convert to a double by using nxCoreClass.PriceToDouble(FilterThreshold,nxCoreTrade.PriceType)
Will either be the value 0 or 1 -- acts as a final Yes/No decision based on the other analysis used by the Nanex Core Processors in deciding whether to include a trade update in the Session High/Low calculation.
If non-zero, then a number from 2 to 7 that depends on the severity of the price change, from table above
Whether this trade price is a significant high or low
#define | Value | Comments |
---|---|---|
NxRTA_SIGHL_EQ | 0 | Indicates the trade price matches the preceding trade price. The Analysis Engine continues to look at trades with matching prices and sets SigHiLoSeconds to the difference between the earliest matching trade and analyzed trade. |
NxRTA_SIGHL_LOWEST | 1 | Indicates this trade has the lowest trade price of the session for all eligible trades that do not have the Filtered set to 1. SigHiLoSeconds is the elapsed seconds-bucket since the first trade of the session. In effect, the price for this type is the Filtered Low for the session. |
NxRTA_SIGHL_LOW | 2 | Indicates the trade price is lower than the preceding trade but is not a new session low. SigHiLoSeconds is the elapsed seconds-bucket since the trade that was first equal to or lower than price. In effect, this tells you the trade price sets a low that has not been reached since SigHiLoSeconds ago. The Analysis Engine uses this in evaluating mitigating factors for the real-time filter. |
NxRTA_SIGHL_HIGH | 3 | Indicates the trade price is higher than the preceding trade but is not a new session high. SigHiLoSeconds is the elapsed seconds-bucket since the trade that was first equal to or lower than price. In effect, this tells you the trade price sets a high that has not been reached since SigHiLoSeconds ago. The Analysis Engine uses this in evaluating mitigating factors for the real-time filter. |
NxRTA_SIGHL_HIGHEST | 4 | Indicates this trade has the highest trade price of the session for all eligible trades that do not have the Filtered set to 1. SigHiLoSeconds is the elapsed seconds-bucket since the first trade of the session. In effect, the price for this type is the Filtered High for the session. |
How much time has elapsed since the price previously traded at the level of SigHiLoType. Note that the time is calculated in buckets of 15-seconds, and does not correspond to the exact second. Thus, this is best used as a filter -- a SigHiLoSeconds of 1500, for example, carries more weight than a SigHiLoSeconds of 15, since it signifies that the stock hasn't traded this low for a long time today. For Lowest and Highest, the SigHiLoSeconds will always point to beginning of session.
A working sample is available
An integer price value which uses the NxCoreTrade.PriceType to indicate distance. If QteMatchDistanceRGN is zero, it indicates the match was exact, otherwise, the match was not exact and is nxCoreClass.PriceToDouble(QteMatchDistanceRGN, nxCoreTrade.PriceType) distance away from the QteMatchTypeRGN closest to the trade price.
An integer price value which uses the NxCoreTrade.PriceType to indicate distance. If QteMatchDistanceBBO is zero, it indicates the match was exact, otherwise, the match was not exact and is nxCoreClass.PriceToDouble(QteMatchDistanceBBO, nxCoreTrade.PriceType) distance away from the QteMatchTypeBBO closest to the trade price.
QteMatchTypeRGN and QteMatchTypeBBO
Defines where the trade occured in relation to latest Regional (RGN) or National (BBO) best quote
#define | Value | Comments |
---|---|---|
NxRTA_QMTYPE_NONE | 0 | Indicates that no quote records were found. This can occur at the opening on NYSE and AMEX stocks for the regional match. Often the NYSE will not issue a quote until the opening trades are sent. Those opening trades will not have any quote records to compare against. |
NxRTA_QMTYPE_BID | 1 | Indicates the trade price was closer to the Bid. If the QteMatchDistance is zero, the trade price was equal to the Bid Price. |
NxRTA_QMTYPE_ASK | 2 | Indicates the trade price was closer to the Ask. If the QteMatchDistance is zero, the trade price was equal to the Ask Price. |
NxRTA_QMTYPE_INSIDE | 3 | Indicates the trade price was exactly between the bid and ask. If QteMatchDistance is zero, it indicates a locked market where the bid and ask prices are equal. Note, only markets with Best Quotes can be locked, unless the regional quote includes competing entities. |
NxRTA_QMTYPE_BELOWBID | 4 | Indicates the trade price was found below the bid price. QteMatchDistance will indicate how far away the price was. Finding no quotes where the trade is between the bid and ask is most common in two scenarios: the trade price is suspect -- either being a very late report/bad print, or the market is moving into new territory: breaking below a significant low. The Analysis engine uses this together with the Significant HiLo when determining mitigating circumstances in the real-time filter. |
NxRTA_QMTYPE_ABOVEASK | 5 | Indicates the trade price was found above the ask price. QteMatchDistance will indicate how far away the price was. Finding no quotes where the trade is between the bid and ask is most common in two scenarios: the trade price is suspect -- either being a very late report/bad print, or the market is moving into new territory: breaking above a significant high. The Analysis engine uses this together with the Significant HiLo when determining mitigating circumstances in the real-time filter. |
QteMatchFlagsRGN and QteMatchFlagsBBO
Defines the freshness of the latest search within the past Regional (RGN) or National (BBO) best quotes
#define | Value | Comments |
---|---|---|
NxRTA_QTEMATCHFLAG_OLDER | 0x01 | Set if the Analysis Engine had to look at a large number of quotes over a period of time and indicates that the match result is not very accurate, possibly stale. |
NxRTA_QTEMATCHFLAG_CROSSED | 0x02 | Set if the matched quote is crossed: a crossed quote is when the bid price is greater than the ask price. Crossed markets can only happen with Best Bid/Ask quote records or regional quotes that include competing entities. Usually pre-market and post-market quotes are found in a crossed state, but recently, crossed market have become more common. |