-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: WebSocket Client for Live Data Streaming #2201
base: dev
Are you sure you want to change the base?
Conversation
38ee363
to
55b4a90
Compare
@ValueRaider any opinions on this websocket? Is it suitable for this package? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could add a new function in WebSocket
for initialization.
Also I think its worth considering adding an async option
if self.is_running: | ||
self.logger.warning("WebSocket is already running.") | ||
print("WebSocket is already running.") | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not "unsubscribe" from everything and then resubscribe to everything + this new ticker.
This would be easier for the user as this is what they ultimately will end up doing
try: | ||
self.ws = create_connection(self.uri) | ||
self.is_running = True | ||
|
||
subscribe_message = {"subscribe": symbols} | ||
self.ws.send(json.dumps(subscribe_message)) | ||
self.logger.info("Subscribed to: %s", symbols) | ||
|
||
self.listen() | ||
except Exception as e: | ||
self.logger.error("Failed to subscribe to symbols: %s", e, exc_info=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let the user call listen, have this function return itself and just update the tickers.
@@ -39,7 +39,8 @@ Yahoo! finance API is intended for personal use only.** | |||
- `Ticker`: single ticker data | |||
- `Tickers`: multiple tickers' data | |||
- `download`: download market data for multiple tickers | |||
- `Market`: get infomation about a market | |||
- `WebSocket`: live streaming data for multiple tickers | |||
- `Market`: get information about a market |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
Changes
WebSocket
class to stream live market data.pricing.proto
andpricing_pb2.py
) for data de serialization.requirements.txt
andsetup.py
to include new dependencies.Usage