Trading stocks with machine learning
Abzal Seitkaziyev
Posted on May 29, 2020
Description
There are three main forms of securities trading: day trading, swing trading and long-term investment. I wanted to compare long term investment with swing trading for the same stock. For example, I believe in the product or service of some company XYZ and it shows stable growth with good potential to grow further. My question: can I get potentially higher return on investment(ROI) when I switch from long investment to swing trading, by buying low and selling high and repeat it multiple times for stock XYZ for long period. Also, will my risk change, with increasing reward?
Modeling & Results
To predict when to enter into the position, I used risk scorecard model, which based on the logistic regression. To get correct exit point, I applied trailing stop-loss. Due to the nature of the target, model picked up some local minima with order of less than 10 days, which created more false positives than I expected. However, with correct implementation of stop-loss, I minimized losses at real false positives entries.
I observed, that choosing stocks without prior screening still could be profitable, but cannot beat the long term investment return.
However, individual models were able to beat long term investment. Model works better in conjunction with balanced trading strategy.
On the example of S&P 500 index, I did backtest from 05-2017 till 05-2020. I got ROI of 1.5 using ML model compare to ROI of 1.22 when just doing long investment.
Conclusion
It is possible to get higher ROI using ML model, than just staying in the long position. Risks of loss could be controlled by proper strategy.
Future work
I would like to select initially high potential portfolio to feed my model and optimize exit strategy using resistance/support lines individually per each stock. As well, I want to explore how to get better ROI than popular trading algorithms.
Link to github repo.
Note: This is a concept check project, which I did as part of my educational goal to learn time-series in data science. This blog is not a financial advise and I am not a broker or professional investor. Stock investing is risky and can lead to loosing money. Please consult a licensed stock advisor before investing.
Posted on May 29, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 17, 2024