AI in Action: Capturing Stock Price Patterns using Google AutoML – by Stephen Chan

Recently I have spent some time on technical analysis of stock markets, and started to build some tools in Python to help me invest in a more systematic fashion.

There are many useful APIs in the market that allow users to download end-of-day price and volume data of stocks listed in Hong Kong Stock Exchange. Then the next step is to apply simple trading strategies to extract signals from the market eg based on closing price vs moving averages, daily volume changes or as a proportion of average monthly volume.

“… what is obvious in the market rarely works…”, William J. O’Neil

Then I came across a common problem among retail investors: the more obvious the signals, the less reliable they are. As the legendary short-sale investor William J. O’Neil pointed out, “what is obvious in the market rarely works”. Scanning stocks where prices breaking through a particular moving average is just too simple. Hence I searched for a more sophisticated approach.

Credit goes to the legendary trader Mark Minervini. His notion of Volatility Contraction Pattern (VCP) seems interesting enough. Basically it refers to a stage where the stock price fluctuates in decreasing volatility, together with trading volumes going down. There are additional conditions that the stocks have to be in an uptrend in general (more at this link).

The case for using Machine Learning

  1. Rule-based approach is not feasible: Unlike identifying price breakthroughs vs moving average on a particular date, there are no easy ways to identify the VCP pattern over a period of time. Previous efforts in rule-based filtering or fitting sinusoidal curves had not yielded any satisfactory results. Image recognition is perhaps the way to go.
  2. Actionable insights can be generated automatically: Scanning the charts of hundreds of Hong Kong stocks by human eyes is time-consuming and distracting. If 10-20 VCP stocks can be identified by the model on a daily basis, investors can focus on a much smaller set of stocks, and decide the right trading strategy in the next few days

Deployment at Google AutoML

From technical perspective, it is a problem of objection detection within the context of image recognition. The labels are stock price patterns (ie VCP), and there could be more than one label appearing in one stock chart image. The labels need to be customised when training the model. The key outputs of the model are labels and the coordinates of bounding boxes.

I tested out my first deployment using Google AutoML, and were very much impressed by the results in the first run within a week. I generated ~400 images of stock charts using Python, then uploaded to Google Cloud/AutoML via API, and identified the labels available in each image (label was the most time-consuming part as always). Although the count of labels is around 100 each, it seems to be sufficient for the model to pick up labels in new images.

The rest of the article can be found here:

https://www.linkedin.com/pulse/ai-action-capturing-stock-price-patterns-using-google-stephen-chan

2 Replies to “AI in Action: Capturing Stock Price Patterns using Google AutoML – by Stephen Chan”

Leave a Reply

Your email address will not be published. Required fields are marked *