Stock screeners are one of the most efficient ways to sort and filter thousands of stocks at a time. Most traders and investors use stock screeners to choose stocks feasibly based on certain search criteria. Though there are platforms like TradingView offering amazing screeners, it’s always optimal to construct your very own screener with coding for ultimate flexibility and customization. But there’s a small problem with it.

Many people may find it difficult to code their desired screener from scratch as it involves a lot of processes like extracting and assembling different types of fundamental data, putting it all together, filtering, sorting, etc. This is where EODHD’s Screener API comes to the rescue.

In this article, we will first explore what this Screener API is, who needs this specific API, and what actually comes with this API. Then, we will use Python to delve deep into the practical aspect of the API by building several stock screeners. With that said, let’s dive into the article!

Register & Get Data

EODHD Screener API

Usually in order to build a stock screener from scratch, it’s essential to pull different data from various sources and compile them for further sorting and filtering. But with EODHD’s Screener API, users can filter out companies with defined parameters – such as market capitalization, exchange, industry, dividend yield, and a bunch of others – in a fraction of a second. This is what makes the API so special as it helps save a ton of time in extracting and assembling the data.

Now let’s talk about who this API is actually for. Unlike APIs like news sentiment API and macroeconomic data API which have a very specific purpose and are suitable for a small group of people, the Screener API has a wide range of use cases. For example, traders and investors can build their own screeners to choose stocks, researchers can use this API to analyze the stocks according to their search criteria, and the list goes on and on.

So, what actually comes with this specific API endpoint? Basically, it gives a dataframe that contains a list of tickers along with some fundamental data about the stock. The list is given based on the search criteria given by the users. As simple as it is. The API comes up with great customization with regard to constructing the search criteria which makes this whole process much more simplified.

Now that we have a good background about what the Screener API is, let’s proceed to the interesting part of the article which is to use Python for constructing various screeners with the help of this API.

Importing Packages

The first and foremost step in this process of building stock screeners is importing the required packages into the Python environment is a non-skippable step.

We’ll be requiring only two packages in this article which are EODHD’s Python Library “eodhd” for data extraction, and Pandas for data manipulation and data wrangling. The following code imports the necessary packages into our Python environment:

If you haven’t installed any of the imported packages, make sure to do so using the pip command in your terminal.

API Key Activation

The second step in this process of using the stock screener API to build custom screeners is API key activation. It is essential to register the EODHD API key with the package in order to use its functions.

If you don’t have an EODHD API key, firstly, head over to their website, then, finish the registration process to create an EODHD account, and finally, navigate to the ‘Settings’ page where you can find your secret EODHD API key. It is important to ensure that this secret API key is not revealed to anyone.

You can activate the API key by following this code:

The code is pretty simple. In the first line, we are storing the secret EODHD API key into the api_key, and then in the second line, we are using the APIClient class provided by the eodhd package to activate the API key and stored the response in the client variable.

Note that you need to replace <YOUR API KEY> with your secret EODHD API key. Apart from directly storing the API key with text, there are other ways for better security such as utilizing environmental variables, and so on.

Register & Get Data

Building a Basic Stock Screener

Now that we’re all set, let’s start off by creating a simple stock screener with just a single filter. We will create a screener that shows only the US-listed stocks and sorts the screener in descending order based on the market capitalization. The following code implements this specific criteria:

In the above code, we are first using the “stock_market_screener” function provided by the eodhd library to extract the screener according to our criteria.

The function takes two important parameters which are “sort” which sorts the screener based on the mentioned data field, and “filters” where we should specify the search criteria of our stock screener. There is another important parameter called “signals” which we’ll discuss later in this article.

Apart from the three important parameters, there are two secondary parameters which are the “limit” and “offset” parameters which can be used according to the users’ requirements.

This is the output of the above code:

As I mentioned earlier, the screener comes with a lot of fundamental data which can be really useful for traders and investors while choosing their stocks.

Building a Stock Screener with Multiple Filters

Now, let’s up the game by creating an advanced stock screener with multiple filters. The previous screener we created did not bring much value to the table, i.e., no investment insights can be drawn from the screener. So we’ll create a meaningful screener with the aid of multiple filters.

Let’s try to build a screener that shows the most profitable stocks by sorting the Earnings Per Share (EPS) and the two search criteria for the screener are:

  • the market capitalization must be greater than $100 Billion
  • the company must operate in the Technology sector

The following code builds a stock screener according to our conditions:

The code is pretty much similar to the previous one except we are making some changes to the “sort” and “filters” parameters to incorporate our search criteria. The following screener is the output of the above code:

The screener shows the top 10 most profitable stocks according to Earnings Per Share and all the stocks are in the Technology sector having a market capitalization of at least $100 Billion.

Screener with Signal-Based Filtering

Now, we’re going to make use of another important parameter that comes with the “stock_market_screener” function which is the “signals” parameter. For example, if you need only tickers that have new lows for the past 200 days and the Book Value is negative, you can use the parameter ‘signal’ to create a screener with this search criteria.

This parameter comes in handy for custom screeners which cannot be created just with the help of “sort” and “filters” parameters. Let’s try creating a stock screener that shows stocks that have achieved a new 200-day low and it must be a US-listed security. The following code implements this search criteria:

Again, the code is pretty much similar to the ones we saw before except we are adding a new parameter which is the “signals” parameter where we are specifying the criteria for signal-based filtering.

The output is a stock screener that shows US-listed securities that have achieved a new 200-day low and it looks like this:

Let’s try one more example of using the “signals” parameter. The following code creates a stock screener that shows stocks operating in the Financial Services sector and is considered overvalued by Wall Street:

The code is almost the same as the previous one except for a minor change in the “signals” parameter. This is the resulting screener of the above code:

Apart from the “200d_new_lo” and “wallstreet_hi” fields in the “signals” parameter, there are four more supported fields that are:

  • “200d_new_hi” – filters tickers that have new 200 days highs
  • “bookvalue_neg”, and “bookvalue_pos – filters tickers with positive Book Value or with Negative Book Value.
  • “wallstreet_lo” – filters tickers that have a price lower than expected by Wall Street analysts.

Conclusion

In this article, we dug deep into EODHD’s Stock Screener API. We started off with understanding what the Screener API is all about and then moved forward to the programming part where we built several stock screeners with Python.

The purpose of this article is to showcase a few of the applications of the Screener API, but there is a lot more that you can do than what’s featured in this article. You can play around with the available parameters and the supported fields of the API to explore the numerous possibilities.

With that being said, you’ve reached the end of the article. Hope you learning something new and useful today. Thank you very much for your time.

Do you enjoy our articles?

We can send new ones right to your email box