feat: refresh Tencent quotes from GUI
This commit is contained in:
@@ -159,7 +159,7 @@ class MainWindow(QMainWindow):
|
||||
def _create_toolbar(self) -> QHBoxLayout:
|
||||
layout = QHBoxLayout()
|
||||
buttons = [
|
||||
("刷新", self.refresh_all),
|
||||
("刷新行情", self._refresh_quotes),
|
||||
("账户设置", self._edit_account),
|
||||
("添加标的", self._add_instrument),
|
||||
("录入成交", self._add_trade),
|
||||
@@ -187,6 +187,14 @@ class MainWindow(QMainWindow):
|
||||
self._fill_holdings_table()
|
||||
self._refresh_details()
|
||||
|
||||
def _refresh_quotes(self) -> None:
|
||||
try:
|
||||
self.service.refresh_quotes()
|
||||
except Exception as exc:
|
||||
QMessageBox.warning(self, "行情刷新失败", str(exc))
|
||||
return
|
||||
self.refresh_all()
|
||||
|
||||
def _fill_holdings_table(self) -> None:
|
||||
self.holdings_table.setRowCount(len(self._positions))
|
||||
for row, position in enumerate(self._positions):
|
||||
|
||||
@@ -14,7 +14,7 @@ def test_formatters_render_money_percent_and_empty_values():
|
||||
def test_main_window_can_be_constructed_offscreen(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("QT_QPA_PLATFORM", "offscreen")
|
||||
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from PySide6.QtWidgets import QApplication, QPushButton
|
||||
|
||||
from grid_trading.services.trading_service import TradingService
|
||||
from grid_trading.ui.main_window import MainWindow
|
||||
@@ -25,6 +25,7 @@ def test_main_window_can_be_constructed_offscreen(tmp_path, monkeypatch):
|
||||
|
||||
assert window.windowTitle() == "Grid Trading Manager"
|
||||
assert window.holdings_table.columnCount() > 0
|
||||
assert any(button.text() == "刷新行情" for button in window.findChildren(QPushButton))
|
||||
|
||||
window.close()
|
||||
service.close()
|
||||
|
||||
Reference in New Issue
Block a user