BrainDock/README.md

124 lines
3.2 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Trading Bot V0.2 — Adaptive Strategy Learning
**Production-ready Crypto Trading Bot with Live P&L Dashboard**
## Features
### ✅ Core Trading
- **Adaptive Signal Generation**: Win-rate based strategy adjustment (5 levels)
- **Risk Management**: Stop Loss (-1.8%), Take Profit (+2.8%), Daily Loss Limit (-5%)
- **Smart Position Sizing**: Dynamic investment (50-55%) based on signal confidence
- **Trailing Stop**: +1.5% entry, 0.6% trail distance
- **Cooldown Protection**: 30min pause after 3 consecutive losses
### ✅ Adaptive Learning (Option 2)
- **Hourly Strategy Evaluation**: Automatically adjusts based on win rate
- **5 Strategy Levels**:
- 🚨 Emergency (<45% WR): Strict signals, minimal trades
- Conservative (45-50%): Reduced risk
- Standard (50-60%): Default settings
- 🟢 Aggressive (60-70%): Increased signal frequency
- 🔥 Full Throttle (>70%): Maximum trading
### ✅ Monitoring & Reporting
- **Live P&L Dashboard**: Real-time portfolio value, profit/loss, holdings
- **Performance Reports**: 3-hour summaries via Telegram
- **Telegram Alerts**: Strategy changes, trade notifications
## Architecture
### Files
- `src/main_ml.py`: Core trading bot (512 lines)
- `src/web_dashboard.py`: FastAPI dashboard (650+ lines)
- `README.md`: This file
### Endpoints
- **Bot**: Runs async trading cycle (5s loop)
- **Dashboard**: http://localhost:7000 (HTML) + `/api/state` (JSON)
- **Telegram**: Real-time alerts
## Configuration
### Strategy Parameters (Adaptive)
```python
SIGNAL_THRESHOLD: 5-10%
INVESTMENT_PERCENT: 50-55%
TAKE_PROFIT_PERCENT: 1.5-3.5%
STOP_LOSS_PERCENT: 1.0-2.2%
MAX_TRADES_PER_DAY: 5-25
MAX_OPEN_POSITIONS: 1-2
```
### Risk Controls
- Daily Loss Limit: -5%
- Max 3 consecutive losses → 30min cooldown
- Min notional: $5.00 per order
- Slippage buffer: PRICE_FILTER rounding
## Usage
### Start Bot
```bash
cd src
python3 main_ml.py
```
### Start Dashboard
```bash
cd src
uvicorn web_dashboard:app --host 0.0.0.0 --port 7000
```
### View Dashboard
```
http://bot.bizmark.cloud
```
## Performance
### Current State (2026-07-07)
- **Portfolio**: $135.99 USD
- **P&L**: -$1.83 (-1.3%)
- **Open Positions**: 1 (XRP 6.7 @ $1.15)
- **Status**: 🟢 LIVE
### Historical
- Total Trades: 10+
- Win Rate: 45-55% (adaptive mode active)
- Largest Win: +2.8% (TP hit)
- Largest Loss: -1.8% (SL hit)
## Version History
### V0.2 (Current) — 2026-07-07
- ✅ Adaptive strategy learning (Option 2)
- ✅ Live P&L dashboard integration
- ✅ 10s refresh rate (optimized)
- ✅ Hourly strategy evaluation
- ✅ Code cleanup (removed V5/V10 labels)
### V0.1 (Previous)
- Static strategy (7.5% signal, 50% investment)
- Basic P&L cart add reporting
## Troubleshooting
### Dashboard shows stale P&L?
- Check `/api/state` endpoint returns new data
- Verify bot is running (`systemctl status trading-bot`)
- Refresh page (clears 10s cache)
### Bot not trading?
- Check daily loss limit (-5% limit may be hit)
- Verify Binance API key has trading permission
- Check MIN_NOTIONAL ($5.00 minimum per order)
### Strategy not adapting?
- Need minimum 5 trades to trigger adaptation
- Strategy updates every hour (check logs)
- Win rate must be >5% points away to trigger new mode
## License
All trades at your own risk. Crypto is volatile.