Home » Use An API To Automate Your Stocks Search

Use An API To Automate Your Stocks Search

This article inaugurates a new “tooling” section that I’ve created to deliver programmatic content to drive your investments. The topic of today is a stock market API that allows you to automate your stocks search: a way to filter the companies you like based on criteria you’ve defined. Also, remember to subscribe to our free newsletter if you like the article.

1. First, let’s define a “stable dividend-payer”

An easy scriptable way to define a “stable” stock is to use a concept called beta. The beta of a stock is a measure of how an individual stock moves with respect to the overall stock market. If the beta is above 1, it’s more volatile than the market. If it’s below 1, it’s less volatile than the market. Here, we want the stock to be “stable” with low volatility; thus, we select a beta between 0.1 and 0.5, based on the last 5 years.

2. Now, let’s use the FMP API to find all of these companies in a blink

First, you will need to get yourself an API key and create an account here. Once done, your key will appear here:

Then, you can use the Stock Screener API with your freshly generated key to search for “dividend-payers” that are “safe“. This will simply be a URL to type into your browser. Let’s start with the base of the URL:

If you want companies paying dividends, with a non-volatile track-record, add it to the URL, including your private key:

If you press enter in your browser, you end up with a list of companies matching your criteria:

See also  Top Bioenergy Companies

3. Finally, we pick the top-3 by market capitalization

Now let’s assume you want to target the 3 largest companies in that subset because you think they will be the safest. Then let me do a bit of Python magic on this list of companies:

In this scenario, your 3 winners are: Tencent, Walmart and Nestle.

3. Conclusion

We’ve shown how to find large and stable dividend-payers with a one-liner using the FMP API and the results are:

As you can see, the API is very flexible to automate your stocks search: unlike stock screeners with an interface that forces you to use only specific operations, you can call a myriad of requests and build immense testing plans the way you fancy them with a bit of scripting. It’s also a great source to synchronise your local data lake and train machine learning (prediction or inference) models. I hope this article has taught you something and that you will put this API into your data-driven investor bag! Take care, Clem

Disclaimer: as usual, this is not financial advice, just sharing a tool I like.

Related Posts

Leave a Comment