mirror of
https://github.com/Sabermrddz/QuantCore-FX.git
synced 2026-07-27 18:47:51 +00:00
layer one v3
This commit is contained in:
+60
-17
@@ -1,30 +1,35 @@
|
||||
"""
|
||||
APEX Layer 1 — Main Application Window
|
||||
APEX Professional Trading System — Main Application Window
|
||||
|
||||
Assembles all 4 tabs:
|
||||
- Tab 1: Dashboard (main signal + ranking table)
|
||||
- Tab 2: Monthly Entry (CPI + PMI input form)
|
||||
- Tab 3: History (past signals)
|
||||
- Tab 4: Settings (configuration)
|
||||
Assembles all 6 tabs:
|
||||
- Tab 1: Dashboard (Layer 1 fundamental signals)
|
||||
- Tab 2: Monthly Entry (CPI + PMI data input)
|
||||
- Tab 3: Layer 2 Monitor (real-time technical analysis)
|
||||
- Tab 4: Confluence Signals (merged Layer 1 + Layer 2)
|
||||
- Tab 5: History (past signals)
|
||||
- Tab 6: Settings (configuration)
|
||||
|
||||
Responsibilities:
|
||||
- Create QMainWindow with QTabWidget
|
||||
- Instantiate all UI tabs
|
||||
- Manage database connection
|
||||
- Run FRED API fetch in background thread (QThread)
|
||||
- Connect inter-tab signals (e.g., entry tab saves → dashboard tab refreshes)
|
||||
- Run FRED API fetch in background thread
|
||||
- Run Alpha Vantage real-time data fetching
|
||||
- Connect inter-tab signals
|
||||
- Handle window events and cleanup
|
||||
"""
|
||||
|
||||
from PyQt5.QtWidgets import QMainWindow, QTabWidget, QVBoxLayout, QWidget, QMessageBox
|
||||
from PyQt5.QtCore import Qt, QThread, pyqtSignal
|
||||
from PyQt5.QtWidgets import QMainWindow, QTabWidget, QMessageBox
|
||||
from PyQt5.QtCore import QThread, pyqtSignal
|
||||
from PyQt5.QtGui import QFont
|
||||
from typing import Dict, Optional
|
||||
import config
|
||||
from database import Database
|
||||
from fred_client import FredClient
|
||||
from layer2_technical import TechnicalAnalyzer
|
||||
from ui.dashboard_tab import DashboardTab
|
||||
from ui.entry_tab import MonthlyEntryTab
|
||||
from ui.layer2_monitor_tab import Layer2MonitorTab
|
||||
from ui.confluence_tab import ConfluenceSignalsTab
|
||||
from ui.history_tab import HistoryTab
|
||||
from ui.settings_tab import SettingsTab
|
||||
|
||||
@@ -75,7 +80,7 @@ class FredFetchWorker(QThread):
|
||||
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
"""Main application window."""
|
||||
"""Main application window — Professional hybrid trading system."""
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize main window."""
|
||||
@@ -92,13 +97,18 @@ class MainWindow(QMainWindow):
|
||||
)
|
||||
raise
|
||||
|
||||
# Initialize Layer 2 components
|
||||
self.tech_analyzer = TechnicalAnalyzer(lookback=config.Z_SCORE_LOOKBACK)
|
||||
|
||||
# UI components
|
||||
self.dashboard_tab = None
|
||||
self.entry_tab = None
|
||||
self.layer2_tab = None
|
||||
self.confluence_tab = None
|
||||
self.history_tab = None
|
||||
self.settings_tab = None
|
||||
|
||||
# Worker thread
|
||||
# Worker threads
|
||||
self.fred_worker = None
|
||||
|
||||
self._init_ui()
|
||||
@@ -113,19 +123,27 @@ class MainWindow(QMainWindow):
|
||||
# Tab widget
|
||||
tabs = QTabWidget()
|
||||
|
||||
# Tab 1: Dashboard
|
||||
# Tab 1: Dashboard (Layer 1)
|
||||
self.dashboard_tab = DashboardTab(self.db)
|
||||
tabs.addTab(self.dashboard_tab, config.TAB_NAMES["dashboard"])
|
||||
|
||||
# Tab 2: Monthly Entry
|
||||
# Tab 2: Monthly Entry (Data input)
|
||||
self.entry_tab = MonthlyEntryTab(self.db)
|
||||
tabs.addTab(self.entry_tab, config.TAB_NAMES["entry"])
|
||||
|
||||
# Tab 3: History
|
||||
# Tab 3: Layer 2 Monitor (Real-time technical)
|
||||
self.layer2_tab = Layer2MonitorTab(self.tech_analyzer)
|
||||
tabs.addTab(self.layer2_tab, config.TAB_NAMES["layer2"])
|
||||
|
||||
# Tab 4: Confluence Signals (Layer 1 + Layer 2)
|
||||
self.confluence_tab = ConfluenceSignalsTab(self.db, self.tech_analyzer)
|
||||
tabs.addTab(self.confluence_tab, config.TAB_NAMES["confluence"])
|
||||
|
||||
# Tab 5: History
|
||||
self.history_tab = HistoryTab(self.db)
|
||||
tabs.addTab(self.history_tab, config.TAB_NAMES["history"])
|
||||
|
||||
# Tab 4: Settings
|
||||
# Tab 6: Settings
|
||||
self.settings_tab = SettingsTab()
|
||||
tabs.addTab(self.settings_tab, config.TAB_NAMES["settings"])
|
||||
|
||||
@@ -144,6 +162,9 @@ class MainWindow(QMainWindow):
|
||||
# Entry tab saves data → History tab refreshes
|
||||
self.entry_tab.data_saved.connect(self.history_tab.refresh_history)
|
||||
|
||||
# Dashboard generates signal → Confluence tab receives signal
|
||||
self.dashboard_tab.signal_generated.connect(self._on_dashboard_signal)
|
||||
|
||||
# Dashboard requests FRED fetch → Start worker thread
|
||||
self.dashboard_tab.fetch_rates_requested.connect(self._fetch_rates)
|
||||
|
||||
@@ -191,6 +212,24 @@ class MainWindow(QMainWindow):
|
||||
print(f"[ERROR] {error_msg}")
|
||||
# Don't show error message to user; display gracefully in dashboard
|
||||
|
||||
def _on_dashboard_signal(self, strongest: str, weakest: str, gap: float,
|
||||
bias_matrix: dict = None):
|
||||
"""
|
||||
Handle dashboard signal generation.
|
||||
Pass to confluence tab for Layer 2 analysis.
|
||||
|
||||
Args:
|
||||
strongest: Strongest currency
|
||||
weakest: Weakest currency
|
||||
gap: Gap score
|
||||
bias_matrix: Monthly directional bias matrix from Layer 1
|
||||
"""
|
||||
if config.DEBUG:
|
||||
print(f"[Main] Signal generated: {strongest}/{weakest} gap={gap:.1f}")
|
||||
|
||||
# Update confluence tab with new Layer 1 signal + bias matrix
|
||||
self.confluence_tab.set_layer1_signal(strongest, weakest, gap, bias_matrix)
|
||||
|
||||
def closeEvent(self, event):
|
||||
"""Handle window close event."""
|
||||
try:
|
||||
@@ -199,6 +238,10 @@ class MainWindow(QMainWindow):
|
||||
self.fred_worker.quit()
|
||||
self.fred_worker.wait()
|
||||
|
||||
# Stop Layer 2 monitoring
|
||||
if self.layer2_tab:
|
||||
self.layer2_tab.closeEvent(event)
|
||||
|
||||
# Close database
|
||||
self.db.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user