trading_agent.runtime.trigger
¶
A reason to wake a desk and run one turn.
Typical usage example:
trigger = Trigger.now(TriggerSource.USER_MESSAGE, desk='main', text='How is the market?')
TriggerSource
¶
Bases: StrEnum
Where a trigger came from.
Trigger
dataclass
¶
One reason to run a turn.
Attributes:
| Name | Type | Description |
|---|---|---|
trigger_id |
str
|
A unique identifier, used to match events to the trigger that caused them. |
source |
TriggerSource
|
Where the trigger came from. |
desk |
str
|
The desk that should handle it. |
text |
str
|
What the desk is asked or told. |
created_at |
datetime
|
When the trigger was created, in UTC. |
attachments |
tuple[Attachment, ...]
|
The pictures and documents the user sent with a message. |
request_id |
str | None
|
The desk's question, plan or permission request this message answers, or None. |
now
classmethod
¶
Creates a trigger with a new identifier and the current time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
TriggerSource
|
Where the trigger came from. |
required |
desk
|
str
|
The desk that should handle it. |
required |
text
|
str
|
What the desk is asked or told. |
required |
attachments
|
tuple[Attachment, ...]
|
The pictures and documents sent with it. |
()
|
request_id
|
str | None
|
The request this message answers, or None. |
None
|
Returns:
| Type | Description |
|---|---|
Trigger
|
The new trigger. |
Source code in src/trading_agent/runtime/trigger.py
to_json_dictionary
¶
Converts the trigger to a dictionary that json.dumps can write.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The trigger's fields, with the time as an ISO 8601 string; attachments only when there are some. |