trading_agent.runtime.slash_commands
¶
Commands a user types to a desk, such as /status, answered by code with no model.
Typical usage example:
commands = SlashCommands(desk, 'dry_run') reply = await commands.handle('/status')
CommandHelp
dataclass
¶
One line of /help: how a command is typed and what it does.
Attributes:
| Name | Type | Description |
|---|---|---|
usage |
str
|
How the command is typed, such as "/think |
description |
str
|
What it does. |
CommandParts
dataclass
¶
The parts of the gateway some commands read, beyond the desk itself.
Attributes:
| Name | Type | Description |
|---|---|---|
tool_registry |
ToolRegistry | None
|
The desk's tools, listed by /tools, or None. |
subagent_library |
SubagentLibrary | None
|
The subagents the desk can delegate to, listed by /subagents, or None. |
journal_reader |
JournalReader | None
|
The desk's journal, read by /subagents and /review, or None. |
subagent_runner |
SubagentRunner | None
|
Runs the trade reviewer for /review, or None. |
SlashCommands
¶
The commands of one desk.
Creates the commands for a desk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk
|
DeskRuntime
|
The desk the commands act on. |
required |
mode
|
str
|
"dry_run" or "live", reported by /status. |
required |
skill_library
|
SkillLibrary | None
|
The desk's skills, each of which can be invoked as / |
None
|
parts
|
CommandParts | None
|
The tools, subagents and journal some commands read, or None when none are available. |
None
|
Source code in src/trading_agent/runtime/slash_commands.py
is_command
¶
Says whether a message is a command rather than something for the model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The message. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True when it starts with a slash. |
Source code in src/trading_agent/runtime/slash_commands.py
command_name
¶
The command word of a message, lowercased and without the @botname suffix Telegram adds in groups.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The message, such as "/usage@my_bot today". |
required |
Returns:
| Type | Description |
|---|---|
str
|
The command word, such as "/usage", or an empty string for an empty message. |
Source code in src/trading_agent/runtime/slash_commands.py
is_instant
¶
Says whether a command only reads the desk, so it can be answered at once instead of waiting for the running turn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The message. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True for the read-only commands, such as /status. |
Source code in src/trading_agent/runtime/slash_commands.py
is_background
¶
Says whether a command asks a model and runs beside the desk's turn, one at a time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The message. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True for /btw and /review. |
Source code in src/trading_agent/runtime/slash_commands.py
skill_request
¶
Turns /
Built-in commands take precedence over skills of the same name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The message, such as "/opening-range-breakout NIFTY". |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The text to send to the model, or None when the message does not name a usable skill. |
Source code in src/trading_agent/runtime/slash_commands.py
catalogue
¶
Every command and usable skill, for a client's command menu.
Returns:
| Type | Description |
|---|---|
list[dict[str, str]]
|
One entry per /help line, then one per usable skill, each with name, usage, description, kind ("command" or "skill") and runs ("at_once", "beside" or "queued"; /stop is "at_once" because it skips the queue). |
Source code in src/trading_agent/runtime/slash_commands.py
handle
async
¶
Runs one command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The message, such as "/model qwen". |
required |
Returns:
| Type | Description |
|---|---|
str
|
The reply to show the user. |