from PyQt6.QtWidgets import (QMainWindow, QWidget, QVBoxLayout, QHBoxLayout,…
- User
from PyQt6.QtWidgets import (QMainWindow, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QLineEdit, QFrame) from PyQt6.QtCore import Qt, QTimer from PyQt6.QtGui import QFont import pyqtgraph as pg import numpy as np import torch import logging from datetime import datetime import asyncio import time from typing import Dict, List
class QuantumChart(pg.PlotWidget): def init(self, title: str, y_label: str, color: str = 'c'): super().init() self.setup_chart(title, y_label, color)
def setup_chart(self, title: str, y_label: str, color: str): self.showGrid(x=True, y=True, alpha=0.2) self.setBackground('k') for axis in [self.getAxis('bottom'), self.getAxis('left')]: axis.setPen(pg.mkPen('w')) axis.setTextPen(pg.mkPen('w')) self.getAxis('bottom').setStyle(showValues=True) self.getAxis('bottom').setLabel('Time') self.getAxis('bottom').setRotation(45) font = QFont() font.setPixelSize(12) self.getAxis('bottom').setTickFont(font) self.getAxis('left').setTickFont(font) self.setLabel('left', y_label, color=color) self.setTitle(title, color='w') self.main_line = self.plot(pen=pg.mkPen(color, width=2)) self.buy_markers = pg.ScatterPlotItem(pen='g', brush='g', symbol='t', size=15) self.sell_markers = pg.ScatterPlotItem(pen='r', brush='r', symbol='t1', size=15) self.beam_line = self.plot(pen=pg.mkPen('g', width=1)) self.addItem(self.buy_markers) self.addItem(self.sell_markers) self.beam_data = [] logging.info("QuantumChart initialized successfully.")class QuantumGUI(QMainWindow): def init(self, config: Dict, trader, market_signals, scanner): super().init() self.logger = logging.getLogger(name) self.logger.info("🚀 Initializing Quantum GUI...")
self.config = config self.trader = trader self.market_signals = market_signals self.scanner = scanner self.neural_engine = scanner self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu") if torch.cuda.is_available(): self.stream = torch.cuda.Stream() self.logger.info("CUDA enabled for GUI.") self.trading_stats = {'wins': 0, 'losses': 0, 'total_pnl': 0.0, 'trades': 0} self.price_history = [] self.volume_history = [] self.time_labels = [] self.trade_markers = [] self.max_points = 100 self.last_update = 0 self.update_interval = 0.1 self.buy_btn = None self.sell_btn = None self.auto_btn = None self.size_input = None self.price_chart = None self.volume_chart = None self.balance_label = None self.status_label = None self.neural_status = None self.init_ui() self.setup_timers() self.connect_signals() if self.config['trading'].get('enabled', True): self.auto_btn.setChecked(True) asyncio.create_task(self._auto_trading_loop()) self.logger.info("✨ Quantum GUI Ready") def init_ui(self): self.setWindowTitle("⚡ Quantum Trading Interface") self.setStyleSheet(""" QMainWindow { background: black; } QLabel { color: #00ff00; font-family: 'Consolas'; font-size: 12px; padding: 2px; } QPushButton { background: #001a00; color: #00ff00; border: 1px solid #00ff00; padding: 5px; font-weight: bold; min-width: 80px; border-radius: 3px; } QPushButton:hover { background: #002200; } QLineEdit { background: #001a00; color: #00ff00; border: 1px solid #00ff00; padding: 5px; border-radius: 3px; } QFrame { border: 1px solid #003300; background: #001100; padding: 5px; border-radius: 5px; } """) central = QWidget() self.setCentralWidget(central) layout = QHBoxLayout(central) self.init_left_panel(layout) self.init_center_panel(layout) self.init_right_panel(layout) self.setMinimumSize(1200, 800) self.show() def init_left_panel(self, parent_layout): panel = QFrame() layout = QVBoxLayout(panel) # Wallet info wallet_frame = QFrame() wallet_layout = QVBoxLayout(wallet_frame) self.balance_label = QLabel("Balance: Loading...") self.balance_label.setStyleSheet("font-size: 14px; font-weight: bold;") self.wallet_label = QLabel("Wallet: " + self.trader.get_wallet_address()[:8] + "...") wallet_layout.addWidget(self.balance_label) wallet_layout.addWidget(self.wallet_label) layout.addWidget(wallet_frame) # Trading controls controls_frame = QFrame() controls_layout = QVBoxLayout(controls_frame) size_layout = QHBoxLayout() size_layout.addWidget(QLabel("Size (SOL):")) self.size_input = QLineEdit() self.size_input.setText(str(self.config['trading']['initial_size'])) size_layout.addWidget(self.size_input) controls_layout.addLayout(size_layout) button_layout = QHBoxLayout() self.buy_btn = QPushButton("BUY") self.buy_btn.setStyleSheet("background: #002200; border: 2px solid #00ff00;") self.sell_btn = QPushButton("SELL") self.sell_btn.setStyleSheet("background: #220000; border: 2px solid #ff0000;") button_layout.addWidget(self.buy_btn) button_layout.addWidget(self.sell_btn) controls_layout.addLayout(button_layout) layout.addWidget(controls_frame) self.logger.info("Trading controls initialized successfully.") # Performance metrics metrics_frame = QFrame() metrics_layout = QVBoxLayout(metrics_frame) metrics_layout.addWidget(QLabel("Performance Metrics")) self.win_rate_label = QLabel("Win Rate: 0.00%") self.pnl_label = QLabel("Total PNL: 0.00 SOL") self.trades_label = QLabel("Total Trades: 0") for label in [self.win_rate_label, self.pnl_label, self.trades_label]: metrics_layout.addWidget(label) layout.addWidget(metrics_frame) parent_layout.addWidget(panel, stretch=1) self.logger.info("Left panel initialized successfully.") def update_data(self): """Update market data display""" try: current_time = time.time() if current_time - self.last_update < self.update_interval: return if torch.cuda.is_available(): with torch.cuda.stream(self.stream): self._update_charts() else: self._update_charts() self.last_update = current_time except Exception as e: self.logger.error(f"Data update error: {e}") - Assistant