Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available: 6.12.0
metadata
title: Investment Portfolio Tracker API
emoji: π
colorFrom: green
colorTo: blue
sdk: gradio
sdk_version: 5.46.1
app_file: app.py
pinned: false
license: mit
Investment Portfolio Tracker - Backend API
A FastAPI backend service for managing investment portfolios with Supabase database integration.
Features
- π User Authentication - JWT-based auth with Supabase
- π° Investment Management - CRUD operations for stocks and crypto
- π Portfolio Analytics - Summary calculations and performance metrics
- π Live Market Data - Real-time prices from Yahoo Finance and CoinGecko
- π‘οΈ Secure - User data isolation and input validation
API Endpoints
Authentication
POST /auth/signup- Create new user accountPOST /auth/signin- User loginPOST /auth/signout- User logout
Investments
GET /investments/- Get user's investmentsPOST /investments/- Add new investmentPUT /investments/{id}- Update investmentDELETE /investments/{id}- Delete investment
Analytics
GET /summary/- Portfolio summary (total value, P&L)
Market Data
GET /price/stock/{ticker}- Get stock priceGET /price/crypto/{symbol}- Get crypto price
Live Demo
π API Documentation: [Your HF Space URL]/docs
Tech Stack
- FastAPI - Modern Python web framework
- Supabase - Database and authentication
- Pydantic - Data validation
- yfinance - Stock market data
- CoinGecko API - Cryptocurrency data
Environment Variables
Set these in your Hugging Face Space secrets:
SUPABASE_URL=your_supabase_url
SUPABASE_KEY=your_supabase_anon_key
Usage
import requests
# Sign up
response = requests.post(f"{API_URL}/auth/signup", json={
"email": "user@example.com",
"password": "password123"
})
token = response.json()["access_token"]
# Add investment
headers = {"Authorization": f"Bearer {token}"}
requests.post(f"{API_URL}/investments/", json={
"asset_type": "Stock",
"ticker": "AAPL",
"quantity": 10,
"buy_price": 150.50,
"buy_date": "2024-01-15"
}, headers=headers)