Skip to Main Content

05/22/2019 |

Analysis Shows Stock Prices Tend to Cluster

One of my favorite parts of my job is to mess around with market data. Eventually, I found myself with a scatter plot comparing the price versus volume for Walmart Inc. (NYSE: WMT).

This chart was built with two-and-a-half years’ worth of ten-minute candles, with each point representing one candle. The X-axis represents the average price, calculated as [(High + Low)/2], and the Y-axis represents the volume of each candle.

Here’s how it looked:

Scatter plot comparing the price versus volume for $WMT.

Note: The volume axis was cropped by one million on this chart, but that doesn’t matter for the purposes of this analysis.

What is interesting here — and seems to matter — is that price values are clustered.

After creating this chart, I decided to split out older values to see if the clustering is relevant. The transformation made the points semi-transparent with time: the older is the point, the more transparent it would be.

Here’s what the chart looks like after the transformation:

Scatter plot comparing the price versus volume for $WMT with older values split out.

So far so good. Interesting, even.

The clusters to the left (e.g. price less than $70) consist of older values, meaning that WMT has not recently traded within this price range. Clusters after the $80 mark look much “fresher”. The $75 to $80 cluster consists of both older and newer points, which means that WMT has revisited this price range at some point.

At this point, I was getting very excited about the idea of price clustering.

I found myself wondering about whether or not having Volume as the Y-axis actually helps or not. I mean, it looks fine, but Volume axis does not contribute to understanding price clusters. On the other hand, without Volume as the Y-axis, the chart will end up looking like a single, crowded line of values (like the one below), which isn’t all that interesting to look at.

Scatter plot comparing the price versus volume for $WMT with volume as the Y-axis.

If you randomize the vertical placement of the points, using a random number (from zero to 1), you can visualize the data in a somewhat more useful way.

This is the same data as the single line above but scattered at random. The motivation behind this exercise was to focus on prices and clusters alone and to generate a visualization that can paint that information.

Here’s how it would look for WMT (remember that vertical coordinate actually means nothing):

Scatter plot comparing the price versus volume for $WMT with volume as the Y-axis and scattered at random.

Looks interesting!

The dots form stripes and the stripes are of various thicknesses. These stripes are easily visible, and it’s obvious that there are gaps in trading (price ranges where there were little to no trades at all, like $78 to $81).

The next thing to do would be to build a histogram, to see the picture from a slightly different angle.

Histogram comparing the price versus volume for $WMT.

In this visualization, I have calculated (a) number of candles and (b) summary volume traded for each of price ranges.

The picture looks pretty familiar, but now we can compare price clusters directly. For example, one can tell that WMT has traded in price range of $95 to $100 twice as long as the $65 to $70 range.

Here is the same visualization, but this time using 6 months of 5 min candles:

Scatter plot and histogram comparing the price versus volume for $WMT using 6 months of 5-minute candles.

Can you imagine seeing see smaller price clusters inside of these large clusters? Well, that’s exactly what happened in this example!

If one assumes that price tends to hang around the same clusters, and current WMT price is around $102, then one might calculate a profit-loss (P/L) ratio.

There are no recent solid clusters above $102, but there’s a little older strip around $104. The closest obvious cluster from below is $97 to $99.

I don’t really know how valuable this approach is, but it was a lot of fun to play around with. Is it useful? Maybe, but more research is required. For now, I hope you find it as interesting as I did.

Appendix: More Charts

Here are a bunch of scatter plot charts for a dozen randomly chosen symbols for you to explore:

NOTE: Charts below build from 23196 of 10-min candles each (since Tue, Jan. 03, 2017).

KO,10,bucket=0.5

$KO scatter plot and histogram.

IBM,10,bucket=2

$IBM scatter plot and histogram.

WMT,10,bucket=1

$WMT scatter plot and histogram.

AAPL,10,bucket=2

$AAPL scatter plot and histogram.

FB,10,bucket=2

$FB scatter plot and histogram.

AMZN,10,bucket=20

$AMZN scatter plot and histogram.

NFLX,10,bucket=5

$NFLX scatter plot and histogram.

NOTE: 13284 candles, since Tue Jan 02 2018 09:30:00 GMT-0500

MCD,10,bucket=1

$MCD scatter plot and histogram.

CSCO,10,bucket=0.5

$CSCO scatter plot and histogram.