After seeing the devastating effects on the economy of the Covid-19 outbreak, I realized how many families were losing money in the stock market due to bad timing, and unpredictable news. For example, one of my dearest friend's family lost nearly $60,000 in Luckin Cofee Stocks, after they were exposed for falsely boosting their accounts. I decided then and there it was time to do something about this volatile market.
How I built it
I began by exploring the field of technical analysis and observing how various hedge funds used automation to gain massive profits from a concept known as High-Frequency Trading (HFT). Companies such as Citadel Securities, and Sun Trading were using this concept so why couldn't I.
My program was written in Python using the Spyder environment (Anaconda distributions). I began by using three major classes: robin_stocks (an unofficial Robinhood API that allowed me to pull real-time stock data without paying a monthly fee), the click class decorator to be able to create system access to the computer, the os module of python which allows me to run commands from the terminal which goes hand in hand with the click group created. Then after reading the documentation for the robin_stocks for a couple of days, I transitioned to learning about different Stock Market indicators. Some of these included the RSI, CCI, MACD, SMA-50, Bollinger Bands, and many more. After extensive research, I found that the RSI served well for my purposes so I decided to import another module called tulipy to be used in conjunction with the real-time stock data from robin_stocks. I then implemented various terminal "decoration " to improve my program from a UI standpoint and then used an idea outlined by J. Wilder Jr and put it into an algorithmic form. Lastly, I used another API called Alpaca so the program would know when the stock market was open, even if your timezones were changed. The RSI 30-70 algorithm was implemented and ran perfectly in real-time and made a total of $2.47 in 4 days (Starting with an initial capital of $15).
Challenges I ran into
Some challenges I ran into while implementing the program was that it was hard to initially decide which indicator to use to select when to buy and sell a stock. This is because I wanted the program to be as conservative as possible in its approach even if it reaps slow gains over time because I wanted it to be able to combat volatility. Therefore, I finally chose the RSI indicator but the tough part was finding a way to decide the stop/loss and take profit condition. Later through heavy consideration, I decided the program would not use a stop loss, but I assumed the indicator would be powerful enough to yield slow, but constant gains without it.
Accomplishments that I'm proud of
I am very proud of using the robin_stocks module and moreover for learning the stock market, I did this by reading various books and youtube videos to understand the in and outs of financial trading. I am less proud of my technical accomplishments, but I happier that if I was able to add more optimizations that a family would not have to fear losing substantial money in the market anymore.
What I learned
I learned a lot about the complex, fast-paced world of day trading and how their are various implementations of how to "read" the market. Furthermore, I learned how to use the Robinhood API to pull real-time market data without using extraneous sources or connecting to additional WebSockets which could have dramatically had an impact on the program's performance ( as speed is a key aspect of day trading). After learning the Robinhood API, I am fairly certain I could expand the scope of this project in various ways to include neural nets (RNN) to optimize the program even further as it lacks a complex aspect to compete with high-level companies.
What's next for Techincal-Market-Defense
The next step for Technical-Market-Defense would be to first learn how to slowly build a neural-network around the existing framework and then use the RSI in combination with its counterpart the MACD. Then this algorithm could be backtested on various companies, and if it works we could move further in possible using the "statistical arbitrage" strategy. If everything goes according to plan, then getting heavier funding the program could be licensed under a subscription plan to low-income families to help them during these tough times.