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.
示例
Using a store to get data and broker: >>> store = bt.observers.backends.ViStore() >>> data = store.getdata() >>> broker = store.getbroker()
- class backtrader.store.StoreParams[源代码]¶
基类:
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[源代码]¶
基类:
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)[源代码]¶
Construct the configured broker and bind it to this Store instance.
- start(data=None, broker=None)[源代码]¶
Register Store participants and initialize common lifecycle state.
- 参数:
data -- Data feed to register with the store (optional).
broker -- Broker instance to register with the store (optional).
备注
On first call, initializes the notification queue and data list. Subsequent calls can add data feeds or set the broker.