-
Notifications
You must be signed in to change notification settings - Fork 62
Open
Description
As of #685 getting merged, BaseStrategy.add() method receives flumine as an argument. This makes it elegant to add e.g. strategy-specific middleware or workers inside the strategy itself. The problem arises when multiple strategies require the same resource and add it multiple times.
As with streams, all the methods outlined below should check whether a resource has already been added and reject duplicates. The test should be if resource not in [resource_1, resource_2, ...] then add_resource(). It would then be expected of the end user to override __eq__() method of each custom resource to determine what constitutes a duplicate.
flumine/flumine/baseflumine.py
Lines 102 to 122 in bfaa5de
| def add_worker(self, worker: BackgroundWorker) -> None: | |
| logger.info("Adding worker %s", worker.name) | |
| self._workers.append(worker) | |
| def add_client_control( | |
| self, client: BaseClient, client_control: Type[BaseControl], **kwargs | |
| ) -> None: | |
| logger.info("Adding client control %s", client_control.NAME) | |
| client.trading_controls.append(client_control(self, client, **kwargs)) | |
| def add_trading_control(self, trading_control: Type[BaseControl], **kwargs) -> None: | |
| logger.info("Adding trading control %s", trading_control.NAME) | |
| self.trading_controls.append(trading_control(self, **kwargs)) | |
| def add_market_middleware(self, middleware: Middleware) -> None: | |
| logger.info("Adding market middleware %s", middleware) | |
| self._market_middleware.append(middleware) | |
| def add_logging_control(self, logging_control: LoggingControl) -> None: | |
| logger.info("Adding logging control %s", logging_control.NAME) | |
| self._logging_controls.append(logging_control) |
Metadata
Metadata
Assignees
Labels
No labels