from datetime import datetime, timedelta import random import time from dataprovider_realtime import RealTimeChart # Create a standalone chart instance chart = RealTimeChart('BTC/USDT') # Base price base_price = 65000.0 # Add 5 pairs of trades (BUY followed by SELL) for i in range(5): # Create a buy trade buy_price = base_price + random.uniform(-200, 200) buy_time = datetime.now() - timedelta(minutes=5-i) # Older to newer buy_amount = round(random.uniform(0.05, 0.5), 2) # Add the BUY trade chart.add_trade( price=buy_price, timestamp=buy_time, amount=buy_amount, pnl=None, # Set to None for buys action='BUY' ) print(f"Added BUY trade {i+1}: Price={buy_price:.2f}, Amount={buy_amount}, Time={buy_time}") # Wait a moment time.sleep(0.5) # Create a sell trade (typically at a different price) price_change = random.uniform(-100, 300) # More likely to be positive for profit sell_price = buy_price + price_change sell_time = buy_time + timedelta(minutes=random.uniform(0.5, 1.5)) # Calculate PnL pnl = (sell_price - buy_price) * buy_amount # Add the SELL trade chart.add_trade( price=sell_price, timestamp=sell_time, amount=buy_amount, # Same amount as buy pnl=pnl, action='SELL' ) print(f"Added SELL trade {i+1}: Price={sell_price:.2f}, PnL={pnl:.2f}, Time={sell_time}") # Wait a moment before the next pair time.sleep(0.5) print("\nAll trades added successfully!")