Skip to content

Add enable_event_logging for StrategyConfig #2183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 6, 2025

Conversation

sunlei
Copy link
Collaborator

@sunlei sunlei commented Jan 6, 2025

Pull Request

Add enable_event_logging for StrategyConfig.

In high-frequency trading strategies, <--[EVT] type events can be particularly noisy. To address this, a toggle switch has been added for better control.

Type of change

  • New feature (non-breaking change which adds functionality)

@cjdsellers cjdsellers merged commit b3432d4 into develop Jan 6, 2025
14 checks passed
@cjdsellers cjdsellers deleted the sunlei/event-log-config branch January 6, 2025 21:12
@@ -60,6 +60,7 @@ class StrategyConfig(NautilusConfig, kw_only=True, frozen=True):
external_order_claims: list[InstrumentId] | None = None
manage_contingent_orders: bool = False
manage_gtd_expiry: bool = False
enable_event_logging: bool = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sunlei I renamed this to a more neutral event_logging to avoid a redundant affirmative.

We could also consider making it something like event_log_level as well, since this new behavior still logs warning and above level events?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are similar types of logs, such as [CMD]-->, but they involve parts of the code I’m not very familiar with. So, I didn’t make any changes there and only adjusted the <--[EVT] logs for now. The idea of an event_log_level is great!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, this is good insight from someone running HFT strats "in the wild".

I think it might still be valuable to see the commands, or would you ideally want a similar config option to filter commands from the strategy as well?

Copy link
Collaborator Author

@sunlei sunlei Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjdsellers

Yes, having such an option would be ideal. In my high-frequency trading environment:

  1. These logs don’t hold significant value because the sheer volume makes them difficult to review, and their format can be challenging to manage. My approach is to compute key metrics directly, output them in Logfmt format, and write them to VictoriaMetrics for analysis. For log-related data, I retain only the most critical logs and a few custom logs, which are then stored in VictoriaLogs.

  2. Time is incredibly valuable. From my measurements, a single log entry can incur a few microseconds of overhead. To minimize this, I strive to reduce the number of logs and instead compute cumulative metrics that are periodically output using timers.

ps: This is solely my perspective based on my specific strategy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true that these log messages can be expensive. Thanks for the insights.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants