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

Implementation of Limit Orders #89

Open
dylan-mcdougall opened this issue Nov 12, 2023 · 0 comments
Open

Implementation of Limit Orders #89

dylan-mcdougall opened this issue Nov 12, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@dylan-mcdougall
Copy link
Owner

dylan-mcdougall commented Nov 12, 2023

Context and Resources

The ability to implement any different order that isn't a market order will require a bit of refactoring of the backend. The best way to go about implementing this would be to incorporate WebSockets so that you can stream and update the stock data in real time in order to implement code that fires when stock prices reach the specified threshold..

Here are 2 potential solutions for implementing WebSockets in Flask backend:

https://flask-socketio.readthedocs.io/en/latest/ < My recommendation as the docs are more robust and the github is updated much more recently

https://github.com/kennethreitz/flask-sockets

After implementing WebSockets, AlpacaAPI has support for wss streams that you can then use to regularly update the stock data from the market. Here is their documentation for implementing WebSockets for stock data. https://docs.alpaca.markets/docs/real-time-stock-pricing-data

Considerations and Pitfalls:

The intent of limit orders is that a user can walk away after placing the order with the peace of mind that if the stock price ever hits that specified limit (within a specified time frame, 24 hours, 30 days, 90 days, etc.), the trade will always go through. Due to the nature of our application's hosting via Render, we will need to specify somewhere for the user to see exactly what time frame our app is live and display that time frame as being the only option for when limit orders will execute.

image

As Alpaca APIs free tier only offers up to 30 symbols being subscribed to via WebSockets, we'll need to be a little creative in how we implement the logic for this. Luckily, as this is just a portfolio project and it's unlikely that we will truly need more than 30 symbols, we can most likely start and breakoff connections depending on whether or not there is a limit order slated for that symbol.

@dylan-mcdougall dylan-mcdougall added the enhancement New feature or request label Nov 12, 2023
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