Creating realtime alerts for stock quotes - websocket

I want to create a realtime stock alert app where users can subscribe to specific stock instrument with target price. Once that target price hit, The subscribed user will be notified over the app.
A good example of such platform is Tradingview.com
For stock API's I will be receiving realtime stock quotes from My API vendor over.
As far my knowledge is concern, I'm looking at this app as Web socket OR MQTT pub/sub platform where users can subscribe to that specific instrument topic and get notified once stock price is hit.
But my knowledge is limited when it comes to thousands of users subscribing to thousands of alerts.
What technologies must be going at the backend for such kind of apps ? What must be the data flow ?

Bit late answer to this, I was working on something similar with all custom NodeJS server and instruments you want to subscribe on. It is very simple server and you can find it here https://github.com/markosole/yahoo-node-streamer
I am working on desktop App built on top of Electron which is used for subscribing to instruments, monitoring multiple instruments and creating visual and sound alerts for every instrument individually. I have not release Electron app source to the public yet.
Creating mobile app will be harder as it would require backround data and best bet would be using Flutter and Google Firestore to send alerts. Well this is very top level.. I will eventually make flutter app and share it on Github

Overlooking the fact that there are literally thousands of apps out there that do all of this already....
Your best bet might be to do one of two things:
1) Just send out the stock price and let the client app figure out the alert, or
2) Have a back-end system that just sends out the alert to the specific customer when their price point is reached.
Option 1 is something that MQTT could easily do. Option 2 could be done using MQTT, but its something of an overkill IMHO. MQTT is built for applications where one node is publishing data, and many nodes are subscribing to that data -- hence Option 1 is more in line with what MQTT was built for.

Related

Alternative of cloud functions

I am developing an app for elderly for my graduation project. There are 2 actors, elderly and the watcher who takes care of elderly.
'all application data stored in Firebase'
My app reminds elderly about their medication time and to check their blood pressure and glucose.
Also, there is a chat between elderly and watcher.
My question is how to push notification without using cloud functions?
I have watched a Flutter course and he used Firebase Cloud Messaging and Cloud Functions, but now Cloud Functions requires to upgrade project's billing plan, so it requires money and credit card, and I don't want to spend money for my graduation project especially that I don't have a huge knowledge about flutter.
I watched a YouTube video that someone explains push notification using Laravel with Flutter, but I afraid about that because I DON'T HAVE ANY IDEA ABOUT Laravel.
Also I see that there are many Flutter packages for push notification, but I don't know how to use it or if it uses a Cloud Functions or not. such as: awesome_notifications, flutter_local_notifications, pusher
I hope someone guide me to the right way.
in order to send custom notifications you can create your own server environment (backend) and from there perform all the logic to be able to send the notifications to the devices.
The only thing you need to be able to send a personalized notification from an external environment is to have the token device, in the case that you will send it to a specific person, you can also send notifications if the devices are subscribed to a topic.
This is the documentation to send notifications from a server to the device:
https://firebase.google.com/docs/cloud-messaging/http-server-ref

How to build real time notifications in a distributed project?

I wonder to know which technique and tools I should use to have the ability to send real time notifications to users. Specifically if I build a messaging system.
I can see that modern social networks can send notifications about new messages almost immediately. Even when the user 'A' from one country writes a message to the user 'B' in another country you can see that the user 'A' writes a message and you immediately see it (even if those users live in different continents).
I tried to figure out how it is possible and find any information about this but without success.
The only thing I found out is the technique when we use a Redis or RabbitMQ server with several servers which acts like publishers and subscribers. Our API servers receive new messages then they push a new message in the queue then subscribers receives the messages and if they have an open WebSocket with the recipient they push this message in the WebSocket and a client receives the message.
But it really won't work if you have a distributed project and your clients are connected to the nearest servers in the nearest data center.
The question is: what technologies/techniques/anything we should use to be able to build notifications in a distributed project?
If you develop your distributed app/system using web technologies, you can consider building what is referred to as a Progressive Web App. With PWAs you can add push notifications in a relatively easy way. You could start with a PWA approach, and then decide later on if developing a native app as well (i.e. iOS or Android) would be necessary.
There are many resources to learn and guide you in developing progressive web apps. Check the references I mentioned above, and you can do this codelab as a starting point.

Broadcast events in Firefox OS

I am wondering if there is a way for a Firefox OS app to broadcast an event to all other apps and for the interested apps to hook on that event and trigger a corresponding action.
An example of use case I have in mind: the Camera app broadcasts the event "picture taken" and another app hooks on this event and take some action on the new picture that has been taken (for example, uploads it to a server).
There's not currently a web API in Firefox OS to broadcast events to all open and/or interested apps.
For your particular use-case of apps being notified when a new photo is taken by Camera, the best approach is probably to open DeviceStorage for "pictures" and listen to "change" events.
Documentation for this is at:
https://developer.mozilla.org/en-US/docs/Web/API/DeviceStorage
Alternatives exist but are more restricted functionally, and available in fewer releases and contexts:
The system can broadcast messages, but only certified apps can listen. https://developer.mozilla.org/en-US/docs/Web/API/Navigator.mozSetMessageHandler
The InterAppCommunication API allows web applications to message one or more other apps, but in a more tightly coupled way than a general broadcast. However this API is not yet standardized, and is only available to certified apps. https://bugzilla.mozilla.org/show_bug.cgi?id=876397
Access to system preferences is coming soon for non-certified apps, and maybe could be used to do this, but that's a hacky way of accomplishing messaging and data sharing. https://developer.mozilla.org/en-US/docs/Web/API/SettingsManager
Note: For every example here, your app would have to be running for it to work. There's no mechanism for waking an app up when a specific action or event occurs. Web Activities is the closest API for event-specific app loading. Timers API is for non-specific app loading.
From this article[1]:
App authors can build an app that will handle one or more activities. That means that the app will be callable by another app to perform some specific actions defined by the activity. For example, let's pretend we want to build a photo manager. It could be used by another application to pick a photo. As an activity handler our app will become part of the other application's workflow.
[1] https://developer.mozilla.org/en-US/docs/Web/API/Web_Activities

Can I use PubNub for realtime data collection?

I'm interested in collecting realtime data periodically (say every 1 min.) through a mobile app on my server. Can I use services like PubNub or Pusher for it or are they only for communication in the other direction - like sending push notifications from a server?
If I can use, could you please explain how exactly the setup would work?
PubNub can provide bi-directional real-time datastreams on all devices, including mobile! Any phone (or server) can be a publisher, or a subscriber, or both.
You can choose your SDK of choice here http://www.pubnub.com/developers/ -- each client has docs for a simple hello world app.
If you need more assistance in getting setup with PubNub on mobile, just shoot us an email at support#pubnub.com and we will assist!

broadcasting data to mobile devices

I working on a project were mobile users can receive alerts based on diferent factors, the server side will be implemented using the MVC framework.
My question is regarding the client side; what would be the most efficient way to send the alerts to the clients? is there any way to broadcast the alerts to each device or do I have to set up some system where each device pulls the data from the server on an interval of mins/seconds? I am afraid pulling the data every X secs/mins would create an unnesesary overhead on the mobile devices.
One way would be using SMS but SMS gateway services are expensive and not on my budget right now.
I haven't personally tried it, but this service might work for you:
http://www.airgramapp.com/api
It is free for limited use. Downside is it appears to be a separate install on the mobile device. This might means less control of the content of the message or its look. Upside is it looks quick and easy if you just need a proof of concept at this point.

Resources