i need a big favor please from PyQt6.QtWidgets import (QMainWindow, QWidget, QVBoxLayout, QHBoxLayout, 
    QLabel, QPushButton, QLineEdit, QTabWidget, QGridLayout, QFrame, 
    QTableWidget, QTableWidgetItem, QProgressBar, QScrollArea)
from PyQt6.QtCore import Qt, QTimer, pyqtSignal
from PyQt6.QtGui import QPalette, QColor, QFont
import pyqtgraph as pg
import numpy as np
from datetime import datetime
from typing import Dict, Optional, List
import logging

[Previous DarkPalette class implementation remains the same...]

class QuantumGUI(QMainWindow):
    # Signal definitions remain the same...

    def __init__(self):
        super().__init__()
        self.setWindowTitle("🌌 Quantum Trading Engine")
        self.setGeometry(100, 100, 1600, 900)
        self.setPalette(DarkPalette())
        
        # Initialize state
        self.price_history = []
        self.volume_history = []
        self.signal_history = []
        self.trades = []
        
        self._setup_ui()
        self._setup_timers()
        self._connect_signals()
        
        logging.info("🎨 Quantum GUI initialized")

    [Previous methods remain the same until _connect_signals...]

    def _connect_signals(self):
        """Connect signal handlers"""
        self.balance_updated.connect(lambda val: self.update_balance(val))
        self.price_updated.connect(lambda val: self._update_price_display(val))
        self.volume_updated.connect(lambda val: self._update_volume_display(val))
        self.trade_executed.connect(self._handle_trade)
        self.error_occurred.connect(self._handle_error)

    def _update_price_display(self, price: float):
        """Update price display"""
        self.status_labels['price'].setText(f"Price: ${price:.4f}")

    def _update_volume_display(self, volume: float):
        """Update volume display"""
        self.status_labels['volume'].setText(f"Volume: ${volume:,.2f}")

[Rest of the implementation remains the same...]     put that stuff into this file and give me the fully finish code from PyQt6.QtWidgets import (QMainWindow, QWidget, QVBoxLayout, QHBoxLayout, 
    QLabel, QPushButton, QLineEdit, QTabWidget, QGridLayout, QFrame, 
    QTableWidget, QTableWidgetItem, QProgressBar, QScrollArea)
from PyQt6.QtCore import Qt, QTimer, pyqtSignal
from PyQt6.QtGui import QPalette, QColor, QFont
import pyqtgraph as pg
import numpy as np
from datetime import datetime
from typing import Dict, Optional, List
import logging

class DarkPalette(QPalette):
    def __init__(self):
        super().__init__()
        self.setColor(QPalette.ColorRole.Window, QColor(53, 53, 53))
        self.setColor(QPalette.ColorRole.WindowText, Qt.GlobalColor.white)
        self.setColor(QPalette.ColorRole.Base, QColor(25, 25, 25))
        self.setColor(QPalette.ColorRole.AlternateBase, QColor(53, 53, 53))
        self.setColor(QPalette.ColorRole.ToolTipBase, Qt.GlobalColor.white)
        self.setColor(QPalette.ColorRole.ToolTipText, Qt.GlobalColor.white)
        self.setColor(QPalette.ColorRole.Text, Qt.GlobalColor.white)
        self.setColor(QPalette.ColorRole.Button, QColor(53, 53, 53))
        self.setColor(QPalette.ColorRole.ButtonText, Qt.GlobalColor.white)
        self.setColor(QPalette.ColorRole.BrightText, Qt.GlobalColor.red)
        self.setColor(QPalette.ColorRole.Link, QColor(42, 130, 218))
        self.setColor(QPalette.ColorRole.Highlight, QColor(42, 130, 218))
        self.setColor(QPalette.ColorRole.HighlightedText, Qt.GlobalColor.black)

class QuantumGUI(QMainWindow):
    # Signals
    balance_updated = pyqtSignal(float)
    price_updated = pyqtSignal(float)
    volume_updated = pyqtSignal(float)
    trade_executed = pyqtSignal(str)
    error_occurred = pyqtSignal(str)

    def __init__(self):
        super().__init__()
        self.setWindowTitle("🌌 Quantum Trading Engine")
        self.setGeometry(100, 100, 1600, 900)
        self.setPalette(DarkPalette())
        
        # Initialize state
        self.price_history = []
        self.volume_history = []
        self.signal_history = []
        self.trades = []
        
        self._setup_ui()
        self._setup_timers()
        self._connect_signals()
        
        logging.info("🎨 Quantum GUI initialized")

    def _setup_ui(self):
        """Setup main UI components"""
        # Create main widget and layout
        main_widget = QWidget()
        self.setCentralWidget(main_widget)
        layout = QHBoxLayout(main_widget)

        # Left panel (Trading controls & status)
        left_panel = self._create_left_panel()
        layout.addWidget(left_panel, 1)

        # Center panel (Charts & indicators)
        center_panel = self._create_center_panel()
        layout.addWidget(center_panel, 2)

        # Right panel (Order book & trades)
        right_panel = self._create_right_panel()
        layout.addWidget(right_panel, 1)

    def _create_left_panel(self) -> QWidget:
        """Create left control panel"""
        panel = QFrame()
        panel.setFrameStyle(QFrame.Shape.StyledPanel)
        layout = QVBoxLayout(panel)

        # Wallet info
        wallet_group = QFrame()
        wallet_layout = QGridLayout(wallet_group)
        self.wallet_address = QLineEdit()
        self.wallet_address.setReadOnly(True)
        self.balance_label = QLabel("Balance: 0.00 SOL")
        wallet_layout.addWidget(QLabel("Wallet:"), 0, 0)
        wallet_layout.addWidget(self.wallet_address, 0, 1)
        wallet_layout.addWidget(self.balance_label, 1, 0, 1, 2)
        layout.addWidget(wallet_group)

        # Trading controls
        controls_group = QFrame()
        controls_layout = QGridLayout(controls_group)
        
        self.token_input = QLineEdit()
        self.amount_input = QLineEdit()
        self.buy_button = QPushButton("BUY")
        self.sell_button = QPushButton("SELL")
        
        self.buy_button.setStyleSheet("background-color: #1b5e20;")
        self.sell_button.setStyleSheet("background-color: #b71c1c;")
        
        controls_layout.addWidget(QLabel("Token:"), 0, 0)
        controls_layout.addWidget(self.token_input, 0, 1)
        controls_layout.addWidget(QLabel("Amount:"), 1, 0)
        controls_layout.addWidget(self.amount_input, 1, 1)
        controls_layout.addWidget(self.buy_button, 2, 0)
        controls_layout.addWidget(self.sell_button, 2, 1)
        
        layout.addWidget(controls_group)

        # Status indicators
        status_group = QFrame()
        status_layout = QGridLayout(status_group)
        
        self.status_labels = {
            'price': QLabel("Price: $0.00"),
            'volume': QLabel("Volume: $0"),
            'trades': QLabel("Trades: 0"),
            'win_rate': QLabel("Win Rate: 0%"),
            'pnl': QLabel("PnL: $0.00")
        }
        
        for i, (key, label) in enumerate(self.status_labels.items()):
            status_layout.addWidget(label, i, 0)
        
        layout.addWidget(status_group)
        
        # Auto-trading controls
        auto_group = QFrame()
        auto_layout = QVBoxLayout(auto_group)
        
        self.auto_trade_button = QPushButton("Start Auto-Trading")
        self.auto_trade_button.setCheckable(True)
        self.stop_button = QPushButton("Emergency Stop")
        self.stop_button.setStyleSheet("background-color: #b71c1c;")
        
        auto_layout.addWidget(self.auto_trade_button)
        auto_layout.addWidget(self.stop_button)
        
        layout.addWidget(auto_group)
        
        layout.addStretch()
        return panel

    def _create_center_panel(self) -> QWidget:
        """Create center chart panel"""
        panel = QFrame()
        panel.setFrameStyle(QFrame.Shape.StyledPanel)
        layout = QVBoxLayout(panel)

        # Charts tab widget
        charts_tabs = QTabWidget()
        
        # Price chart
        self.price_chart = pg.PlotWidget()
        self.price_chart.setBackground('k')
        self.price_chart.showGrid(x=True, y=True, alpha=0.2)
        self.price_line = self.price_chart.plot(pen=pg.mkPen('c', width=2))
        charts_tabs.addTab(self.price_chart, "Price")

        # Volume chart
        self.volume_chart = pg.PlotWidget()
        self.volume_chart.setBackground('k')
        self.volume_chart.showGrid(x=True, y=True, alpha=0.2)
        self.volume_bar = pg.BarGraphItem(x=[], height=[], width=0.8, brush='b')
        self.volume_chart.addItem(self.volume_bar)
        charts_tabs.addTab(self.volume_chart, "Volume")

        # Indicators chart
        self.indicators_chart = pg.PlotWidget()
        self.indicators_chart.setBackground('k')
        self.indicators_chart.showGrid(x=True, y=True, alpha=0.2)
        self.rsi_line = self.indicators_chart.plot(pen=pg.mkPen('y', width=2))
        self.macd_line = self.indicators_chart.plot(pen=pg.mkPen('b', width=2))
        self.signal_line = self.indicators_chart.plot(pen=pg.mkPen('r', width=2))
        charts_tabs.addTab(self.indicators_chart, "Indicators")

        layout.addWidget(charts_tabs)

        # Trading signals panel
        signals_group = QFrame()
        signals_layout = QGridLayout(signals_group)
        
        self.signal_indicators = {
            'strength': QProgressBar(),
            'direction': QLabel("NEUTRAL"),
            'confidence': QProgressBar()
        }
        
        for bar in [self.signal_indicators['strength'], 
                   self.signal_indicators['confidence']]:
            bar.setMinimum(0)
            bar.setMaximum(100)
            bar.setTextVisible(True)
            bar.setFormat("%v%")
        
        signals_layout.addWidget(QLabel("Signal Strength:"), 0, 0)
        signals_layout.addWidget(self.signal_indicators['strength'], 0, 1)
        signals_layout.addWidget(QLabel("Direction:"), 1, 0)
        signals_layout.addWidget(self.signal_indicators['direction'], 1, 1)
        signals_layout.addWidget(QLabel("AI Confidence:"), 2, 0)
        signals_layout.addWidget(self.signal_indicators['confidence'], 2, 1)
        
        layout.addWidget(signals_group)
        
        return panel

    def _create_right_panel(self) -> QWidget:
        """Create right panel with positions and trades"""
        panel = QFrame()
        panel.setFrameStyle(QFrame.Shape.StyledPanel)
        layout = QVBoxLayout(panel)

        # Active positions table
        positions_group = QFrame()
        positions_layout = QVBoxLayout(positions_group)
        positions_layout.addWidget(QLabel("Active Positions"))
        
        self.positions_table = QTableWidget(0, 4)
        self.positions_table.setHorizontalHeaderLabels(
            ["Token", "Size", "Entry", "PnL"]
        )
        positions_layout.addWidget(self.positions_table)
        
        layout.addWidget(positions_group)

        # Trade history table
        trades_group = QFrame()
        trades_layout = QVBoxLayout(trades_group)
        trades_layout.addWidget(QLabel("Trade History"))
        
        self.trades_table = QTableWidget(0, 5)
        self.trades_table.setHorizontalHeaderLabels(
            ["Time", "Token", "Side", "Size", "PnL"]
        )
        trades_layout.addWidget(self.trades_table)
        
        layout.addWidget(trades_group)

        return panel

    def _setup_timers(self):
        """Setup update timers"""
        self.update_timer = QTimer()
        self.update_timer.timeout.connect(self._update_displays)
        self.update_timer.start(1000)  # 1 second updates

    def _connect_signals(self):
        """Connect signal handlers"""
        self.balance_updated.connect(self._update_balance)
        self.price_updated.connect(self._update_price)
        self.volume_updated.connect(self._update_volume)
        self.trade_executed.connect(self._handle_trade)
        self.error_occurred.connect(self._handle_error)

    def _update_displays(self):
        """Update all displays"""
        try:
            if self.price_history:
                self.price_line.setData(self.price_history)
            
            if self.volume_history:
                self.volume_bar.setOpts(
                    x=list(range(len(self.volume_history))),
                    height=self.volume_history
                )
            
            self._update_indicators()
            self._update_positions()
            self._update_trades()
            
        except Exception as e:
            logging.error(f"Display update error: {e}")

    def update_price(self, price: float, volume: float = 0):
        """Update price and volume data"""
        try:
            self.price_history.append(float(price))
            if volume > 0:
                self.volume_history.append(float(volume))
            
            if len(self.price_history) > 1000:
                self.price_history = self.price_history[-1000:]
                self.volume_history = self.volume_history[-1000:]
            
            self.price_updated.emit(price)
            if volume > 0:
                self.volume_updated.emit(volume)
                
        except Exception as e:
            logging.error(f"Price update error: {e}")

    def update_signals(self, signals: Dict):
        """Update trading signals"""
        try:
            self.signal_indicators['strength'].setValue(int(signals.get('strength', 0)))
            self.signal_indicators['direction'].setText(signals.get('direction', 'NEUTRAL'))
            self.signal_indicators['confidence'].setValue(int(signals.get('confidence', 0)))
            
            direction = signals.get('direction', 'NEUTRAL')
            self.signal_indicators['direction'].setStyleSheet(
                "color: green;" if direction == "LONG" else
                "color: red;" if direction == "SHORT" else
                "color: white;"
            )
            
        except Exception as e:
            logging.error(f"Signal update error: {e}")

    def update_metrics(self, metrics: Dict):
        """Update trading metrics"""
        try:
            if 'pnl' in metrics:
                self.status_labels['pnl'].setText(
                    f"PnL: ${metrics['pnl']:.2f}"
                )
            
            if 'total_trades' in metrics:
                self.status_labels['trades'].setText(
                    f"Trades: {metrics['total_trades']}"
                )
            
            if 'win_rate' in metrics:
                self.status_labels['win_rate'].setText(
                    f"Win Rate: {metrics['win_rate']:.1f}%"
                )
                
        except Exception as e:
            logging.error(f"Metrics update error: {e}")

    def update_positions(self, positions: Dict):
        """Update active positions"""
        try:
            self.positions_table.setRowCount(len(positions))
            
            for i, (token, pos) in enumerate(positions.items()):
                self.positions_table.setItem(i, 0, QTableWidgetItem(token))
                self.positions_table.setItem(i, 1, QTableWidgetItem(f"{pos['size']:.4f}"))
                self.positions_table.setItem(i, 2, QTableWidgetItem(f"${pos['entry_price']:.4f}"))
                
                pnl = pos.get('pnl', 0)
                pnl_item = QTableWidgetItem(f"{pnl:+.2f}%")
                pnl_item.setForeground(
                    QColor('green') if pnl > 0 else
                    QColor('red') if pnl < 0 else
                    QColor('white')
                )
                self.positions_table.setItem(i, 3, pnl_item)
                
        except Exception as e:
            logging.error(f"Positions update error: {e}")

    def add_trade(self, trade: Dict):
        """Add trade to history"""
        try:
            row = self.trades_table.rowCount()
            self.trades_table.insertRow(row)
            
            time_str = datetime.fromtimestamp(trade['timestamp']).strftime('%H:%M:%S')
            self.trades_table.setItem(row, 0, QTableWidgetItem(time_str))
            self.trades_table.setItem(row, 1, QTableWidgetItem(trade['token']))
            self.trades_table.setItem(row, 2, QTableWidgetItem(
                "BUY" if trade['direction'] > 0 else "SELL"
            ))
            self.trades_table.setItem(row, 3, QTableWidgetItem(f"{trade['size']:.4f}"))
            
            pnl_item = QTableWidgetItem(f"{trade['pnl']:+.2f}%")
            pnl_item.setForeground(
                QColor('green') if trade['pnl'] > 0 else QColor('red')
            )
            self.trades_table.setItem(row, 4, pnl_item)
            
            # Keep last 100 trades
            if self.trades_table.rowCount() > 100:
                self.trades_table.removeRow(0)
                
        except Exception as e:
            logging.error(f"Trade history update error: {e}")

    def update_wallet(self, address: str):
        """Update wallet address"""
        self.wallet_address.setText(address)

    def update_balance(self, balance: float):
        """Update wallet balance"""
        self.balance_label.setText(f"Balance: {balance:.4f} SOL")

    def _update_indicators(self):
        """Update technical indicators"""
        try:
            if len(self.price_history) > 14:
                # Calculate RSI
                price_array = np.array(self.price_history)
                changes = np.diff(price_array)
                gains = np.where(changes > 0, changes, 0)
                losses = np.where(changes < 0, -changes, 0)
                
                avg_gain = np.mean(gains[-14:])
                avg_loss = np.mean(losses[-14:])
                
                if avg_loss == 0:
                    rsi = 100
                else:
                    rs = avg_gain / avg_loss
                    rsi = 100 - (100 / (1 + rs))
                
                self.rsi_line.setData(y=[rsi] * len(self.price_history))
                
                # Calculate MACD
                ema12 = self._calculate_ema(price_array, 12)
                ema26 = self._calculate_ema(price_array, 26)
                macd = ema12 - ema26
                signal = self._calculate_ema(macd, 9)
                
                self.macd_line.setData(y=macd)
                self.signal_line.setData(y=signal)
                
        except Exception as e:
            logging.error(f"Indicator update error: {e}")

    def _calculate_ema(self, data: np.ndarray, period: int) -> np.ndarray:
        """Calculate EMA for given data and period"""
        alpha = 2 / (period + 1)
        return np.array([
            data[i] if i < period else
            data[i] * alpha + self._calculate_ema(data[:i], period)[-1] * (1 - alpha)
            for i in range(len(data))
        ])

    def show_message(self, message: str, color: str = 'white'):
        """Show status message"""
        status_bar = self.statusBar()
        status_bar.setStyleSheet(f"color: {color};")
        status_bar.showMessage(message, 5000)

    def get_trade_params(self) -> Dict:
        """Get current trade parameters"""
        return {
            'token': self.token_input.text(),
            'amount': float(self.amount_input.text() or 0)
        }

    def connect_signals(self, handlers: Dict):
        """Connect GUI signals to handlers"""
        if 'start_scalping' in handlers:
            self.auto_trade_button.clicked.connect(
                lambda: handlers['start_scalping']() 
                if self.auto_trade_button.isChecked() else 
                handlers['stop_scalping']()
            )
        
        if 'stop_scalping' in handlers:
            self.stop_button.clicked.connect(handlers['stop_scalping'])
        
        if 'buy' in handlers:
            self.buy_button.clicked.connect(handlers['buy'])
        
        if 'sell' in handlers:
            self.sell_button.clicked.connect(handlers['sell'])
        
        if 'auto_trade' in handlers:
            self.auto_trade_button.clicked.connect(handlers['auto_trade'])

    def _handle_trade(self, signature: str):
        """Handle trade execution"""
        self.show_message(f"Trade executed: {signature}", color='green')

    def _handle_error(self, error: str):
        """Handle error message"""
        self.show_message(f"Error: {error}", color='red')

    def closeEvent(self, event):
        """Handle window close event"""
        self.update_timer.stop()
        event.accept() i need u to write it all because my eye sight please provide the fulll entirety of the final iteration