Add configurable data providers and localize frontend UI

This commit is contained in:
2026-03-15 00:55:12 +08:00
parent 12de93aa30
commit d233a3f55d
38 changed files with 1936 additions and 1038 deletions

View File

@@ -38,6 +38,7 @@ class TerminalDashboard:
self.end_date = ""
self.tickers: List[str] = []
self.initial_cash = 100000.0
self.data_sources: Dict[str, Any] = {}
# Trading state
self.current_date = "-"
@@ -72,6 +73,7 @@ class TerminalDashboard:
end_date: str = "",
tickers: List[str] = None,
initial_cash: float = 100000.0,
data_sources: Dict[str, Any] = None,
):
"""Set configuration state"""
self.mode = mode
@@ -88,6 +90,7 @@ class TerminalDashboard:
self.end_date = end_date
self.tickers = tickers or []
self.initial_cash = initial_cash
self.data_sources = data_sources or {}
self.total_value = initial_cash
self.cash = initial_cash
@@ -114,6 +117,11 @@ class TerminalDashboard:
left.add_row(f"[bold]Mode:[/bold] {mode_str}")
left.add_row(f"[dim]Config:[/dim] {self.config_name}")
left.add_row(f"[dim]Server:[/dim] {self.host}:{self.port}")
preferred_sources = self.data_sources.get("preferred", [])
if preferred_sources:
left.add_row(
f"[dim]Data:[/dim] {' -> '.join(preferred_sources)}",
)
if self.mode == "live" and self.nyse_time:
left.add_row(f"[dim]NYSE:[/dim] {self.nyse_time[:19]}")
@@ -265,6 +273,7 @@ class TerminalDashboard:
trades: List[Dict] = None,
days_completed: int = None,
days_total: int = None,
data_sources: Dict[str, Any] = None,
):
"""Update dashboard state and refresh display"""
if date:
@@ -297,6 +306,8 @@ class TerminalDashboard:
self.holdings = holdings
if trades is not None:
self.trades = trades
if data_sources is not None:
self.data_sources = data_sources
if self.live:
self.live.update(self._build_panel())