Global Beverage Corporation Exchange API
This is a FastAPI-based stock trading API that allows users to manage stocks, execute trades, and compute financial metrics like P/E ratio, Dividend Yield, Volume Weighted Stock Price (VWSP), and the GBCE All Share Index.
- Stock Management: Create and fetch stock details.
- Trade Management: Record buy/sell trades.
- Financial Calculations:
- P/E Ratio
- Dividend Yield
- Volume Weighted Stock Price
- GBCE All Share Index
Clone the Repository**
git clone https://github.com/dpksrmwork/gbce.git
cd gbce
python -m venv .venv
source .venv/bin/activate # On Windows use: venv\Scripts\activate
pip install -r app/requirements.txt
uvicorn app.src.main:app --host 0.0.0.0 --port 8080 --reload
Method | Endpoint | Description |
---|---|---|
POST |
/stocks/ |
Create a new stock |
GET |
/stocks/all_share_index |
Compute GBCE All Share Index |
Method | Endpoint | Description |
---|---|---|
POST |
/trades/ |
Record a new trade |
Method | Endpoint | Description |
---|---|---|
POST |
/stocks/pe_ratio/ |
Compute P/E Ratio |
POST |
/stocks/dividend_yield/ |
Compute Dividend Yield |
GET |
/stocks/vwsp/ |
Compute VWSP for a stock |
curl -X POST "http://localhost:8080/stocks/" \
-H "Content-Type: application/json" \
-d '{
"symbol": "AAPL",
"stock_type": "Common",
"last_dividend": 5,
"par_value": 100
}'
curl -X POST "http://localhost:8080/trades/" \
-H "Content-Type: application/json" \
-d '{
"stock_symbol": "AAPL",
"quantity": 10,
"trade_type": "buy",
"price": 150
}'
curl -X POST "http://localhost:8080/stocks/vwsp/" \
-H "Content-Type: application/json" \
-d '{"symbol": "AAPL"}'
After running the server, access Swagger UI:
- Swagger UI: http://localhost:8080/docs
- ReDoc: http://localhost:8080/redoc