import sys import os import time from datetime import datetime # Add the project root to the path sys.path.append(os.getcwd()) # Try to access the running application's charts from train_rl_with_realtime import charts if not charts: print("No charts are running. Please start the application first.") sys.exit(1) # Get the first chart chart = charts[0] print(f"Accessing chart for {chart.symbol}") # Add some test trades print("Adding trades...") chart.add_trade(price=64500, timestamp=datetime.now(), pnl=0.5, action='BUY') print("Added BUY trade 1") time.sleep(1) chart.add_trade(price=64800, timestamp=datetime.now(), pnl=0.7, action='SELL') print("Added SELL trade 1") time.sleep(1) chart.add_trade(price=64600, timestamp=datetime.now(), pnl=0.3, action='BUY') print("Added BUY trade 2") time.sleep(1) chart.add_trade(price=64900, timestamp=datetime.now(), pnl=0.6, action='SELL') print("Added SELL trade 2") # Try to get the current trades print("\nCurrent trades:") if hasattr(chart, 'trades') and chart.trades: for i, trade in enumerate(chart.trades[-5:]): action = trade.get('action', 'UNKNOWN') price = trade.get('price', 'N/A') timestamp = trade.get('timestamp', 'N/A') pnl = trade.get('pnl', None) close_price = trade.get('close_price', 'N/A') print(f"Trade {i+1}: {action} @ {price}, Close: {close_price}, PnL: {pnl}, Time: {timestamp}") else: print("No trades found.")