Skip to content
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

WebSocket streaming with thread pool/executor #5

Open
scawful opened this issue May 5, 2022 · 0 comments
Open

WebSocket streaming with thread pool/executor #5

scawful opened this issue May 5, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@scawful
Copy link
Owner

scawful commented May 5, 2022

This is an advanced task, so be prepared to do a lot of threading, networking, and reading Boost documentation.

To help with this feature you should be knowledgeable with Boost.Asio https://www.boost.org/doc/libs/1_77_0/doc/html/boost_asio.html and Boost.Beast https://www.boost.org/doc/libs/1_79_0/libs/beast/doc/html/index.html

Currently the WebSocket features of Premia are limited to the Socket class in the TDAmeritrade service, which simply polls the API and then prints the responses to the console. However, a single instance of the stream isn't very useful when you have a watchlist full of symbols and multiple charts to update, so I want to convert the WebSocket thread as its implemented into a thread pool with an active listener/callback for all the data updates so it can be efficiently used for the type of tasks I detailed above.

Once the streams have been organized into a thread pool, some way of communicating with them in a thread safe manner needs to be devised for updating the GUI as requests come in. We should also take extra care not to clog up the buffer with requests, which means having an intimate understanding of the exchange of data going on. Taking the time to read the TDA Streaming Guide https://developer.tdameritrade.com/content/streaming-data will be helpful in testing. This can also play into the design of the callbacks/event handlers for #3

Here's a stack overflow article https://stackoverflow.com/questions/69601043/boost-beast-websocket-how-to-make-a-pending-async-read-queue-work-for-io-con I found that may help in converting the current implementation to using a thread pool, but the design for the callbacks/events still needs to be formulated.

@scawful scawful added the enhancement New feature or request label May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant