Skip to main content

Variables

  • custom_logger: logging.Logger: A custom logger instance for the Systematica library.

build_logger

build_logger(
    logger_name: str,
) ‑> logging.Logger
Build a custom logger with a RichHandler for better formatting. This logger will not propagate messages to the root logger. Parameters:
NameTypeDefaultDescription
logger_namestr--The name of the logger to create.
Returns:
TypeDescription
logging.LoggerA configured logger instance with a RichHandler.

UTCFormatter

UTCFormatter(
    fmt=None,
    datefmt=None,
    style='%',
    validate=True,
    *,
    defaults=None,
)
A custom logging formatter that formats timestamps in UTC. Initialize the formatter with specified format strings. Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format. Use a style parameter of %, { or $ to specify that you want to use one of %-formatting, str.format ({}) formatting or string.Template formatting in your format string. Parameters:
NameTypeDefaultDescription
fmtstrNoneThe format string for the log messages. If None, a default format is used.
datefmtstrNoneA format string for the date and time in the log messages. If None, defaults to ISO format.
stylestr%The style of formatting to use. Can be one of %, {, or $. Defaults to %.
validateboolTrueIf True, validate the format string against the specified style.
defaultsdictNoneA dictionary of default values for the format string. This is used to provide default values for any placeholders in the format string.
Raises:
TypeDescription
ValueErrorIf the format string is invalid for the specified style.

Ancestors

  • logging.Formatter

Methods

formatTime

formatTime(
    self,
    record,
    datefmt=None,
)
Convert the record’s creation timestamp to a UTC datetime object. If a datefmt is provided, format the datetime according to that format. Parameters:
NameTypeDefaultDescription
recordlogging.LogRecord--The log record containing the timestamp to format.
datefmtstrNoneA format string for the datetime. If not provided, defaults to ISO format.
Returns:
TypeDescription
strThe formatted timestamp as a string.

Logger

Logger(
    template_name: str = None,
)
A logger class that provides logging functionality for different strategies. Initialize the Logger. Parameters:
NameTypeDefaultDescription
strategy_namestrNoneThe name of the strategy for which the logger is created. If not provided, the default root logger is used.

Descendants

  • systematica.portfolio.messengers.base.BaseMessenger
  • systematica.utils.logger.TimeRotatingLogger

Static methods

get_logger_instance

get_logger_instance(
    strategy_name: str,
) ‑> logging.Logger
Get a logger instance for a specific strategy. Parameters:
NameTypeDefaultDescription
strategy_namestr--The name of the strategy for which the logger is created.
Returns:
TypeDescription
logging.LoggerA logger instance configured for the specified strategy.

Methods

info

info(
    self,
    msg: str,
)
Log a message at the INFO level. Parameters:
NameTypeDefaultDescription
msgstr--The message to log.

error

error(
    self,
    msg: str,
)
Log a message at the ERROR level. Parameters:
NameTypeDefaultDescription
msgstr--The message to log.

warning

warning(
    self,
    msg: str,
)
Log a message at the WARNING level. Parameters:
NameTypeDefaultDescription
msgstr--The message to log.

TimeRotatingLogger

TimeRotatingLogger(
    template_name: str = None,
)
A logger class which rotates at midnight. Initialize the Logger. Parameters:
NameTypeDefaultDescription
strategy_namestrNoneThe name of the strategy for which the logger is created. If not provided, the default root logger is used.

Ancestors

  • systematica.utils.logger.Logger

Static methods

get_logger_instance

get_logger_instance(
    strategy_name: str,
) ‑> logging.Logger
Get TimedRotatingFileHandler that rotates at midnight. Parameters:
NameTypeDefaultDescription
strategy_namestr--The name of the strategy for which the logger is created.
Returns:
TypeDescription
logging.LoggerA logger instance configured for the specified strategy.