FastAPI Backend für Trend Analysis
ID: REQ-TA-015 · Service: trend-analysis · Status: 🟢 aktiv · Use Case: UC-TA-003, UC-TA-004, UC-TA-005, UC-TA-006, UC-TA-007, UC-TA-008, UC-TA-009, UC-TA-010, UC-TA-011, UC-TA-013, UC-TA-014
Das FastAPI Backend (eigener Container trend-analysis/, analog zu trading-data-layer) stellt alle Endpunkte für den Trend Analysis Service bereit. Es liest ausschließlich lesend aus market_data.forex_ohlcv (PostgreSQL, bestehende Instanz, keine eigenen Tabellen/Migrationen). Die Datenquelle speichert nur 15-Minuten-Kerzen — 1h/4h/Daily werden vom Backend zur Abfragezeit per pandas-Resampling aggregiert (leere Buckets ohne Rohdaten werden verworfen statt als Flat-Kerzen dargestellt). Indikatoren via pandas-ta folgen in einer zweiten Implementierungsphase.
Tech Stack
| Feld | Wert |
|---|---|
| Framework | FastAPI |
| Language | Python 3.11+ |
| Data Processing | pandas (Resampling, Heikin-Ashi) |
| Indicator Library | pandas-ta (geplant für Phase 2, noch nicht implementiert) |
| Datenbank | PostgreSQL (bestehende Instanz, schema market_data, rein lesend) |
| Containerization | Docker |
Endpoints
Implementiert
- GET /health
Eintrag 2
| Feld | Wert |
|---|---|
| Get /Api/V1/Ohlcv (Params | pair, timeframe, limit, to) |
Eintrag 3
| Feld | Wert |
|---|---|
| Get /Api/V1/Heikin-Ashi (Params | pair, timeframe, limit, to) |
Eintrag 4
| Feld | Wert |
|---|---|
| Get /Api/V1/Ohlcv/Latest (Params | pair, timeframe) |
Geplant (Phase 2)
- GET /api/v1/indicators/ema
- GET /api/v1/indicators/rsi
- GET /api/v1/indicators/macd
- GET /api/v1/indicators/bbands
- GET /api/v1/indicators/supertrend
- GET /api/v1/indicators/squeeze
- GET /api/v1/indicators/force-index
Performance
| Feld | Wert |
|---|---|
| Caching | kein Caching in Phase 1 (Datenmenge auf dem Pi unkritisch); Redis/In-Memory-Cache optional für Phase 2 falls nötig |
| Max Response Time | 2 Sekunden |
Docker
Image: python:3.11-slim
Port: 8002
Traefik Route: PathPrefix(/trend-analysis), strip-prefix Middleware
Env Vars
- MARKET_DATA_DATABASE_URL
Abnahmekriterien
- [ ] Alle implementierten Endpunkte antworten in unter 2 Sekunden
- [ ] CORS ist für das Frontend konfiguriert
- [ ] Health-Check Endpunkt gibt Datenbankstatus zurück
- [ ] Ungültiges Währungspaar oder Zeitrahmen liefert HTTP 400 mit JSON-Fehlerdetail
- [ ] API Dokumentation via Swagger unter /docs erreichbar
Changelog
Eintrag 1
Version: 1.0
Changes: Initiale Version