backtrader.store module¶
Store base classes.
Store provides per-instance state and lifecycle helpers for store implementations. LiveStoreBase builds on it as the contract for live stores. Store instances do not impose singleton behavior.
- Classes:
StoreParams: Parameter management for Store classes. Store: Per-instance base class for Store implementations.
Example
Using a store to get data and broker: >>> store = bt.observers.backends.ViStore() >>> data = store.getdata() >>> broker = store.getbroker()
- class backtrader.store.StoreParams[source]¶
Bases:
objectSimple parameter management for Store classes.
This class provides automatic parameter initialization from the class-level params tuple, creating a self.p attribute with all parameter values.
- class backtrader.store.Store[source]¶
Bases:
StoreParamsPer-instance base class for store implementations.
Stores manage connections to external data sources and brokers. They provide data feeds and broker instances, and handle notifications from the external service.
- _started¶
Whether the store has been started.
- params¶
Tuple of parameter definitions.
- broker¶
The broker instance associated with this store.
- params = ()¶
- getbroker(*args, **kwargs)[source]¶
Construct the configured broker and bind it to this Store instance.
- start(data=None, broker=None)[source]¶
Register Store participants and initialize common lifecycle state.
- Parameters:
data – Data feed to register with the store (optional).
broker – Broker instance to register with the store (optional).
Note
On first call, initializes the notification queue and data list. Subsequent calls can add data feeds or set the broker.
- stop()[source]¶
Stop the Store.
Concrete stores with resources to release should override this hook.