This project fetch stock price data, store parsed data into local db, and provide APIs for query.
- storage: MySQL:8.0 is one of the top choices for RDBMS, it's reliable and extensible.
- web framework: Flask is a popular lightweight Python web framework, which is suitable for this assignment.
- SQL builder: SQLAlchemy 's SQL Expression Language is flexible to use.
- MySQL client for Python: PyMySQL is implemented in pure Python, it's easy to install in some system.
- object (de)serialization: marshmallow is a Python library that converts complex data types to native Python data types and vice versa, it can help reduce code duplication when serialize/deserialize objects.
- environment variable loader: python-decouple is a tool to load env vars from .env or ini file.
- HTTP library: requests to make HTTP requests.
- Clone this repo to local machine and enter project directory
>>git clone [email protected]:fakepoet/python_assignment.git && cd python_assignment
- Generate
.env
file with.env.example
and replaceALPHA_VANTAGE_API_KEY
with yours (if you don't have one, you can apply for free from here)cp .env.example .env
- Run project via docker-compose
Initial data is fetched with above command, if you want to manual update data, please run below command:
docker-compose up -d
docker exec financial-app python get_raw_data.py
- Verify status of containers
If you can see two containers with name financial-app / financial-db, then project is running properly.
docker ps -f name=financial-
- Test API
curl -X GET 'http://localhost:5000/api/financial_data'
Secret keys for local development can be stored in .env
file, as long as .env
is included in .gitignore
, it should not be included in repo history.
For safety concerns, you can also add extra protection via password management tools like 1Password, which can turn plain text into secret references
In production environment, it's better to store & use secret via secret management services like Kubernetes secret or AWS secrets manager.