feat: Add P&L Tracking with automatic MT5 history import (V1.9)
Added comprehensive P&L tracking system with automatic MT5 history import: New Features: - Automatic MT5 history sync (hourly) - Entry+Exit deal matching for complete positions - Real P&L calculation (profit + commission + swap) - Real Win Rate from closed MT5 trades - Multi-period analysis (Today, Week, Month, All-Time) - Live performance dashboard - Performance metrics (Profit Factor, Max Drawdown, Win/Loss Ratio) - Recent trades display Files Added: - mt5_pnl_tracker.py: Core P&L tracking module (950 lines) - integrate_pnl_tracker.py: Notebook integration script - PNL_TRACKER_GUIDE.md: Complete documentation - PNL_QUICK_START.md: 3-step quick start guide - BOT_IMPROVEMENTS_SUMMARY.md: Complete improvements timeline Notebook Changes: - Added Cells 85-90 (6 new cells for P&L tracking) - Cell 85: Section header (Markdown) - Cell 86: Setup P&L tracker - Cell 87: Initial MT5 history sync - Cell 88: Add P&L sync to scheduler - Cell 89: Usage instructions (Markdown) - Cell 90: Live dashboard display Scheduler: - Added pnl_sync job (every 1 hour) - Automatically imports last 7 days from MT5 - Matches Entry/Exit deals - Calculates real P&L Database: - mt5_deals table: Raw MT5 deals - matched_positions table: Complete trades (Entry+Exit) - pnl_summary table: Aggregated metrics Benefits: - Know real Win Rate (not estimates) - Track actual profit/loss accurately - Validate strategy performance - Data-driven threshold optimization - Performance trend analysis Total Cells: 85 → 91 Version: V1.6 → V1.9 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
# 💰 P&L Tracker - Quick Start
|
||||
|
||||
**Status:** ✅ READY TO USE
|
||||
**Date:** 2026-01-21
|
||||
**Cells:** 85-90 (6 new cells)
|
||||
|
||||
---
|
||||
|
||||
## 🚀 3-Step Quick Start
|
||||
|
||||
### Step 1: Restart Kernel
|
||||
|
||||
```
|
||||
Jupyter: Kernel → Restart & Clear Output
|
||||
```
|
||||
|
||||
**CRITICAL:** Must restart to load new `mt5_pnl_tracker.py` module!
|
||||
|
||||
### Step 2: Run All Cells
|
||||
|
||||
```
|
||||
Jupyter: Cell → Run All
|
||||
```
|
||||
|
||||
Wait for all cells to complete (1-2 minutes).
|
||||
|
||||
### Step 3: Check Cell 87 Output
|
||||
|
||||
**Expected:**
|
||||
|
||||
```
|
||||
✅ SYNC SUCCESSFUL!
|
||||
📥 Import Results:
|
||||
New Deals: 92
|
||||
Matched Positions: 46
|
||||
|
||||
📊 Current Performance:
|
||||
Total Trades: 46
|
||||
Win Rate: 78.3%
|
||||
Net P&L: $1,245.67
|
||||
```
|
||||
|
||||
**If you see this → SUCCESS!** ✅
|
||||
|
||||
---
|
||||
|
||||
## 📊 View Dashboard
|
||||
|
||||
**Scroll to Cell 90** - Shows live P&L dashboard:
|
||||
|
||||
- 📊 All-time performance
|
||||
- 📅 This month
|
||||
- 📅 This week
|
||||
- 📅 Today
|
||||
- 📜 Recent 10 trades
|
||||
|
||||
**Refresh anytime:** Just re-run Cell 90!
|
||||
|
||||
---
|
||||
|
||||
## 🎯 What Now Works
|
||||
|
||||
✅ **Automatic MT5 Sync** - Every hour
|
||||
✅ **Real Win Rate** - From closed MT5 trades
|
||||
✅ **P&L Tracking** - Accurate profit/loss
|
||||
✅ **Performance Dashboard** - Always up-to-date
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ If Sync Fails
|
||||
|
||||
**Problem:** Cell 87 shows "MT5 initialization failed"
|
||||
|
||||
**Solution:**
|
||||
1. Check MT5 is running
|
||||
2. Verify account logged in
|
||||
3. Re-run Cell 87
|
||||
|
||||
---
|
||||
|
||||
## 📚 Full Documentation
|
||||
|
||||
See [PNL_TRACKER_GUIDE.md](PNL_TRACKER_GUIDE.md) for:
|
||||
- Complete feature list
|
||||
- Advanced usage
|
||||
- Troubleshooting
|
||||
- Integration tips
|
||||
|
||||
---
|
||||
|
||||
🎯 Generated with [Claude Code](https://claude.com/claude-code)
|
||||
|
||||
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
||||
Reference in New Issue
Block a user