mirror of
https://github.com/Sabermrddz/QuantCore-FX.git
synced 2026-07-27 18:47:51 +00:00
94 lines
2.4 KiB
Python
94 lines
2.4 KiB
Python
"""
|
|
APEX Layer 1 — Application Entry Point
|
|
|
|
Launches the PyQt5 application.
|
|
|
|
Usage:
|
|
python main.py
|
|
|
|
Requirements:
|
|
- Python 3.10+
|
|
- PyQt5 5.15+
|
|
- requests 2.31+
|
|
- pandas 2.0+ (optional, for data)
|
|
- python-dotenv 1.0+
|
|
|
|
Installation:
|
|
pip install PyQt5 requests python-dotenv
|
|
|
|
First run:
|
|
1. Ensure .env file exists with FRED_API_KEY set
|
|
2. Run: python main.py
|
|
3. App initializes database with schema
|
|
4. Auto-fetches rates from FRED if AUTO_FETCH_RATES_ON_STARTUP=true
|
|
5. Ready for manual CPI/PMI entry
|
|
"""
|
|
|
|
import sys
|
|
import traceback
|
|
from PyQt5.QtWidgets import QApplication, QMessageBox
|
|
from PyQt5.QtCore import Qt
|
|
import config
|
|
from main_window import MainWindow
|
|
|
|
|
|
def main():
|
|
"""Application entry point."""
|
|
try:
|
|
# Check critical configuration
|
|
if not config.FRED_API_KEY:
|
|
print("[ERROR] FRED_API_KEY not configured in .env file")
|
|
print("Please:")
|
|
print(" 1. Go to https://fred.stlouisfed.org")
|
|
print(" 2. Register and get a free API key")
|
|
print(" 3. Add to .env: FRED_API_KEY=your_key_here")
|
|
return 1
|
|
|
|
if config.DEBUG:
|
|
print(f"[Main] {config.APP_TITLE}")
|
|
print(f"[Main] Debug: ON")
|
|
print(f"[Main] Database: {config.DB_PATH}")
|
|
|
|
# Create QApplication
|
|
app = QApplication(sys.argv)
|
|
|
|
# Set application-wide stylesheet (optional)
|
|
app.setStyle('Fusion')
|
|
|
|
# Create and show main window
|
|
window = MainWindow()
|
|
window.show()
|
|
|
|
# Run application
|
|
exit_code = app.exec_()
|
|
|
|
if config.DEBUG:
|
|
print("[Main] Application closed normally")
|
|
|
|
return exit_code
|
|
|
|
except Exception as e:
|
|
# Show error dialog
|
|
print(f"[CRITICAL ERROR] {str(e)}")
|
|
traceback.print_exc()
|
|
|
|
# Try to show Qt error dialog
|
|
try:
|
|
app = QApplication.instance()
|
|
if app is None:
|
|
app = QApplication(sys.argv)
|
|
|
|
QMessageBox.critical(
|
|
None,
|
|
"Critical Error",
|
|
f"Application failed to start:\n\n{str(e)}\n\nCheck the console for details."
|
|
)
|
|
except:
|
|
pass
|
|
|
|
return 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|