From abee306fd0aade8b68a4612539a61ecbbb22fb16 Mon Sep 17 00:00:00 2001 From: Romazes Date: Tue, 20 Feb 2024 17:19:39 +0200 Subject: [PATCH] revert: repeat code of finding data-provider --- lean/commands/live/deploy.py | 30 +++++++------------------- lean/models/data_providers/__init__.py | 7 +----- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/lean/commands/live/deploy.py b/lean/commands/live/deploy.py index e713f924..269a8473 100644 --- a/lean/commands/live/deploy.py +++ b/lean/commands/live/deploy.py @@ -27,7 +27,7 @@ from lean.commands.live.live import live from lean.components.util.live_utils import get_last_portfolio_cash_holdings, configure_initial_cash_balance, configure_initial_holdings,\ _configure_initial_cash_interactively, _configure_initial_holdings_interactively -from lean.models.data_providers import all_data_providers, installed_data_providers +from lean.models.data_providers import all_data_providers from lean.components.util.json_modules_handler import build_and_configure_modules, get_and_build_module, update_essential_properties_available _environment_skeleton = { @@ -39,7 +39,7 @@ } -def _get_configurable_modules_from_environment(lean_config: Dict[str, Any], environment_name: str) -> Tuple[LeanConfigConfigurer, List[LeanConfigConfigurer], LeanConfigConfigurer]: +def _get_configurable_modules_from_environment(lean_config: Dict[str, Any], environment_name: str) -> Tuple[LeanConfigConfigurer, List[LeanConfigConfigurer]]: """Returns the configurable modules from the given environment. :param lean_config: the LEAN configuration that should be used @@ -61,14 +61,7 @@ def _get_configurable_modules_from_environment(lean_config: Dict[str, Any], envi data_feed_configurers = [local_data_feed for local_data_feed in all_local_data_feeds if _get_brokerage_base_name(local_data_feed.get_live_name()) in data_queue_handlers_base_names] - - data_downloader_preference = None - if "data-downloader" in lean_config: - data_downloader_base_name = _get_brokerage_base_name(lean_config["data-downloader"]) - data_downloader_preference = next((local_data_history for local_data_history in installed_data_providers - if _get_brokerage_base_name(local_data_history.get_config_value_from_name('data-downloader')) in data_downloader_base_name), None) - - return brokerage_configurer, data_feed_configurers, data_downloader_preference + return brokerage_configurer, data_feed_configurers def _get_brokerage_base_name(brokerage: str) -> str: @@ -98,19 +91,12 @@ def _raise_for_missing_properties(lean_config: Dict[str, Any], environment_name: :param environment_name: the name of the environment :param lean_config_path: the path to the LEAN configuration file """ - brokerage_configurer, data_feed_configurers, data_downloader_preference = _get_configurable_modules_from_environment(lean_config, environment_name) + brokerage_configurer, data_feed_configurers = _get_configurable_modules_from_environment(lean_config, environment_name) brokerage_properties = brokerage_configurer.get_required_properties(include_optionals=False) data_queue_handler_properties = [] - for data_feed_configurer in data_feed_configurers: + for data_feed_configurer in data_feed_configurers: data_queue_handler_properties.extend(data_feed_configurer.get_required_properties(include_optionals=False)) - required_properties = list(set(brokerage_properties + data_queue_handler_properties)) - - if data_downloader_preference is not None: - for data_downloader_property in data_downloader_preference.get_required_properties(include_optionals=False): - if data_downloader_property not in required_properties: - required_properties.append(data_downloader_property) - missing_properties = [p for p in required_properties if p not in lean_config or lean_config[p] == ""] missing_properties = set(missing_properties) if len(missing_properties) == 0: @@ -443,8 +429,8 @@ def deploy(project: Path, raise MoreInfoError(f"The '{environment_name}' is not a live trading environment (live-mode is set to false)", "https://www.lean.io/docs/v2/lean-cli/live-trading/brokerages/quantconnect-paper-trading") - env_brokerage, env_data_queue_handlers, env_data_downloader = _get_configurable_modules_from_environment(lean_config, environment_name) - _install_modules([env_brokerage] + env_data_queue_handlers + [env_data_downloader], kwargs) + env_brokerage, env_data_queue_handlers = _get_configurable_modules_from_environment(lean_config, environment_name) + _install_modules([env_brokerage] + env_data_queue_handlers + [data_provider_configurer], kwargs) _raise_for_missing_properties(lean_config, environment_name, lean_config_manager.get_lean_config_path()) @@ -519,4 +505,4 @@ def deploy(project: Path, raise RuntimeError(f"InteractiveBrokers is currently not supported for ARM hosts") lean_runner = container.lean_runner - lean_runner.run_lean(lean_config, environment_name, algorithm_file, output, engine_image, None, release, detach, loads(extra_docker_config)) + lean_runner.run_lean(lean_config, environment_name, algorithm_file, output, engine_image, None, release, detach, loads(extra_docker_config)) \ No newline at end of file diff --git a/lean/models/data_providers/__init__.py b/lean/models/data_providers/__init__.py index 5eb8752c..fb0c47e2 100644 --- a/lean/models/data_providers/__init__.py +++ b/lean/models/data_providers/__init__.py @@ -16,16 +16,11 @@ from lean.models import json_modules all_data_providers: List[DataProvider] = [] -installed_data_providers: List[DataProvider] = [] for json_module in json_modules: if "data-provider" in json_module["type"]: all_data_providers.append(DataProvider(json_module)) -for data_provider in all_data_providers: - if data_provider._installs: - installed_data_providers.append(data_provider) - # QuantConnect DataProvider [QuantConnectDataProvider] = [ - data_provider for data_provider in all_data_providers if data_provider._id == "QuantConnect"] + data_provider for data_provider in all_data_providers if data_provider._id == "QuantConnect"] \ No newline at end of file