Developing mobile application predicting stock prices — concept
The idea of predicting stock prices using artificial intelligence is not new, however, the popularity of the thought of using machines to manage our finances keeps growing and it is pretty obvious why — who wouldn’t want to make money doing almost nothing? When the usual user thinks about the term of AI, complex neural networks with massive math formulas arise in his mind and I wanted to change it wrapping all technical stuff in the user-friendly mobile application. In this set of articles, I’m going to show you the process of developing such an application, from the very raw concept to the fully working tool allowing you to use all the strength of the AI in stock prediction right from your phone.
Concept
Starting with the concept of mobile application, why? I wanted to have the compact simple application available for everyone interested in investing in stocks, not only professional stock traders, and what is easier than just opening your phone, looking at some trends on charts to make your investments following this prediction?
What stocks to predict
It was decided to engage in predicting the price of cryptocurrencies. There are plenty of cryptocurrencies exchanges providing free-to-use API to get the latest data and so it is easier to train the AI models.
Functional requirements
Based on applications, already existed in the field of predicting stocks, and my own thoughts I have made a list of functional requirements, which I wanted to have in the MVP of my application.
- Allowing users to choose various predictive algorithms — although not a lot of users may know about the differences of AI algorithms, I wanted to give a user the opportunity to choose so that users could compare different algorithms and pick a favorite one!
- Showing users the simple prediction chart — and it's not about complex numbers in the tables, just a chart so that users could see the overall trend and the predicted prices over some period of time.
- Showing users the historical predictions — could be useful for users to understand how algorithms performed in the past and understand the overall behavior.
- Giving users the ability to interact — well, something social is needed in every application, maybe commenting on the predictions is the way?
Mock-ups
Based on the functional requirements, I decided to create mockups, presenting the vision of the application. Mockups show the core functionality I wanted to implement.
The first screen shows the list of available predictions in the system when the second shows the actual prediction, and the last but not least presents the historical predictions. You could also see the comments section on the bottom, presenting the feature of interacting with other users.
Architecture thoughts
Of course, all these predictions could be done straight on the phone — we need a lot of power to train our models, thus the application needs server-side.
I’ve chosen AWS for the purposes of the backend side of the application. The Sagemaker seemed like a good service for training the models and there are plenty of services to store data, like DynamoDB, create APIs (e.g. in API Gateway), and make interactions fast and cheap.
The things from the mobile side are pretty simple. Just make calls to the API and parse the data in the application. I decided to choose Firebase to implement the authentication in the application + store some data in free firebase storage.
I’ll share more about the application architecture in the second part!
AI part thoughts
The most interesting part is choosing the right AI model and training it. I have decided not to create my own model and test the existing models. The problem we are trying to solve predicting stock prices is called time-series regression, as we are trying to predict a future response based on the response history. From my research, I’ve designated for myself four main categories of the models used for stock prediction:
- Linear — the simplest ones, like linear regression, fast and simple, yet still could be powerful.
- Decision-tree based — e.g Random Forest or famous XGBoost.
- Neural-network-based — neural networks are everywhere, and the stock prediction field is not an exception. Here the type of networks with feedback loops, which allow the information to be stored, are used (e.g. RNN).
- Mixed — there are a lot of statistics-based models for time-series regression problems, like ARIMA or Facebook Prophet. And there are also models that combine statistics-based models with other AI models, like Neural Prophet.
Conclusion
The concept of making a mobile application predicting stock prices is pretty interesting, however, it requires knowledge in making mobile applications as well as server-side applications + understanding the AI models and all the theoretical parts in time-series regression is a must.
In the next parts, I will show you the implementation of the server-side application, I will show you what you need to know about the time-series regression problems and how to integrate all of this into a beautiful useful mobile application.
Links
Wanna talk about AI in crypto world? Contact me!