中文|English
A simple python project that uses open api to crawl and transform data, store it in a database, and then provide an api interface for data query and analysis.
Python - main programming language is Python.
Flask - provides web framework.
Flask-SQL - an extension for Flask that adds support for SQLAlchemy, help binding database records to object.
MySQL - popular database server.
this project use the free api provided by AlphaVantage to query time series stock data, so you need to apply for your APIKEY on this page first.
The project uses MySQL service to store stock data, if you don't have mysql server, you need to download and install it,see:MySQL installation, if you have MySQL service, prepare the ip,port,username,password,dbname of MySQL server.
Project runs need to configure APIKEY and MySQL environment variables on the server
export DB_HOST_PORT = 'database ip and port, eg. 192.168.3.14:3306'
export DB_NAME = 'database name'
export DB_USER = 'database username'
export DB_PASSWORD = 'database user password'
export API_KEY = 'APIKEY applied in the first step'
python get_raw_data.py
The ENV variable can be used at startup to specify the environment configuration for service startup
ENV=dev python financial/app.py
Change the ENV variable in the docker-compose.yml file
docker-compose up --build
In principle, it is forbidden to store keys in any form in the code repository, so the database keys used in this project and Alpha Vantage's APIKEY need to be configured in the environment variables before the program starts. A more common practice in the industry is for companies to maintain a KMS key management system, and all keys are obtained by interacting with the KMS key management system