This is a practice project for learning development of web application in Python after finished some Deep Learning courses with Jupyter Notebook. I am interest in investment. Vincent's blog and GitHub project about using python to build investment tool to analyze and predict stock's reasonable price based on predicted future value is a good starting point for practicd. I start to build 1st version , mainly refer to Vincent's project. ( You can go to Vincent Tatan's blog and GitHub project to get more information. )
After 1st version , I migrate web framework , redesign UI , improve performance, add technical analysis charts , try to make this tool more easy to use. ]
This application implement simplified model to predict expected stock price according to fillowing indicators :
- Annual_growth
- npf.rate(4, 0 , - 1st_year_eps , 5th_year_eps ) , npf is numpy financial package
- PE Ratio
- yearly mean stock price / EPS , and select minimum of recent 5 year
- EPS after 2 years later , Future EPS
- npf.fv( Annual_growth, 2 years , 0, 5th_year_eps)
- Future Value
- Future EPS x PR Ratio
- Present Value
- npf.pv( Dicount Rate , 2 years, 0, Future Value)
- Expected Reasonable Price Range , add on +/- margin rate
- Present Value x ( 1 +/- Margin Rate )
The real stock market is so complicate so these business rules are obviously not enough. It's only POC.
So, don't use this application for real market decision ! ! !
Some experts have already developed models and software to solve financial market challenges, like the true story introduced in this book "The Man Who Solved the Market". Though the book touch lightly on tech details, many resource around similar topic are available on Web and GitHub. I have found some links :
Lots of domain knowledge and skills are required to build similar system.
The Wall Street Journal (2021-01-18) :
Quant hedge fund tells clients that drop of 20% to 30% was partly due to increased volatility.
Wow, even the best model won't always beat the market ...
This application has not been rigorously tested and its domain rules are very simple which are hard to cover the complexity of real stock market. There may be also incorrect data introduced by some not found bugs or data sources .
- Visual Studio Code
- Python 3.8
- pipenv
- Web framework : from Dash migrate to Django
- Django Rest Framework
- Stock chart : from cufflinks.quant_figure change to HighCharts Stock
- jQuery : through ajax update information and stock chart
- pandas datareader : to get stock price history
- BeautifulSoup : parse web page
- gunicorn web server
- dj-static for static file process in gunicorn
- Web UI apply Bootstrap 4.x with responsive design
- Fontawesome : icon
- 2 Slider components :
- ootstrap-slider : https://github.com/seiyria/bootstrap-slider
- Ion.RangeSlider : http://ionden.com/a/plugins/ion.rangeSlider/index.html
- No requirement for database
- Stock price and financial data are retrieved from other web site or service in real time, if data sources are blocked or data specs are changed that will cause service error
- Stock information will be cached in memory for 12 hr after first accessed
- Demo site is deploy to Google Cloud Run, it may need a few seconds to start application if it already auto shutdown after long idle.
- It may take a few seconds to refresh stock information if it's the first access of selected stock in last 12 hours
- config/settings.py will read OS environment variable to set logger level, set 'LOGGER_LOG_LEVLE=DEBUG' will enable debug mode
- python manage.py runserver
- python manage.py collectstatic // this will copy css js image ... files to staticfiles folder
- gunicorn --bind 0.0.0.0:change_to_prefered_port config.wsgi:application
- Apply for Google Cloud Service account
- Install Google Cloud SDK for python, follow instruction on official document
- Install Google Cloud extend module for Visual Studio Code
- Use Cloud Run to deploy application in Visual Studio Code
What's new or fixed issues:
2024-01-03
- Refactor codes to follow pylint and mypy rules
- Fixed issue: Error occured when retrieve stock data from yahoo
2024-01-15
- Add Copilot usage guidelines and improve logging in investment_suggestion_view
- Refactor dashboard.js to asynchronously update charts when stock is selected.
2024-01-16
- Refactor code to prevent from invoking duplicated requests to access same stock data from outside website
2024-08-08
- Close the demo site. In an era of AI rising, the methods and tools for software development are so different. We can do better design and work more efficiency and learn more quickly through AI tools' help. This project becomes less helpful for learning reference, so does the demo site. This project's demo site is closed now to leave resource fo more effective usage.