Initial release: TradeMind crypto trading bot with paper/live modes and strategy training
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
# TradeMind
|
||||
|
||||
Krypto-Tradingbot (Python) mit **Paper-/Simulationsmodus**, **Live-Trading** und **Antrainierung** der Strategie.
|
||||
|
||||
Per [Podman](https://podman.io) deploybar. Alle API-Keys werden aus der `config.yaml` oder aus Environment-Variablen gelesen.
|
||||
|
||||
## Features
|
||||
- **Paper / Simulation**: führt Käufe & Verkäufe gegen einen Candles-Feed durch, ohne echtes Geld.
|
||||
- **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.
|
||||
- **Konfiguration**: eine `config.yaml`, mehrere Exchanges in `state/weights.json` persistierbar.
|
||||
|
||||
## Installation (lokal / Dev)
|
||||
```bash
|
||||
python -m venv .venv
|
||||
.venv\Scripts\activate # Windows
|
||||
pip install -r requirements.txt
|
||||
python -m trademind --help
|
||||
```
|
||||
|
||||
## Podman (empfohlener Deploy)
|
||||
```bash
|
||||
# 1. Build
|
||||
podman build -t trademind:latest -f Podmanfile .
|
||||
|
||||
# 2. Paper-Modus (kein API-Key nötig)
|
||||
podman run --rm trademind:latest paper --config /app/config.yaml
|
||||
|
||||
# 3. Training (Strategie wird antrainiert)
|
||||
podman run --rm -v $PWD/state:/app/state trademind:latest train --config /app/config.yaml
|
||||
|
||||
# 4. Live-Trading (NUR mit echten Keys + sandbox: false)
|
||||
podman run -it --rm \
|
||||
-e BINANCE_API_KEY=... \
|
||||
-e BINANCE_API_SECRET=... \
|
||||
trademind:latest live --config /app/config.yaml
|
||||
```
|
||||
|
||||
### Mit `podman-compose` (optional)
|
||||
```bash
|
||||
pip install podman-compose # ein Mal
|
||||
podman-compose build
|
||||
podman-compose up paper # Simulationslauf
|
||||
podman-compose run --rm train # Antrainieren
|
||||
podman-compose run --rm live # Live-Zyklus
|
||||
```
|
||||
|
||||
## Konfiguration (`config.yaml`)
|
||||
```yaml
|
||||
trading:
|
||||
base_currency: BTC
|
||||
quote_currency: USDT
|
||||
initial_balance: 10000
|
||||
position_size_pct: 0.10
|
||||
fee_pct: 0.001
|
||||
slippage_pct: 0.0005
|
||||
timeframe: 1h
|
||||
candles: 500
|
||||
|
||||
strategy:
|
||||
fast_period: 12
|
||||
slow_period: 26
|
||||
rsi_overbought: 70
|
||||
rsi_oversold: 30
|
||||
atr_stop_mult: 2.5
|
||||
allow_long: true
|
||||
allow_short: false
|
||||
|
||||
training:
|
||||
generations: 15
|
||||
population: 30
|
||||
seed: 42
|
||||
state_file: state/weights.json
|
||||
|
||||
exchanges:
|
||||
binance:
|
||||
api_key: ${BINANCE_API_KEY}
|
||||
api_secret: ${BINANCE_API_SECRET}
|
||||
sandbox: true
|
||||
kraken:
|
||||
api_key: ${KRAKEN_API_KEY}
|
||||
api_secret: ${KRAKEN_API_SECRET}
|
||||
sandbox: true
|
||||
coinbase:
|
||||
api_key: ${COINBASE_API_KEY}
|
||||
api_secret: ${COINBASE_API_SECRET}
|
||||
sandbox: true
|
||||
kucoin:
|
||||
api_key: ${KUCOIN_API_KEY}
|
||||
api_secret: ${KUCOIN_API_SECRET}
|
||||
password: ${KUCOIN_PASSPHRASE}
|
||||
sandbox: true
|
||||
```
|
||||
|
||||
## CLI
|
||||
```
|
||||
trademind paper # Paper-/Simulationslauf (Echte Marktkurse, Orders nur simuliert)
|
||||
trademind live # ein Live-Zyklus (echte Orders)
|
||||
trademind train # optimiert die Strategie-Parameter & -gewichte
|
||||
trademind show # zeigt die geladene Konfiguration (Keys maskiert)
|
||||
```
|
||||
|
||||
### 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
|
||||
fällt automatisch auf generierte mock-Daten zurück.
|
||||
|
||||
```
|
||||
trademind paper --data live --exchange kraken # zwingend live (sonst Fehler)
|
||||
trademind paper --data mock # deterministische Offline-Daten
|
||||
trademind train --data live --exchange coinbase # Training auf echten Kursdaten
|
||||
```
|
||||
|
||||
## Antrainieren im Detail
|
||||
`trademind train` erzeugt eine Population randomisierter Parameter
|
||||
(`fast/slow/signal`, `rsi_*`, `atr_stop_mult`, Signalgewichte) und optimiert sie per
|
||||
Elitismus + Crossover + Mutation so, dass die gewichtete Fitness gestiegen ist:
|
||||
|
||||
```
|
||||
Fitness = 0.6 × TotalReturn + 0.3 × (Sharpe/10) − 0.1 × MaxDrawdown
|
||||
```
|
||||
|
||||
Das Ergebnis wird in `state/weights.json` gespeichert und bei `paper` / `live`
|
||||
automatisch geladen.
|
||||
|
||||
## Sicherheit / Haftung
|
||||
- Paper-/Simulationsmodus nutzt **keine** echten Order.
|
||||
- Live-Orders sind **auf eigenes Risiko**. Es gibt keine Garantie für Erträge.
|
||||
- API-Keys niemals committen.
|
||||
|
||||
## Tests
|
||||
```bash
|
||||
pip install pytest
|
||||
python -m pytest
|
||||
```
|
||||
Reference in New Issue
Block a user