Skip to content

Commit fb0cbc4

Browse files
author
fvetter
committed
🔧 Major project cleanup and documentation update
🗑️ Cleanup: - Remove config.json.example (replaced by config.template.json) - Remove duplicate/outdated installation scripts - Consolidate installation with setup.sh 📚 Documentation: - Complete README.md overhaul with critical fixes documentation - Added v1.2.3, v1.2.4 critical versions history - Complete email system documentation with Gmail setup guide - Enhanced troubleshooting and verification commands - Added daily/weekly maintenance routines 🔧 Installation: - Consolidated setup.sh with interactive menu - Removed confusing duplicate setup scripts - Enhanced error handling and user guidance - Support for different installation types 📊 Critical Information Added: - v1.2.4 multi-fill order fix documentation - v1.2.3 Binance OCO API fix documentation - Email automation complete setup guide - Performance verification commands ✨ User Experience: - Clear upgrade path for critical versions - Step-by-step configuration guides - Comprehensive troubleshooting solutions - Complete feature documentation 🎯 Project now has clean structure and complete documentation
1 parent 05db08d commit fb0cbc4

File tree

6 files changed

+441
-242
lines changed

6 files changed

+441
-242
lines changed

README.md

Lines changed: 216 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ Bot de trading automatisé pour Binance optimisé pour Raspberry Pi avec gestion
88
enhanced_trading_bot/
99
├── 🤖 run_bot.py # Script principal du bot
1010
├── 🔧 config/ # Configuration
11-
│ └── config.json # Paramètres trading et API
11+
│ ├── config.json # Paramètres trading et API
12+
│ ├── config.template.json # Template de configuration
13+
│ └── email_config.json # Configuration email (optionnel)
1214
├── 🧠 src/ # Code source
1315
│ ├── bot.py # Bot principal
1416
│ ├── trading_engine.py # Moteur de trading
@@ -23,39 +25,47 @@ enhanced_trading_bot/
2325
│ ├── cleanup_db.py # Nettoyage base de données
2426
│ ├── db_query.py # Explorateur base de données
2527
│ ├── performance_stats.py # Analyseur de performance
28+
│ ├── email_sender.py # Système d'envoi email
2629
│ ├── monitor.sh # Monitoring et rapports
27-
│ └── run_wrapper.sh # Wrapper d'exécution cron
30+
│ ├── run_wrapper.sh # Wrapper d'exécution cron
31+
│ └── setup.sh # Script d'installation
2832
└── 🐍 venv/ # Environnement virtuel Python
2933
```
3034

3135
---
3236

3337
## 🚀 Installation et Configuration
3438

35-
### 1. **Prérequis**
39+
### **Installation automatique (recommandée)**
3640

3741
```bash
38-
# Système à jour
39-
sudo apt update && sudo apt upgrade -y
42+
# Cloner le repository
43+
git clone https://github.com/up2dev/enhanced-trading-bot.git
44+
cd enhanced-trading-bot
4045

41-
# Dépendances Python
42-
sudo apt install python3-full python3-pip python3-venv -y
46+
# Installation interactive
47+
chmod +x setup.sh
48+
./setup.sh
4349
```
4450

45-
### 2. **Configuration**
51+
### **Installation manuelle**
4652

4753
```bash
48-
# Aller dans le répertoire
49-
cd /home/yotsi/enhanced_trading_bot
54+
# Prérequis système
55+
sudo apt update && sudo apt upgrade -y
56+
sudo apt install python3-full python3-pip python3-venv git sqlite3 -y
5057

51-
# Activer l'environnement virtuel
58+
# Environnement Python
59+
python3 -m venv venv
5260
source venv/bin/activate
53-
54-
# Vérifier les dépendances
5561
pip install -r requirements.txt
62+
63+
# Configuration
64+
cp config/config.template.json config/config.json
65+
# Éditez config/config.json avec vos clés API
5666
```
5767

58-
### 3. **Configuration Binance**
68+
### **Configuration Binance**
5969

6070
Éditez `config/config.json` avec vos clés API et configurez les permissions sur Binance :
6171

@@ -65,6 +75,39 @@ pip install -r requirements.txt
6575

6676
---
6777

78+
## 🚨 Versions Critiques et Corrections
79+
80+
### **⚠️ Mises à jour critiques récentes**
81+
82+
| Version | Type | Description | Action Requise |
83+
|---------|------|-------------|----------------|
84+
| **v1.2.4** | 🚨 **CRITIQUE** | Correction multi-fill orders | **OBLIGATOIRE** |
85+
| **v1.2.3** | 🔧 Important | Correction API Binance OCO | Recommandée |
86+
| **v1.2.2** | 📊 Mineur | Correction statistiques email | Optionnelle |
87+
88+
#### **🔥 v1.2.4 - Correction Multi-fill Orders (CRITIQUE)**
89+
90+
**Problème résolu :** Les ordres d'achat exécutés en plusieurs fills n'enregistraient que le premier fill (5-15% de la quantité réelle).
91+
92+
**Impact :**
93+
-**AVANT** : Achat 50 USDC → Enregistré 0.031 SOL → OCO sur 5%
94+
-**APRÈS** : Achat 50 USDC → Enregistré 0.619 SOL → OCO sur 100%
95+
96+
**Vérification après mise à jour :**
97+
```bash
98+
# Vos logs doivent maintenant montrer :
99+
📊 Ordre exécuté en 8 fill(s):
100+
✅ RÉCAPITULATIF: 8 fills = 0.61900000 SOL (quantité complète)
101+
```
102+
103+
#### **🔧 v1.2.3 - Correction API Binance**
104+
105+
**Problème résolu :** Erreur API `-1104` sur les ordres OCO (trop de paramètres envoyés).
106+
107+
**Vérification :** Plus d'erreurs `-1104` dans les logs.
108+
109+
---
110+
68111
## 🎮 Utilisation des Scripts
69112

70113
### 🤖 **Bot Principal** (`run_bot.py`)
@@ -211,6 +254,118 @@ python3 email_sender.py --test
211254

212255
# Éditer la configuration avec vos paramètres
213256
nano config/email_config.json
257+
```
258+
259+
#### **Paramètres Gmail :**
260+
261+
1. **Activer l'authentification à 2 facteurs** sur votre compte Google
262+
2. **Générer un mot de passe d'application** :
263+
- Google Account → Sécurité → Mots de passe des applications
264+
- Choisir "Mail" + nom de votre appareil
265+
- Copier le mot de passe généré (16 caractères)
266+
3. **Utiliser ce mot de passe** dans `config/email_config.json`
267+
268+
#### **Configuration type :**
269+
270+
```json
271+
{
272+
"smtp": {
273+
"server": "smtp.gmail.com",
274+
"port": 587,
275+
"username": "votre-email@gmail.com",
276+
"password": "abcd efgh ijkl mnop",
277+
"use_tls": true
278+
},
279+
"recipients": {
280+
"daily": ["admin@exemple.com"],
281+
"weekly": ["admin@exemple.com", "manager@exemple.com"]
282+
},
283+
"settings": {
284+
"send_daily": true,
285+
"send_weekly": true,
286+
"attach_performance": true
287+
}
288+
}
289+
```
290+
291+
#### **Commandes disponibles :**
292+
293+
```bash
294+
# Test de configuration (obligatoire avant utilisation)
295+
python3 email_sender.py --test
296+
297+
# Envoi manuel rapport quotidien
298+
python3 email_sender.py --daily
299+
300+
# Envoi manuel rapport hebdomadaire
301+
python3 email_sender.py --weekly
302+
```
303+
304+
#### **Automatisation cron :**
305+
306+
```bash
307+
# Éditer le cron
308+
crontab -e
309+
310+
# Ajouter ces lignes :
311+
# Bot toutes les 10 minutes
312+
*/10 * * * * /home/yotsi/enhanced_trading_bot/run_wrapper.sh
313+
314+
# Rapport quotidien à 18h (avec email)
315+
0 18 * * * cd /home/yotsi/enhanced_trading_bot && ./monitor.sh && python3 email_sender.py --daily
316+
317+
# Rapport performance hebdomadaire le dimanche à 19h
318+
0 19 * * 0 cd /home/yotsi/enhanced_trading_bot && python3 email_sender.py --weekly
319+
```
320+
321+
#### **Sécurité :**
322+
323+
-**Configuration exclue** du repository Git
324+
-**Templates fournis** pour nouveaux utilisateurs
325+
-**Support mots de passe d'application** Gmail
326+
-**Validation automatique** des paramètres
327+
328+
#### **Fournisseurs supportés :**
329+
330+
| Fournisseur | Serveur SMTP | Port | Notes |
331+
|------------|--------------|------|-------|
332+
| **Gmail** | `smtp.gmail.com` | 587 | Mot de passe d'app requis |
333+
| **Outlook** | `smtp-mail.outlook.com` | 587 | Compatible Hotmail |
334+
| **Yahoo** | `smtp.mail.yahoo.com` | 587 | Mot de passe d'app requis |
335+
336+
#### **Contenu des emails :**
337+
338+
**📧 Rapport quotidien :**
339+
- Statistiques d'exécution du bot
340+
- Nombre de transactions du jour
341+
- Ordres OCO actifs
342+
- Performance système Raspberry Pi
343+
- Erreurs récentes
344+
345+
**📈 Rapport hebdomadaire :**
346+
- Analyse de performance (7 jours)
347+
- ROI et profits/pertes
348+
- Volume de trading
349+
- Rapport de monitoring complet
350+
- Fichier de performance en pièce jointe
351+
352+
#### **Dépannage :**
353+
354+
```bash
355+
# Vérifier les logs email
356+
tail -20 logs/email.log
357+
358+
# Test avec debug
359+
python3 email_sender.py --test
360+
361+
# Vérifier la configuration
362+
cat config/email_config.json
363+
```
364+
365+
**Erreurs communes :**
366+
- **"Authentication failed"** : Vérifiez le mot de passe d'application
367+
- **"Connection refused"** : Vérifiez server/port SMTP
368+
- **"Configuration invalide"** : Éditez `config/email_config.json`
214369

215370
---
216371

@@ -268,6 +423,7 @@ sudo tail /var/log/syslog | grep CRON
268423
"testnet": false
269424
},
270425
"trading": {
426+
"base_currency": "USDC",
271427
"max_trade_amount": 165,
272428
"max_trade_ratio": 0.25,
273429
"min_balance_reserve": 21,
@@ -281,7 +437,11 @@ sudo tail /var/log/syslog | grep CRON
281437
"cooldown_minutes": 20,
282438
"max_daily_trades": 150,
283439
"stop_loss_percentage": -8.0,
284-
"use_oco_orders": true
440+
"use_oco_orders": true,
441+
"stop_limit_buffer": 0.001
442+
},
443+
"advanced_strategy": {
444+
"future_transfer_enabled": true
285445
},
286446
"cryptos": {
287447
"BTC": {
@@ -308,6 +468,7 @@ sudo tail /var/log/syslog | grep CRON
308468
- `logs/trading_bot.log` : Activité principale du bot
309469
- `logs/cron.log` : Exécutions automatiques
310470
- `logs/errors.log` : Erreurs système
471+
- `logs/email.log` : Activité email
311472
- `logs/daily_report.log` : Rapport quotidien
312473

313474
### **Consultation des logs :**
@@ -336,10 +497,13 @@ grep "STATISTIQUES" logs/daily_report.log
336497
# Sauvegardes
337498
cp db/trading.db db/backup_$(date +%Y%m%d).db
338499

500+
# Mise à jour du code
501+
git pull origin main
502+
339503
# Nettoyage périodique
340504
python3 cleanup_db.py --days-keep 30
341505

342-
# Rotation des logs (automatique mais peut être forcée)
506+
# Rotation des logs (automatique)
343507
find logs/ -name "*.log" -mtime +15 -delete
344508
```
345509

@@ -398,13 +562,24 @@ python3 db_query.py --stats
398562
python3 cleanup_db.py --clear-orphaned
399563
```
400564

565+
### **Problèmes multi-fill (v1.2.4+) :**
566+
567+
```bash
568+
# Vérifier que les fills sont bien traités
569+
grep "Ordre exécuté en.*fill" logs/trading_bot.log
570+
571+
# Doit montrer des lignes comme :
572+
# "📊 Ordre exécuté en 8 fill(s):"
573+
# "✅ RÉCAPITULATIF: 8 fills = 0.61900000 SOL"
574+
```
575+
401576
---
402577

403578
## 📞 Support et Développement
404579

405580
### **Structure du code :**
406-
- `src/bot.py` : Logique principale
407-
- `src/trading_engine.py` : Décisions de trading (RSI, OCO)
581+
- `src/bot.py` : Logique principale + gestion position totale
582+
- `src/trading_engine.py` : Décisions trading + gestion multi-fill
408583
- `src/binance_client.py` : Interface API Binance
409584
- `src/database.py` : Gestion SQLite
410585
- `src/portfolio_manager.py` : Gestion allocation
@@ -423,6 +598,9 @@ python3 run_bot.py --dry-run --log-level DEBUG > debug.log 2>&1
423598

424599
# Analyser les indicateurs techniques
425600
grep "Indicateurs" logs/trading_bot.log
601+
602+
# Vérifier les fills multiples (v1.2.4+)
603+
grep "fills.*RÉCAPITULATIF" logs/trading_bot.log
426604
```
427605

428606
---
@@ -431,9 +609,12 @@ grep "Indicateurs" logs/trading_bot.log
431609

432610
-**Trading RSI automatique** avec gestion des rachats
433611
-**Ordres OCO** (profit + stop-loss) avec surveillance
612+
-**Gestion multi-fill** complète (v1.2.4+)
613+
-**Position totale** pour OCO intelligents
434614
-**Gestion d'allocation portfolio** intelligente
435615
-**Protection cooldown** et limites journalières
436616
-**Monitoring système** complet Raspberry Pi
617+
-**Rapports email** automatiques
437618
-**Statistiques de performance** détaillées
438619
-**Gestion des erreurs** robuste avec retry
439620
-**Mode simulation** complet pour tests
@@ -458,6 +639,9 @@ python3 db_query.py --interactive
458639
# 4. Vérifier les ordres OCO actifs
459640
python3 db_query.py -i
460641
# puis : show oco_orders 10
642+
643+
# 5. Vérifier les multi-fills récents (v1.2.4+)
644+
grep "RÉCAPITULATIF" logs/trading_bot.log | tail -5
461645
```
462646

463647
### **Commandes de maintenance hebdomadaire :**
@@ -471,11 +655,24 @@ python3 cleanup_db.py --days-keep 30
471655

472656
# Export rapport performance
473657
python3 performance_stats.py --export weekly_report.txt --full
658+
659+
# Mise à jour du code
660+
git pull origin main
474661
```
475662

476663
---
477664

665+
## 🔗 Liens Utiles
666+
667+
- **Repository GitHub** : [enhanced-trading-bot](https://github.com/up2dev/enhanced-trading-bot)
668+
- **Issues/Support** : [GitHub Issues](https://github.com/up2dev/enhanced-trading-bot/issues)
669+
- **Releases** : [GitHub Releases](https://github.com/up2dev/enhanced-trading-bot/releases)
670+
- **Documentation Binance API** : [Binance API](https://binance-docs.github.io/apidocs/spot/en/)
671+
672+
---
673+
478674
**🎯 Le bot est conçu pour fonctionner 24/7 sur Raspberry Pi avec une surveillance minimale !**
479675

676+
**⚠️ Assurez-vous d'utiliser la version v1.2.4+ pour un fonctionnement optimal des ordres multi-fill !**
677+
480678
Pour toute question spécifique, consultez les logs ou utilisez les outils de diagnostic intégrés.
481-
```

0 commit comments

Comments
 (0)