Skip to content

Setup screen

SetupScreen

SetupScreen()

Bases: Screen[None]


              flowchart TD
              src.tradingagents.interface.tui.setup_screen.SetupScreen[SetupScreen]

              

              click src.tradingagents.interface.tui.setup_screen.SetupScreen href "" "src.tradingagents.interface.tui.setup_screen.SetupScreen"
            

Collect run parameters via a Textual form, then push :class:RunScreen.

The screen owns every form widget; values are read directly from those widgets at submit time and fed into :class:SetupParams so Pydantic does the per-field and cross-field validation.

Methods:

Name Description
compose

Build the setup form layout.

on_button_pressed

Handle the Start / Cancel button clicks.

action_start

Validate the form, then push :class:RunScreen on success.

action_cancel

Exit the app without running anything.

Source code in src/tradingagents/interface/tui/setup_screen.py
def __init__(self) -> None:
    """Initialise the screen with default values matching :func:`run_cli`."""
    super().__init__()
    self._defaults = SetupParams()

BINDINGS

BINDINGS: list[Binding] = [
    Binding("escape", "cancel", "Cancel"),
    Binding("ctrl+s", "start", "Start"),
]

compose

compose() -> ComposeResult

Build the setup form layout.

Yields:

Name Type Description
ComposeResult ComposeResult

The widgets that make up the form, including

ComposeResult

text inputs, selects, the analyst checkboxes row, and the

ComposeResult

Start / Cancel buttons.

Source code in src/tradingagents/interface/tui/setup_screen.py
def compose(self) -> ComposeResult:
    """Build the setup form layout.

    Yields:
        ComposeResult: The widgets that make up the form, including
        text inputs, selects, the analyst checkboxes row, and the
        Start / Cancel buttons.
    """
    today = datetime.date.today().strftime("%Y-%m-%d")
    with VerticalScroll(id="setup-scroll"):
        yield Static("TradingAgents - TUI", id="setup-title")
        yield Static(
            "Tab/Shift+Tab to navigate fields. Defaults match the "
            "tradingagents cli with no flags. Esc cancels, Ctrl+S starts.",
            id="setup-hint",
        )

        yield from self._text_row("ticker", "Ticker", self._defaults.ticker)
        yield from self._text_row("date", "Trade Date (YYYY-MM-DD)", today)
        yield from self._select_row(
            "llm_provider",
            "LLM Provider",
            list(get_args(LLMProvider)),
            self._defaults.llm_provider,
        )
        yield from self._text_row(
            "deep_think_llm", "Deep-Thinking LLM", self._defaults.deep_think_llm
        )
        yield from self._text_row(
            "quick_think_llm", "Quick-Thinking LLM", self._defaults.quick_think_llm
        )
        yield from self._select_row(
            "reasoning_effort",
            "Reasoning Effort",
            list(get_args(ReasoningEffort)),
            self._defaults.reasoning_effort,
        )
        yield from self._select_row(
            "response_language",
            "Response Language",
            list(get_args(ResponseLanguage)),
            self._defaults.response_language,
        )

        with Horizontal(classes="form-row"):
            yield Label("Analysts", classes="form-label")
            with Horizontal(classes="form-checkboxes", id="analyst-checkboxes"):
                for analyst in SUPPORTED_ANALYSTS:
                    yield Checkbox(analyst, value=True, id=f"analyst-{analyst}")

        yield from self._int_row(
            "max_debate_rounds",
            "Max Bull/Bear Debate Rounds",
            self._defaults.max_debate_rounds,
        )
        yield from self._int_row(
            "max_risk_discuss_rounds",
            "Max Risk-Management Debate Rounds",
            self._defaults.max_risk_discuss_rounds,
        )
        yield from self._int_row(
            "max_recur_limit", "Max Recursion Limit (>= 25)", self._defaults.max_recur_limit
        )

        with Horizontal(classes="form-row"):
            yield Label("Debug Streaming", classes="form-label")
            yield Switch(value=self._defaults.debug, id="debug")

        yield Static("", id="setup-error")

        with Horizontal(id="actions"):
            yield Button("Cancel", id="cancel")
            yield Button("Start", id="start", variant="primary")

on_button_pressed

on_button_pressed(event: Pressed) -> None

Handle the Start / Cancel button clicks.

Parameters:

Name Type Description Default

event

Pressed

The button press event.

required
Source code in src/tradingagents/interface/tui/setup_screen.py
def on_button_pressed(self, event: Button.Pressed) -> None:
    """Handle the Start / Cancel button clicks.

    Args:
        event (Button.Pressed): The button press event.
    """
    if event.button.id == "start":
        self.action_start()
    elif event.button.id == "cancel":
        self.action_cancel()

action_start

action_start() -> None

Validate the form, then push :class:RunScreen on success.

Source code in src/tradingagents/interface/tui/setup_screen.py
def action_start(self) -> None:
    """Validate the form, then push :class:`RunScreen` on success."""
    try:
        params = self._collect_params()
    except ValidationError as exc:
        self._show_error(self._format_validation_error(exc))
        return
    except ValueError as exc:
        self._show_error(str(exc))
        return
    self._show_error("")
    self.app.push_screen(RunScreen(params=params))

action_cancel

action_cancel() -> None

Exit the app without running anything.

Source code in src/tradingagents/interface/tui/setup_screen.py
def action_cancel(self) -> None:
    """Exit the app without running anything."""
    self.app.exit(None)