Logging

All logging in Haymaker is performed asynchronously in a separate thread, ensuring that logging operations do not block or interfere with other actions.

Custom Logging Levels

In addition to standard Python logging levels, Haymaker defines two custom levels:

  • DATA (value 5): Very detailed information below the DEBUG level, typically used to log actual market data for low-level debugging.

  • NOTIFY (value 60): Above the CRITICAL level, typically used to send live notifications to administrators focused on strategy performance rather than technical details.

These levels are not used by the framework itself but are available for strategy creators to log non-technical performance information.

Logging Configuration

You can customize logging by defining a logging configuration in YAML format. Point Haymaker to this file by setting the logging_config configuration variable to its absolute path. This can be done via:

  • A YAML configuration file (e.g., under logging_config).

  • Command-line option (e.g., -s logging_config /path/to/config.yaml).

  • Environment variable (e.g., HAYMAKER_LOGGING_CONFIG=/path/to/config.yaml).

The log file location (when logging to a file) is set with the logging_path configuration variable. This specifies a subdirectory within the folder defined by the data_folder variable. If the subdirectory doesn’t exist, Haymaker creates it.

Note

Both logging_config and logging_path can be set in your configuration YAML file, via CLI with -s, or as environment variables prefixed with HAYMAKER_.

Execution Module

By default, the Execution Module creates three loggers:

  • haymaker: General messages related to the framework.

  • strategy: Tracks signals generated by strategies. The default haymaker.brick.AbstractBaseBrick implementation logs all data sent via dataEvent.

  • broker: Captures all ib_insync.ib.IB events with broker messages.

To customize logging, copy the default configuration file and override it as needed. The default file is located at:

https://github.com/t1user/haymaker/blob/master/haymaker/logging/logging_config.yaml

Dataloader Module

The Dataloader Module creates a single logger that outputs to both stream and file.

To customize logging, copy the default configuration file and override it as needed. The default file is located at:

https://github.com/t1user/haymaker/blob/master/haymaker/logging/dataloader_logging_config.yaml