Closed jetonbacaj closed 3 years ago
I'm thinking of using a javafx.beans.property.SimpleListProperty and whenever the underlying list changes within a Listener, subscriptions will be re-evaluated and updated accordingly. I'll start a PR soon.
I'm thinking of using a javafx.beans.property.SimpleListProperty and whenever the underlying list changes within a Listener, subscriptions will be re-evaluated and updated accordingly. I'll start a PR soon.
Wouldn't adding a "removeTicker" method, which in turn calls Polygon with a {"action":"unsubscribe","params":"{channel}.{ticker}"}
(and the appropriate method+call for subscribing) be enough of a functionality, instead of having a List listener? The latter would be cool, but I would personally prefer explicit calls for sub/unsub, and not expose the actual list in any way.
I think it's a better design to keep the Listener interface that contains a list getter for the tickers and their associated channels (e.g. AlpacaStreamListener#getStreamMessageTypes). Perhaps what we could do is have some method in AlpacaAPI
/PolygonAPI
like refreshListener
that will send the subscribing/unsubscribing messages based on the underlying updated list in the Listener interface. What do you think?
@jetonbacaj any thoughts on my previous comment?
I think that that would work, though depends on the implementation of the refreshListener
.
I'd avoid doing a unsubscribe
then subscribe
for all of the tickers in the list after the add/remove, as this could result in a ticker information data loss in the interim (especially for second bars, and even more so for trade and quote updates).
Unless I am misunderstanding your idea... which is completely possible, and quite probable. :-)
If we need to add or remove a specific ticker from the alpaca and/or polygon, we have to remove the whole listener, reinitialize it with the updated ticker list, and then listen for it again.
Any way we can just add or remove tickers from the listener itself? @Petersoj