backtrader.errors module¶
Exception Classes Module - Custom exceptions for backtrader.
This module defines the exception hierarchy used throughout the backtrader framework.
- Classes:
BacktraderError: Base exception for all backtrader exceptions. StrategySkipError: Raised to skip a strategy during optimization. ModuleImportError: Raised when a required module cannot be imported. FromModuleImportError: Raised when a from-style import fails. DataError: Raised for data-feed/parsing problems. BrokerError: Raised for broker/execution problems. OrderError: Raised for order-related problems (subclass of BrokerError). ConfigError: Raised for invalid configuration/parameters.
Example
Raising StrategySkipError during optimization: >>> class MyStrategy(bt.Strategy): … params = ((‘period’, 20),) … … def __init__(self): … if self.p.period < 5: … raise bt.errors.StrategySkipError()
- exception backtrader.errors.BacktraderError[source]¶
Bases:
ExceptionBase exception for all backtrader exceptions.
- exception backtrader.errors.StrategySkipError[source]¶
Bases:
BacktraderErrorRequests the platform to skip this strategy for backtesting. To be raised during the initialization (
__init__) phase of the instance
- exception backtrader.errors.DataError[source]¶
Bases:
BacktraderErrorRaised for data-feed problems: loading, parsing, or alignment failures.
- exception backtrader.errors.BrokerError[source]¶
Bases:
BacktraderErrorRaised for broker/execution problems: cash, margin, or matching failures.
- exception backtrader.errors.OrderError[source]¶
Bases:
BrokerErrorRaised for order-related problems: invalid size/price or rejected orders.
- exception backtrader.errors.ConfigError[source]¶
Bases:
BacktraderErrorRaised for invalid configuration or parameter values.