Date: April 2020, Senior year of high school
I took a risk, and decided to try my hand at the stock market. I could not have started at a worse time, as only two weeks after I invested, the corona virus pandemic hit the markets, and I lost half of my initial investment. I figured I was not the best financial advisor, not from a long shot. So, I decided I would take a different approach. I created a stock trading bot[ to do the work for me.
At the moment, the bot is what I would call dumb. It will only trade based on the now. If a stock I own jumps in value, the bot will sell. If it falls in value, it will sell.Â
In the future, I would like to make the bot smart, by integrating machine learning. I can essentially train my computer based on a history of stock data, to perform based on patterns and trends, instead of current prices.
This is a large project (for me), and incorporates a MySQL database to store the stocks that I own and how much cash I have available in my account. It then uses RobotJs to manually log into my stock account, and click all of the buttons on the stock profile, enter the stock name, enter the number of shares to sell or buy, and then sell or buy stocks. I would eventually like to use an API, but I found this easy enough to start with, although it is significantly more unreliable.
Here are some screenshots of the code.
Here is the code that gets the stock price. I am proud of this, and would like to upload it to NPM eventually.
This was a lot of fun to make. If you have any good trading strategies, I would love to hear them!
Update: the idea of trading stocks like this has some fundamental flaws. While this was fun to make, it was not practical, and is not being used. I wouldn't recommend this seriously to anyone else.