# Getting market movers (gainers and losers)?

**URL:** <https://forum.alpaca.markets/t/getting-market-movers-gainers-and-losers/3458>\
**Category:** Alpaca Market Data\
**Created:** [November 28, 2020, 10:13pm UTC](https://forum.alpaca.markets/t/getting-market-movers-gainers-and-losers/3458 "2020-11-28T22:13:08Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidchopin](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@davidchopin](https://forum.alpaca.markets/u/davidchopin)\
**Post date:** [November 28, 2020, 10:13pm UTC](https://forum.alpaca.markets/t/getting-market-movers-gainers-and-losers/3458/1 "2020-11-28T22:13:08Z")

</div>

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](https://alpaca.markets/learn/market-data-api-intro/#a-possible-use-case-of-data-apis) 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!

---

<div class="post-metadata">

**Author:** ![spicer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/spicer/32/1079_2.png) [@spicer](https://forum.alpaca.markets/u/spicer)\
**Post date:** [November 30, 2020, 7:21pm UTC](https://forum.alpaca.markets/t/getting-market-movers-gainers-and-losers/3458/2 "2020-11-30T19:21:40Z")

</div>

Would this work?

> **[Snapshot - Gainers/Losers - Polygon.io](https://polygon.io/docs/get_v2_snapshot_locale_us_markets_stocks __direction__ anchor)**

or

> **[Snapshot - All Tickers - Polygon.io](https://polygon.io/docs/get_v2_snapshot_locale_us_markets_stocks_tickers_anchor)**

---

<div class="post-metadata">

**Author:** ![davidchopin](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@davidchopin](https://forum.alpaca.markets/u/davidchopin)\
**Post date:** [November 30, 2020, 7:34pm UTC](https://forum.alpaca.markets/t/getting-market-movers-gainers-and-losers/3458/3 "2020-11-30T19:34:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![spicer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/spicer/32/1079_2.png) [@spicer](https://forum.alpaca.markets/u/spicer)\
**Post date:** [November 30, 2020, 8:42pm UTC](https://forum.alpaca.markets/t/getting-market-movers-gainers-and-losers/3458/4 "2020-11-30T20:42:45Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/alp/original/2X/d/ddfa537a3971e9876ad00015817030eb08816fe9.jpeg)

---

<div class="post-metadata">

**Author:** ![davidchopin](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@davidchopin](https://forum.alpaca.markets/u/davidchopin)\
**Post date:** [November 30, 2020, 8:54pm UTC](https://forum.alpaca.markets/t/getting-market-movers-gainers-and-losers/3458/5 "2020-11-30T20:54:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![davidchopin](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@davidchopin](https://forum.alpaca.markets/u/davidchopin)\
**Post date:** [November 30, 2020, 8:55pm UTC](https://forum.alpaca.markets/t/getting-market-movers-gainers-and-losers/3458/6 "2020-11-30T20:55:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gilbenherut](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@gilbenherut](https://forum.alpaca.markets/u/gilbenherut)\
**Post date:** [December 2, 2020, 1:31am UTC](https://forum.alpaca.markets/t/getting-market-movers-gainers-and-losers/3458/7 "2020-12-02T01:31:33Z")

</div>

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)…

```auto
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](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:

> **[atreadw1492/yahoo\_fin](https://github.com/atreadw1492/yahoo_fin)**
>
> Scrape stock price history from new (Spring 2017) Yahoo Finance layout - atreadw1492/yahoo\_fin

Let me know if you have any more questions!

Best,  
Gil

---

<div class="post-metadata">

**Author:** ![gilbenherut](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@gilbenherut](https://forum.alpaca.markets/u/gilbenherut)\
**Post date:** [December 2, 2020, 1:35am UTC](https://forum.alpaca.markets/t/getting-market-movers-gainers-and-losers/3458/8 "2020-12-02T01:35:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![davidchopin](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@davidchopin](https://forum.alpaca.markets/u/davidchopin)\
**Post date:** [December 2, 2020, 2:22am UTC](https://forum.alpaca.markets/t/getting-market-movers-gainers-and-losers/3458/9 "2020-12-02T02:22:45Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![gilbenherut](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@gilbenherut](https://forum.alpaca.markets/u/gilbenherut)\
**Post date:** [December 2, 2020, 2:44am UTC](https://forum.alpaca.markets/t/getting-market-movers-gainers-and-losers/3458/10 "2020-12-02T02:44:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![davidchopin](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@davidchopin](https://forum.alpaca.markets/u/davidchopin)\
**Post date:** [December 2, 2020, 2:57am UTC](https://forum.alpaca.markets/t/getting-market-movers-gainers-and-losers/3458/11 "2020-12-02T02:57:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![alpacanoob](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/alpacanoob/32/2371_2.png) [@alpacanoob](https://forum.alpaca.markets/u/alpacanoob)\
**Post date:** [January 18, 2023, 12:34am UTC](https://forum.alpaca.markets/t/getting-market-movers-gainers-and-losers/3458/12 "2023-01-18T00:34:46Z")

</div>

Any update on this? [Polygon.io](http://Polygon.io) now costs $30 a month for the snaphot apis.
