backtrader.mixins package¶
Backtrader mixins module.
This module provides mixin classes that can be used to add functionality to other classes without using metaclasses. These mixins are part of the effort to remove metaprogramming from backtrader while maintaining backward compatibility.
- class backtrader.mixins.SingletonMixin[source]¶
Bases:
objectMixin class to implement singleton pattern using __new__ method.
This replaces the MetaSingleton metaclass pattern, providing the same functionality without using metaclasses. Each class that inherits from this mixin will maintain exactly one instance per class.
Thread-safe implementation using threading.Lock.
Features: - Thread-safe singleton creation - Per-class singleton instances (subclasses get their own instances) - Automatic cleanup when instances are garbage collected - Maintains compatibility with existing parameter systems
- class backtrader.mixins.ParameterizedSingletonMixin[source]¶
Bases:
SingletonMixinEnhanced singleton mixin that integrates with parameter systems.
This version is specifically designed to work with backtrader’s parameter system, maintaining compatibility with MetaParams functionality.
- backtrader.mixins.StoreBase¶
alias of
ParameterizedSingletonMixin