123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- #!/usr/bin/env python3
- """
- Test script to demonstrate the new /performance command functionality.
- """
- def demo_performance_ranking():
- """Demo what the performance ranking will look like."""
- print("🏆 Token Performance Ranking Demo")
- print("=" * 50)
-
- # Mock token performance data (sorted by P&L)
- token_performance = {
- 'BTC': {
- 'total_pnl': 150.75,
- 'pnl_percentage': 5.2,
- 'completed_trades': 8,
- 'win_rate': 75.0
- },
- 'ETH': {
- 'total_pnl': 45.30,
- 'pnl_percentage': 3.1,
- 'completed_trades': 5,
- 'win_rate': 60.0
- },
- 'SOL': {
- 'total_pnl': -25.40,
- 'pnl_percentage': -2.8,
- 'completed_trades': 3,
- 'win_rate': 33.3
- }
- }
-
- sorted_tokens = sorted(
- token_performance.items(),
- key=lambda x: x[1]['total_pnl'],
- reverse=True
- )
-
- print("🏆 Token Performance Ranking\n")
-
- for i, (token, stats) in enumerate(sorted_tokens, 1):
- # Ranking emoji
- if i == 1:
- rank_emoji = "🥇"
- elif i == 2:
- rank_emoji = "🥈"
- elif i == 3:
- rank_emoji = "🥉"
- else:
- rank_emoji = f"#{i}"
-
- # P&L emoji
- pnl_emoji = "🟢" if stats['total_pnl'] >= 0 else "🔴"
-
- print(f"{rank_emoji} {token}")
- print(f" {pnl_emoji} P&L: ${stats['total_pnl']:,.2f} ({stats['pnl_percentage']:+.1f}%)")
- print(f" 📊 Trades: {stats['completed_trades']} | Win: {stats['win_rate']:.0f}%")
- print()
-
- # Summary
- total_pnl = sum(stats['total_pnl'] for stats in token_performance.values())
- total_trades = sum(stats['completed_trades'] for stats in token_performance.values())
- total_pnl_emoji = "🟢" if total_pnl >= 0 else "🔴"
-
- print("💼 Portfolio Summary:")
- print(f" {total_pnl_emoji} Total P&L: ${total_pnl:,.2f}")
- print(f" 📈 Tokens Traded: {len(token_performance)}")
- print(f" 🔄 Completed Trades: {total_trades}")
- print()
- print("💡 Usage: /performance BTC for detailed BTC stats")
- def demo_detailed_performance():
- """Demo what detailed token performance will look like."""
- print("\n📊 BTC Detailed Performance Demo")
- print("=" * 50)
-
- # Mock detailed BTC stats
- token_stats = {
- 'token': 'BTC',
- 'total_pnl': 150.75,
- 'pnl_percentage': 5.2,
- 'completed_volume': 2900.00,
- 'expectancy': 18.84,
- 'total_trades': 12,
- 'completed_trades': 8,
- 'buy_trades': 6,
- 'sell_trades': 6,
- 'win_rate': 75.0,
- 'profit_factor': 3.2,
- 'total_wins': 6,
- 'total_losses': 2,
- 'largest_win': 85.50,
- 'largest_loss': 32.20,
- 'avg_win': 42.15,
- 'avg_loss': 28.75,
- 'recent_trades': [
- {
- 'side': 'buy',
- 'value': 500,
- 'timestamp': '2023-12-01T10:30:00',
- 'pnl': 0
- },
- {
- 'side': 'sell',
- 'value': 500,
- 'timestamp': '2023-12-01T14:15:00',
- 'pnl': 45.20
- },
- {
- 'side': 'buy',
- 'value': 300,
- 'timestamp': '2023-12-01T16:45:00',
- 'pnl': 0
- }
- ]
- }
-
- pnl_emoji = "🟢" if token_stats['total_pnl'] >= 0 else "🔴"
-
- print(f"📊 {token_stats['token']} Detailed Performance\n")
-
- print("💰 P&L Summary:")
- print(f"• {pnl_emoji} Total P&L: ${token_stats['total_pnl']:,.2f} ({token_stats['pnl_percentage']:+.2f}%)")
- print(f"• 💵 Total Volume: ${token_stats['completed_volume']:,.2f}")
- print(f"• 📈 Expectancy: ${token_stats['expectancy']:,.2f}")
- print()
-
- print("📊 Trading Activity:")
- print(f"• Total Trades: {token_stats['total_trades']}")
- print(f"• Completed: {token_stats['completed_trades']}")
- print(f"• Buy Orders: {token_stats['buy_trades']}")
- print(f"• Sell Orders: {token_stats['sell_trades']}")
- print()
-
- print("🏆 Performance Metrics:")
- print(f"• Win Rate: {token_stats['win_rate']:.1f}%")
- print(f"• Profit Factor: {token_stats['profit_factor']:.2f}")
- print(f"• Wins: {token_stats['total_wins']} | Losses: {token_stats['total_losses']}")
- print()
-
- print("💡 Best/Worst:")
- print(f"• Largest Win: ${token_stats['largest_win']:,.2f}")
- print(f"• Largest Loss: ${token_stats['largest_loss']:,.2f}")
- print(f"• Avg Win: ${token_stats['avg_win']:,.2f}")
- print(f"• Avg Loss: ${token_stats['avg_loss']:,.2f}")
- print()
-
- print("🔄 Recent Trades:")
- for trade in token_stats['recent_trades'][-3:]:
- side_emoji = "🟢" if trade['side'] == 'buy' else "🔴"
- pnl_display = f" | P&L: ${trade['pnl']:.2f}" if trade['pnl'] != 0 else ""
- print(f"• {side_emoji} {trade['side'].upper()} ${trade['value']:,.0f} @ 12/01 10:30{pnl_display}")
- print()
- print("🔄 Use /performance to see all token rankings")
- def demo_no_data_scenarios():
- """Demo what happens when there's no trading data."""
- print("\n📭 No Data Scenarios Demo")
- print("=" * 50)
-
- print("1. No trading data at all:")
- print("📊 Token Performance\n")
- print("📭 No trading data available yet.\n")
- print("💡 Performance tracking starts after your first completed trades.")
- print("Use /long or /short to start trading!")
- print()
-
- print("2. No trading history for specific token:")
- print("📊 SOL Performance\n")
- print("📭 No trading history found for SOL.\n")
- print("💡 Start trading SOL with:")
- print("• /long SOL 100")
- print("• /short SOL 100")
- print()
- print("🔄 Use /performance to see all token rankings.")
- print()
-
- print("3. Open positions but no completed trades:")
- print("📊 ETH Performance\n")
- print("ETH has open positions but no completed trades yet\n")
- print("📈 Current Activity:")
- print("• Total Trades: 3")
- print("• Buy Orders: 2")
- print("• Sell Orders: 1")
- print("• Volume: $1,500.00")
- print()
- print("💡 Complete some trades to see P&L statistics!")
- print("🔄 Use /performance to see all token rankings.")
- if __name__ == "__main__":
- print("🚀 Performance Command Demo")
- print("=" * 60)
-
- demo_performance_ranking()
- demo_detailed_performance()
- demo_no_data_scenarios()
-
- print("\n" + "=" * 60)
- print("✅ Key Features:")
- print("• Token performance ranking (best to worst P&L)")
- print("• Detailed stats for specific tokens")
- print("• Win rate, profit factor, expectancy calculations")
- print("• Recent trade history included")
- print("• Mobile-friendly compressed and detailed views")
- print("• Handles cases with no data gracefully")
- print("• Easy navigation between ranking and details")
- print("\n💡 Usage:")
- print("• /performance - Show all token rankings")
- print("• /performance BTC - Show detailed BTC stats")
- print("• /performance ETH - Show detailed ETH stats")
|