trading_agent.journal.trade_journal
¶
The trade journal: a permanent, append-only record of everything each desk does.
The journal listens to the event bus and writes each event as one JSON line in the desk's file for that India date, workspace/desks/<desk>/journal/YYYY-MM-DD.jsonl; events that belong to no desk go to workspace/journal/. Lines are only ever added. Secrets are masked first. The stream of individual text pieces is left out, because the final text event of the turn holds the whole reply.
Typical usage example:
journal = TradeJournal(event_bus, layout, redactor) task = asyncio.create_task(journal.run())
TradeJournal
¶
Writes every event to the desks' journal files.
Subscribes to the bus at once, so no event published after this is missed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_bus
|
EventBus
|
The bus to record. |
required |
layout
|
WorkspaceLayout
|
Where the journal files go. |
required |
redactor
|
SecretRedactor
|
Masks secrets before writing. |
required |
Source code in src/trading_agent/journal/trade_journal.py
run
async
¶
Writes events until the task is cancelled, then stops listening.
Source code in src/trading_agent/journal/trade_journal.py
record
¶
Appends one event to its journal file, unless it is a text piece.
A failure to write is logged and does not stop the journal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
published_event
|
Event
|
The event. |
required |
Source code in src/trading_agent/journal/trade_journal.py
path_for
¶
The journal file an event belongs in.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
published_event
|
Event
|
The event. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The desk's file for the event's India date, or the gateway's file for an event without a desk. |