trading_agent.terminal.chat_transcript
¶
Groups one desk's events into chat turns, one per trigger, as the web page does.
It follows the rules of the web page's chatTurnBuilder.ts and eventSocket.ts, but it is fed one event at a time, and each call says which item changed, so a screen only redraws that item.
Typical usage example:
transcript = ChatTranscript() for event in journal_events: transcript.add(event) changed = transcript.add(live_event)
ChatTranscript
¶
The chat of one desk, built from its events.
Attributes:
| Name | Type | Description |
|---|---|---|
items |
list[ChatItem]
|
The turns and loose events, oldest first. |
Creates an empty transcript.
Source code in src/trading_agent/terminal/chat_transcript.py
add
¶
Adds one event.
An event already added, such as one read from the journal and received live too, is ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
dict[str, Any]
|
The event, with kind, desk, payload and created_at. |
required |
Returns:
| Type | Description |
|---|---|
ChatItem | None
|
The turn or loose event that changed or was added, or None when nothing shown changed. |
Source code in src/trading_agent/terminal/chat_transcript.py
turn
¶
Finds a turn by its trigger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trigger_id
|
str
|
The trigger's id. |
required |
Returns:
| Type | Description |
|---|---|
ChatTurn | None
|
The turn, or None when no such trigger was seen. |
Source code in src/trading_agent/terminal/chat_transcript.py
running_turn
¶
The turn that has started and not finished, if any.
Returns:
| Type | Description |
|---|---|
ChatTurn | None
|
The open turn, or None. |
key
¶
A key that is the same for the journal's copy and the live copy of one event; the web page's key plus the trigger id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
dict[str, Any]
|
The event. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The key. |