Add REST API with dashboard and configurable port (server.host/port, TM_PORT, --port)
This commit is contained in:
@@ -9,6 +9,7 @@ Per [Podman](https://podman.io) deploybar. Alle API-Keys werden aus der `config.
|
||||
- **Live**: platziert reale Markerorders über [ccxt](https://github.com/ccxt/ccxt) (Binance, Kraken, Coinbase, KuCoin, OKX, Bybit, BitMEX …).
|
||||
- **Antrainieren** (`train`): evolutionäre Optimierung der Strategie-Parameter + Signalgewichte auf Simulationsdaten (Fitness = gewichteter Return + Sharpe − Max-Drawdown).
|
||||
- **Kernstrategie**: MACD-Cross + RSI + ATR-Stop-Loss.
|
||||
- **REST-API + Dashboard** (`serve`): Web-Dashboard + API für Status, Signals, Equity, Paper-Launch – Port frei anpassbar.
|
||||
- **Konfiguration**: eine `config.yaml`, mehrere Exchanges in `state/weights.json` persistierbar.
|
||||
|
||||
## Installation (lokal / Dev)
|
||||
@@ -44,6 +45,7 @@ podman-compose build
|
||||
podman-compose up paper # Simulationslauf
|
||||
podman-compose run --rm train # Antrainieren
|
||||
podman-compose run --rm live # Live-Zyklus
|
||||
TM_PORT=9000 podman-compose up serve # API/Dashboard auf Host-Port 9000
|
||||
```
|
||||
|
||||
## Konfiguration (`config.yaml`)
|
||||
@@ -73,6 +75,10 @@ training:
|
||||
seed: 42
|
||||
state_file: state/weights.json
|
||||
|
||||
server:
|
||||
host: 0.0.0.0
|
||||
port: 8080 # REST-API/Dashboard (trademind serve)
|
||||
|
||||
exchanges:
|
||||
binance:
|
||||
api_key: ${BINANCE_API_KEY}
|
||||
@@ -98,9 +104,30 @@ exchanges:
|
||||
trademind paper # Paper-/Simulationslauf (Echte Marktkurse, Orders nur simuliert)
|
||||
trademind live # ein Live-Zyklus (echte Orders)
|
||||
trademind train # optimiert die Strategie-Parameter & -gewichte
|
||||
trademind serve # STARTET REST-API + HTML-DASHBOARD (Port: server.port / --port)
|
||||
trademind show # zeigt die geladene Konfiguration (Keys maskiert)
|
||||
```
|
||||
|
||||
### REST-API + Dashboard (`serve`)
|
||||
```bash
|
||||
# lokal (Port frei wählbar – CLI > Env > config.yaml)
|
||||
trademind serve --port 9000 --data mock
|
||||
TM_PORT=9000 tm serve # Env-Override
|
||||
|
||||
# Podman (Host-Port über TM_PORT anpassbar)
|
||||
podman run --rm -p 9000:8080 trademind:latest serve --config /app/config.yaml
|
||||
```
|
||||
| Endpunkt | Beschreibung |
|
||||
|---|---|
|
||||
| `GET /` | HTML-Dashboard (Status-Kacheln, Equity-Chart, Signal-Tabelle) |
|
||||
| `GET /api/health` | Liveness |
|
||||
| `GET /api/status` | Konfiguration, aktives Symbol, letztes Paper-Ergebnis |
|
||||
| `GET /api/signals?limit=25` | zuletzt berechnete Signals (Score, Preis, Grund) |
|
||||
| `GET /api/equity` | Equity-Kurve des letzten Paper-Laufs |
|
||||
| `POST /api/paper` | startet einen Paper-Lauf (simuliert, keine Live-Orders) |
|
||||
|
||||
Der Server ist rein read-only bzw. simuliert – er platziert **nie** Live-Orders.
|
||||
|
||||
### Kursdatenquellen (paper & train)
|
||||
Die Standard-Modus `--data auto` nutzt **echte Marktkurse** über die öffentliche
|
||||
ccxt-API (Binance ist default) – keine API-Keys nötig. Bei Erreichbarkeitsproblemen
|
||||
@@ -131,6 +158,6 @@ automatisch geladen.
|
||||
|
||||
## Tests
|
||||
```bash
|
||||
pip install pytest
|
||||
pip install pytest httpx
|
||||
python -m pytest
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user