trading_agent.channels.notification_formatter
¶
Turns the events worth a phone notification into short messages.
The user chooses which kinds are pushed in trading_agent.toml's [telegram] notifications list. Every message starts with the desk's name, because one chat hears from every desk.
Typical usage example:
formatter = NotificationFormatter(['fills', 'halts']) text = formatter.format(event, trigger_source)
NotificationFormatter
¶
Decides which events are pushed and how they read.
Creates the formatter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notifications
|
Sequence[str]
|
The kinds to push, from [telegram] notifications. |
required |
Source code in src/trading_agent/channels/notification_formatter.py
format
¶
Builds the notification for one event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
published_event
|
Event
|
The event. |
required |
trigger_source
|
str | None
|
For a text event, what woke the desk for that turn, or None when unknown. |
required |
trigger_text
|
str | None
|
For a text event, the trigger's text, or None when unknown. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The message, or None when this event is not pushed. |
Source code in src/trading_agent/channels/notification_formatter.py
wants_daily_summaries
¶
Says whether the day's summaries are pushed at each rollover.
Returns:
| Type | Description |
|---|---|
bool
|
True when daily_summaries is in the notifications list. |