Getting market movers (gainers and losers)?

I am wanting to make a bot that trades the day’s biggest market movers (largest percent increase or decrease from the previous day). I read in this post that there is a use case where the user could query this data:

First, the investor could set up a daily query to check the 10 biggest daily losers out of a list of 500 stocks. Next, the system can retrieve the peers and industry tags for each of those losers and check their performance. Subsequently, part of the system can scan the news for the day and determine whether any major news occurred, potentially by keyword matching.

However, looking through the documentation, I don’t see which endpoint you could hit to achieve this screen. Hitting /v2/assets returns over 10,000 assets, but there is no percent change field on the objects returned. To me, it seems that one would have to loop through each asset on this list and manually generate a list of market movers. I would greatly appreciate if somebody could let me know if this is, in fact, the only way to achieve this, or if there is a simpler way. That is, if there is an endpoint for querying by percent change.

Thanks!

Would this work?

or

1 Like

I’ve begun working with Polygon’s API. The gainers/losers endpoints are actually what I’m using now. I hadn’t previously realized that Alpaca users got access to premium Polygon features. One issue is that this Polygon gainers/losers screen doesn’t return a lot of stocks. Many of them aren’t shortable. There is no way to query Polygon (as far as I know) for stocks that are tradable/shrotable through Alpaca. I’m needing to do a check on each individual security for tradability/shortability after receiving the list from Polygon.

What I do is use the Snapshot all Tickers API call. This gives me all stocks in the market (not just the limited gainers / losers polygon gives you).

Then I use the Alpaca /v2/assets API. To get a list of stocks that are easy to borrow. Then only look at the stocks that return via the Snapshot API that are easy to borrow.

1 Like

Any idea if the Snapshot All Tickers endpoint has a parameter for sorting by todaysChangePerc ascending/descending?

Actually, now that I think about it, it should be pretty easy to sort on the frontend.

There is nothing that limits you to using only Alpaca or Polygon in your app.

For gainers and such, I would suggest using a REST API for Yahoo Finance (which still delivers daily data)…

from yahoo_fin import stock_info as yf_info
...

df = yf_info.get_day_gainers()

This call is a wrapper for the following API:
https://finance.yahoo.com/gainers?offset=0&count=100
– which returns a dataframe (from pandas) of the first one hundred gainers of that time. Same with losers.

(You would need to couch the call with try / except since it does fail occasionally).

The REST API can be found here:

Let me know if you have any more questions!

Best,
Gil

Here are the columns of the dataframe for gainers:
Symbol
Name
Price (Intraday)
Change
% Change
Volume
Avg Vol (3 month)
Market Cap
PE Ratio (TTM)

Gil

Hey Gil,

I know that I don’t have to use Polygon or Alpaca, but I was hoping that they would have this functionality built in so that I wouldn’t have to filter for shortability/tradability on Alpaca. I’m currently using @spicer 's suggestion of getting all tickers and sorting on the front end. Its working well!

1 Like

Glad to hear!

My point was that you can incorporate stock data from sources other than Alpaca while still using Alpaca for trade. Sorry if I stated the obvious.

For me, getting gainers through Yahoo works best (though they do fail on many other fronts as well) – without needing to filter irrelevant stocks etc. – but I get it that all is working fine for you now.

Gil

All good, thanks for the suggestion! I checked out Yahoo, but it seems that it isn’t very well maintained. That is, I couldn’t find a good documentation page for it, so it was a lot of guesswork.

1 Like