tedchou12 / webull

Unofficial APIs for Webull.
MIT License
601 stars 184 forks source link

Regarding Stock Alerts Not Working #302

Open asam007s opened 2 years ago

asam007s commented 2 years ago

I face an issue with setting Alert to Stock script. After setting Alert using Alerts_Add (...) API i am not able to get the Notification call back. I verified that the Alert is set successfully! But my question is :How do I get the notification if the Alert condition is met ?

can I get some help please

Rgds Student.

zenhorace commented 2 years ago

Where are you hoping to be notified when the alert condition is met?

asam007s commented 2 years ago

Thanks for your reply.. Once the condition is met/satisfied, I am expecting to notify back to the calling process/func which has registred the alert event. I am not sure if it will generate any type of call back or we need to keep polling.. do you know the mechanism to catch the alert hit.

zenhorace commented 2 years ago

So the APIs provided aren't long running operations. When you call an API to set an alert, it performs the task of setting it and returns if that task was successful. At that point the transaction is done. There is no callback or webhook that you register with the alert. If you're lucky, maybe what webull does on their end is open up a websocket to notify the clients when an alert is met. This is unlikely though. What's more likely is that webull is tracking these conditions on their backend and sends a push notification to clients when the condition is met. There may be an API that we can call to see what conditions have been met/pushed, but then you'd have to implement some polling mechanism to know when that happens. My suggestion: only use the add alerts API if you want to be alerted in the client (browser, app, desktop). Otherwise, you may be better off implementing your own alerts by pulling bars and evaluating at intervals.

asam007s commented 2 years ago

Thanks Zenhorace for your quick reply.. I think I came acorss push messages, (with differnt topic level) but what i see in that they are available in webull only for streaming purpose using StreamConn. Here polling is not reqired. but a on_price call back is notified. this is similar to Alert but doesnt serve the actual perpose if we want to define a specific price level to meet. What wonders me is Setting Alert is quite a very bacis function and cannot go without it in designing an embeded programming. It might be required for various puspose for Example say : WeatherAlert or StockAlert- or in generical an application that waits on external event -might need Alert type of mechnism. -- Please Feel Free to Share your opinion :)

zenhorace commented 2 years ago

So you're saying that you've seen the clients use websockets (streamConn) to notify of alerts? In that case, feel free to just listen to that connection.

And yes, alerts/notifications are common requirements. They are usually achieved using websockets or webhooks or a push notification service.

asam007s commented 2 years ago

Webull defines streamConn, but its not for Alerts. it like subscribe for call back event on specific script you define.. here you get to read the full price dumb which is very frequent.. may be you will see 2-3 calls every seconds.

As you said previously .. "There may be an API that we can call to see what conditions have been met/pushed, but then you'd have to implement some polling mechanism to know when that happens."

Can I find any API.. ? which I can poll to read the push mesage specific for Alert kind of thing. In app as you noted we get the notification message properly... cant I read this by polling an API ? if you know any such API.. please let me know.