Team 2
Cheng Wang NUID: 001280107
Meihu Qin NUID: 002190486
-
Our final project is a Web APP which could track those companies stocks from Yahoo Finance API
-
Our whole project contains several parts:
- FastAPI - Web API
- Streamlit - Front end prototype demo
- Docker - dockerfile
- Github CI/CD - continues integration + deploy
- Airflow - set up a daily task to update stock values
- PyTest - simple unit tests for fastaapi
- Logs - be stored in cloud MySQL and be displayed in Streamlit
- MySQL db - log, user, user_follow, company stocks tables
Prometheus + Grafana - display server status(metrics)Prometheus Alert Manager - send alert when server's metrics meets requirememts
-
If S3 credential is filaed, you can create your own AWS S3 bucket and store all required info into(In our final project, we ignore this credential file because of security issues)/credentials/json file -
Under this repo, you will see a
requirements.txtfile, it contains all Python packages that we installed on our machine. Use fllowing commands in your terminal to install all required packagescd ./FinalProject pip install requirements.txt
-
Then you will see all dependencies our peoject need will be installed!
-
api functions
Path: ./src/api_functions/
-
main.py
Path: ./src/ <!--start FastAPI unicorn server --> uvicorn main:app --reload
-
index.html/result.html
Path: ./src/
-
log
Path: ./logs/
- no log file inside because I used
.gitignoreto ignore it but you can generate one if you want - We also make an easy to generate log for you, you can create a
mysql.yamlfile undersrcfolder
credentials: host: "your_pc_ip_address 127.0.0.1 -> localhost" user: "your_username" password: "your_userpassword" database: "your_db" - no log file inside because I used
-
pytest
Path: ./src/streamlit/pages/report.html
-
requirements.txt
Path: ./src/ You need to use Python 3+ version and user pip to install all dependencies pip install requirements.txt
-
streamlit
Path: ./src/streamlit
- You need to use
streamlit run Home.pyto start our streamlit! - All
*.pyfiles intopages/folder are other pages for streamlit, you don't need to worry about
- You need to use
-
Airflow dags(only)
Path: ./src/airflow
- This is the only file we need for our daily Airflow dags task
- You can use docker to set up a airflow server and goto
127.0.0.1:8080to use your Airflow! - if you want to use our dags, you need to add a params when you use docker compose
- In your
docker-compose.ymlfile, you need to add a volume from local dag file path into docker continerairflow/dags/path
- In your
-
MySQL database (table create SQL script only)
Path: ./src/mysqlUse
uvicorn main:app --reloadto start FastAPI uvicorn servergo to :
http://127.0.0.1/8000/, this is home pageclick
docsbutton and you will jump to API documentation
- We create some simple api functions to test
- People who use our api could input some values and get some correct result to see
-
following
- You need to input your username + company abbreviation name
- We can search whether you followed this company or not
- if this company does not exist in the database, we will search it from Yahoo API
- if this company also DNE in Yahoo API, we will catch this exception and return messages
- if this company exists in Yahoo API, we will download all 10 years stock history and add you as a follower into our database record
-
save stock price
- search target company exists or not
- if exists, we will save 10 yeas stock history
- if not exists, we will return a exception message
-
stock price search by date
- You can input a custom date range for searching
- We only search it from our database if DNE, you will get a not found message
- We will return result for you xD
- You can input a custom date range for searching
-
predicted stock price
- We use airflow trained our related stock company daily(00:00:00)
- If you just follow a new company which is not in the database now, our Airflow only update it on a new day. But you can trigger it manyally and get this model you need
- For prediction, we will return a new day's close price!
-
models
- As point 4 shows, we only return a new day's close price!
-
update stock price
- We also set up a Airflow dag for updating stock price for all stock company tables daily (00:00:00)
- You also can manually trigger Airflow dag task as you want
- WE ATTEST THAT WE HAVEN’T USED ANY OTHER STUDENTS’ WORK IN OUR ASSIGNMENT AND ABIDE BY THE POLICIES LISTED IN THE STUDENT HANDBOOK
- Contribution: Cheng Wang: 50% Meihu Qin: 50%
- Cheng's work: stramlit, mysql database tables design, dockerfile, Github CI/CD,prometheus(node exporter, status exporter, alertmanager), Grafana, deploy app on cloud(VPS)
- Meihu's work: fastAPI, logs, Pytest, writing proposal, Airflow dags and setup, model train, stock finance data collected