-
Notifications
You must be signed in to change notification settings - Fork 724
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update example messaging with msgbus (#2406)
- Loading branch information
1 parent
d53c78d
commit 22512f8
Showing
4 changed files
with
42 additions
and
24 deletions.
There are no files selected for viewing
19 changes: 0 additions & 19 deletions
19
examples/backtest/example_09_custom_event_with_msgbus/README.md
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
examples/backtest/example_09_messaging_with_msgbus/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Example: Self-Communication Using Message Bus | ||
|
||
A practical demonstration of using NautilusTrader's message bus for self-communication within a strategy. | ||
The example implements a "10th bar notification system" where the strategy: | ||
|
||
1. Creates a custom event (using Python's dataclass) to represent the 10th bar occurrence | ||
2. Publishes this event to the message bus when the 10th bar arrives | ||
3. Subscribes to and handles these events within the same strategy | ||
|
||
Key learning points: | ||
- Creating custom events with the message bus | ||
- Implementing publish/subscribe pattern for self-communication | ||
- Using events for condition-based notifications | ||
- Handling state changes through message bus events | ||
|
||
This pattern provides a clean, event-driven approach to handle conditional notifications | ||
and state changes within your trading strategies. | ||
|
||
Note: | ||
While this example shows both publisher and subscriber roles within a single strategy, in practice these roles | ||
can be distributed - any component can be a publisher and any other component can be a subscriber of events. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters