https://github.com/tholemu/drf_transactions
https://github.com/tholemu/drf_transactions
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tholemu/drf_transactions
- Owner: tholemu
- Created: 2023-07-31T05:30:38.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-01T20:20:09.000Z (almost 2 years ago)
- Last Synced: 2025-02-12T17:31:18.573Z (3 months ago)
- Language: Python
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Intro
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.
# Setup
> From within the 'drf_transactions' project folder containing 'manage.py', perform the following steps.
#### Create & Activate Python3 virtual environment
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
```#### Install Django and Django REST Framework
```
pip install django
pip install djangorestframework
```#### Initialize Database
```
python manage.py makemigrations transactions
python manage.py migrate transactions
```#### Run Development Webserver
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.
# Testing
#### Example POST
```
POST http://127.0.0.1:8000/transactions/
{
"price": "35000.00",
"quantity": ".000015",
"symbol": "btc"
}
```#### Example List all Transactions
```
GET http://127.0.0.1:8000/transactions/
```