How do price threshold alerts work for stock/forex/crypto apps?

I have been looking for an answer to this question for months believe it or not, but have not found anything definitive.

Many finance based apps (including free apps) allow users to set simple ‘price alerts’ for a particular market (eg. stocks, bitcoin, etc). When price crosses that threshold, the user receives their custom APNS alert/notification. How are these alerts generated- eg. a backend server constantly monitoring price and iterating possibly thousands of individual user devices to send custom individual alerts (this seems like quite a heavy process to run 24/7)? Or is there something simpler, that I am missing?

Any advice or resources as to where I could find help for this would be greatly appreciated.


Hi @jfixin and welcome to the forum community! From my understanding the backend would be responsible for tracking and notifying the user of any changes from the API. You could have a backend such as Firebase for example that also uses cloud functions. The cloud functions would monitor and trigger a notification to the user if any changes were to occur. There are also services such as Pusher can also help with real-time experiences. They’ve published an article on real-time notifications with a stock API that you might find helpful.


Hi @jfixin,
There are a couple of moving parts that achieve that, and there can be several implementation to manage the same, however one that worked for us was as so,

  1. A microservice that retrieves the latest prices
  2. The app/user saves the data on some cloud based service for the alerts
  3. Subscribe to updates to that microservice in #1
  4. When an update is broadcast, the lambda/cloud function runs and checks if the conditions set in #2 are met and if they are, it sends a notification to the app/user

If you separate and move the processing away it can be done in a more efficient manner.

hope that helps

@gdelarosa thanks- yes I am using Firebase cloud functions already. But can’t see an efficient way to do custom price alerts for individual users without topics. eg. user 1 wants an alert at $9999.99, and user 2 wants alert at $1000.01. The cloud function would need to iterate all users for alerts for every price change, and price changes every second. You can see how this can blow out with a lot of users- and the cloud function would need to run 24/7.

@jayantvarma this is interesting, can you expand on #3 and #4 (i have 1+2 handled). Is every tick/price change an ‘update to broadcast’? This also sounds like a lot of processing.

Thanks guys.

depending on how you have implemented #1 and #2 things can be different.
However the idea is very simple, the #1 only needs to update prices and broadcast a change
#2 is saving the conditions
#3 & #4 are all the subscriptions but managed by a cloud function that will receive an update broadcast, which can then depending on your implementation further check for conditions that match.

These are implementations which organisations spend resources on to hone and perfect to get optimal performance, you can get an overview to think about, implementation will be a lot more detailed.

This topic was automatically closed after 166 days. New replies are no longer allowed.