#!/usr/bin/env python3 """ Trading Statistics Demo Shows sample trading statistics to demonstrate what the bot tracks. """ import sys from pathlib import Path from datetime import datetime, timedelta import random # Add src directory to Python path sys.path.insert(0, str(Path(__file__).parent.parent / "src")) from src.stats import TradingStats def create_demo_stats(): """Create demo trading statistics.""" print("šŸ“Š Creating Demo Trading Statistics...\n") # Create stats instance with demo file stats = TradingStats("demo_stats.json") # Set initial balance initial_balance = 1000.0 stats.set_initial_balance(initial_balance) # Simulate some trades over 30 days current_balance = initial_balance base_time = datetime.now() - timedelta(days=30) print("šŸŽ² Simulating 30 days of trading...") # Generate sample trades symbols = ["BTC/USDC:USDC", "ETH/USDC:USDC"] for day in range(30): date = base_time + timedelta(days=day) # 70% chance of trading each day if random.random() < 0.7: # 1-3 trades per day num_trades = random.randint(1, 3) for _ in range(num_trades): symbol = random.choice(symbols) # Simulate buy trade if symbol == "BTC/USDC:USDC": price = random.uniform(45000, 55000) amount = random.uniform(0.001, 0.01) else: # ETH price = random.uniform(2800, 3200) amount = random.uniform(0.01, 0.1) trade_value = amount * price # Record buy stats.data['trades'].append({ 'timestamp': date.isoformat(), 'symbol': symbol, 'side': 'buy', 'amount': amount, 'price': price, 'value': trade_value, 'order_id': f'demo_{len(stats.data["trades"])}', 'type': 'manual', 'pnl': 0.0 }) # Sometimes sell (60% chance) if random.random() < 0.6: # Sell at slightly different price sell_price = price * random.uniform(0.98, 1.05) # -2% to +5% pnl = amount * (sell_price - price) current_balance += pnl sell_date = date + timedelta(hours=random.randint(1, 12)) stats.data['trades'].append({ 'timestamp': sell_date.isoformat(), 'symbol': symbol, 'side': 'sell', 'amount': amount, 'price': sell_price, 'value': amount * sell_price, 'order_id': f'demo_{len(stats.data["trades"])}', 'type': 'manual', 'pnl': pnl }) # Record daily balance daily_variance = random.uniform(-20, 30) # Daily balance change current_balance += daily_variance stats.data['daily_balances'].append({ 'date': date.date().isoformat(), 'balance': current_balance, 'timestamp': date.isoformat() }) # Save the demo data stats._save_stats() return stats, current_balance def main(): """Main demo function.""" print("šŸŽ® Trading Statistics Demo\n") print("This shows what your bot will track when you start trading manually.\n") # Create demo data stats, current_balance = create_demo_stats() # Display statistics print("šŸ“ˆ Sample Trading Statistics:\n") stats_message = stats.format_stats_message(current_balance) # Convert HTML to plain text for terminal display plain_message = stats_message.replace('', '').replace('', '') plain_message = plain_message.replace('', '').replace('', '') print(plain_message) print("\n" + "="*60) print("šŸŽÆ What This Means:") print("āœ… Your bot will track ALL these metrics automatically") print("šŸ“± View anytime on your phone with /stats command") print("šŸ’¾ Statistics persist between bot restarts") print("šŸ”„ Every manual trade updates your performance metrics") print("šŸ“Š Professional-grade analytics from day one") print("="*60) print(f"\nšŸ“ Demo data saved to: demo_stats.json") print("šŸ—‘ļø You can delete this file - it's just for demonstration") if __name__ == "__main__": main()