This project contains a simple Django REST framework webserver which allows for tracking of financial trading transactions. In its simplest form, it will ingest a payload containing decimal parameters of "price", "quantity", and string parameter of "symbol", then calculate the total transaction cost and add it to a database.
The project could be enhanced with an additional parameter of "purchased timestamp", indicating when the order was originally executed.
From within the 'drf_transactions' project folder containing 'manage.py', perform the following steps.
The following commands will create a new Python3 virtual environment named 'env' and activate it. This allows for project-based isolation of your Python3 environment, ensuring a fresh installation for each project.
python3 -m venv env
source env/bin/activate
pip install django
pip install djangorestframework
python manage.py makemigrations transactions
python manage.py migrate transactions
The following command will start the Django development webserver, which listens on 0.0.0.0:8000 by default.
python manage.py runserver
This can be modified by specifying [address]:[port] following the 'runserver' parameter. For example, the following will start the webserver and listen on port 8443.
python manage.py runserver 0.0.0.0:8443
Your Transactions webserver should now be listening on 127.0.0.1:8000, unless a custom port was specified.
POST http://127.0.0.1:8000/transactions/
{
"price": "35000.00",
"quantity": ".000015",
"symbol": "btc"
}
GET http://127.0.0.1:8000/transactions/