From 42d37549b4ce8a84760a250fad60d3062bb61ab3 Mon Sep 17 00:00:00 2001 From: Romazes Date: Wed, 7 Feb 2024 15:04:18 +0200 Subject: [PATCH 1/4] rename: data-provider and data-feed --- lean/commands/backtest.py | 14 ++++---- lean/commands/cloud/live/deploy.py | 8 ++--- lean/commands/live/deploy.py | 34 +++++++++---------- lean/commands/optimize.py | 12 +++---- lean/commands/research.py | 14 ++++---- lean/components/api/live_client.py | 2 +- lean/components/config/lean_config_manager.py | 4 +-- .../brokerages/cloud/cloud_brokerage.py | 2 +- lean/models/brokerages/local/data_feed.py | 2 +- 9 files changed, 46 insertions(+), 46 deletions(-) diff --git a/lean/commands/backtest.py b/lean/commands/backtest.py index e8deda1c..373b1693 100644 --- a/lean/commands/backtest.py +++ b/lean/commands/backtest.py @@ -251,7 +251,7 @@ def _select_organization() -> QCMinimalOrganization: @option("--debug", type=Choice(["pycharm", "ptvsd", "vsdbg", "rider", "local-platform"], case_sensitive=False), help="Enable a certain debugging method (see --help for more information)") -@option("--data-provider", +@option("--data-provider-historical", type=Choice([dp.get_name() for dp in all_data_providers], case_sensitive=False), default="Local", help="Update the Lean configuration file to retrieve data from the given provider") @@ -259,10 +259,10 @@ def _select_organization() -> QCMinimalOrganization: @option("--download-data", is_flag=True, default=False, - help="Update the Lean configuration file to download data from the QuantConnect API, alias for --data-provider QuantConnect") + help="Update the Lean configuration file to download data from the QuantConnect API, alias for --data-provider-historical QuantConnect") @option("--data-purchase-limit", type=int, - help="The maximum amount of QCC to spend on downloading data during the backtest when using QuantConnect as data provider") + help="The maximum amount of QCC to spend on downloading data during the backtest when using QuantConnect as data provider historical") @option("--release", is_flag=True, default=False, @@ -301,7 +301,7 @@ def backtest(project: Path, output: Optional[Path], detach: bool, debug: Optional[str], - data_provider: Optional[str], + data_provider_historical: Optional[str], download_data: bool, data_purchase_limit: Optional[int], release: bool, @@ -363,12 +363,12 @@ def backtest(project: Path, lean_config = lean_config_manager.get_complete_lean_config("backtesting", algorithm_file, debugging_method) if download_data: - data_provider = QuantConnectDataProvider.get_name() + data_provider_historical = QuantConnectDataProvider.get_name() organization_id = container.organization_manager.try_get_working_organization_id() - if data_provider is not None: - data_provider_configurer: DataProvider = get_and_build_module(data_provider, all_data_providers, kwargs, logger) + if data_provider_historical is not None: + data_provider_configurer: DataProvider = get_and_build_module(data_provider_historical, all_data_providers, kwargs, logger) data_provider_configurer.ensure_module_installed(organization_id) data_provider_configurer.configure(lean_config, "backtesting") diff --git a/lean/commands/cloud/live/deploy.py b/lean/commands/cloud/live/deploy.py index 640680e2..457b349b 100644 --- a/lean/commands/cloud/live/deploy.py +++ b/lean/commands/cloud/live/deploy.py @@ -114,13 +114,13 @@ def _configure_brokerage(lean_config: Dict[str, Any], logger: Logger, user_provi hide_input=not show_secrets) def _configure_data_feed(brokerage: CloudBrokerage, logger: Logger) -> None: - """Configures the data feed to use based on the brokerage given. + """Configures the data provider live to use based on the brokerage given. :param brokerage: the cloud brokerage :param logger: the logger to use """ if len(cloud_brokerage_data_feeds[brokerage]) != 0: - data_feed_selected = logger.prompt_list("Select a data feed", [ + data_feed_selected = logger.prompt_list("Select a data provider live", [ Option(id=data_feed, label=data_feed) for data_feed in cloud_brokerage_data_feeds[brokerage] ], multiple=False) data_feed_property_name = [name for name in brokerage.get_required_properties([InternalInputUserInput]) if ("data-feed" in name)] @@ -265,7 +265,7 @@ def deploy(project: str, ensure_options(essential_properties) essential_properties_value = {brokerage_instance.convert_variable_to_lean_key(prop) : kwargs[prop] for prop in essential_properties} brokerage_instance.update_configs(essential_properties_value) - # now required properties can be fetched as per data provider from essential properties + # now required properties can be fetched as per data provider historical from essential properties required_properties = [brokerage_instance.convert_lean_key_to_variable(prop) for prop in brokerage_instance.get_required_properties([InternalInputUserInput])] ensure_options(required_properties) required_properties_value = {brokerage_instance.convert_variable_to_lean_key(prop) : kwargs[prop] for prop in required_properties} @@ -340,7 +340,7 @@ def deploy(project: str, logger.info(f"Environment: {brokerage_settings['environment'].title()}") logger.info(f"Server name: {live_node.name}") logger.info(f"Server type: {live_node.sku}") - logger.info(f"Data provider: {price_data_handler.replace('Handler', '')}") + logger.info(f"Data provider historical: {price_data_handler.replace('Handler', '')}") logger.info(f"LEAN version: {cloud_project.leanVersionId}") logger.info(f"Order event notifications: {'Yes' if notify_order_events else 'No'}") logger.info(f"Insight notifications: {'Yes' if notify_insights else 'No'}") diff --git a/lean/commands/live/deploy.py b/lean/commands/live/deploy.py index a8f35864..a913a84e 100644 --- a/lean/commands/live/deploy.py +++ b/lean/commands/live/deploy.py @@ -171,7 +171,7 @@ def _configure_lean_config_interactively(lean_config: Dict[str, Any], brokerage.build(lean_config, logger, properties, hide_input=not show_secrets).configure(lean_config, environment_name) - data_feeds = logger.prompt_list("Select a data feed", [ + data_feeds = logger.prompt_list("Select a data provider live", [ Option(id=data_feed, label=data_feed.get_name()) for data_feed in local_brokerage_data_feeds[brokerage] ], multiple= True) for data_feed in data_feeds: @@ -228,11 +228,11 @@ def _get_default_value(key: str) -> Optional[Any]: @option("--brokerage", type=Choice([b.get_name() for b in all_local_brokerages], case_sensitive=False), help="The brokerage to use") -@option("--data-feed", +@option("--data-provider-live", type=Choice([d.get_name() for d in all_local_data_feeds], case_sensitive=False), multiple=True, - help="The data feed to use") -@option("--data-provider", + help="The data provider live to use") +@option("--data-provider-historical", type=Choice([dp.get_name() for dp in all_data_providers if dp._id != "TerminalLinkBrokerage"], case_sensitive=False), default="Local", help="Update the Lean configuration file to retrieve data from the given provider") @@ -282,8 +282,8 @@ def deploy(project: Path, output: Optional[Path], detach: bool, brokerage: Optional[str], - data_feed: Optional[str], - data_provider: Optional[str], + data_provider_live: Optional[str], + data_provider_historical: Optional[str], release: bool, image: Optional[str], python_venv: Optional[str], @@ -302,14 +302,14 @@ def deploy(project: Path, If PROJECT is a directory, the algorithm in the main.py or Main.cs file inside it will be executed. If PROJECT is a file, the algorithm in the specified file will be executed. - By default an interactive wizard is shown letting you configure the brokerage and data feed to use. - If --environment, --brokerage or --data-feed are given the command runs in non-interactive mode. + By default an interactive wizard is shown letting you configure the brokerage and data provider live to use. + If --environment, --brokerage or --data-provider-live are given the command runs in non-interactive mode. In this mode the CLI does not prompt for input. If --environment is given it must be the name of a live environment in the Lean configuration. - If --brokerage and --data-feed are given, the options specific to the given brokerage/data feed must also be given. - The Lean config is used as fallback when a brokerage/data feed-specific option hasn't been passed in. + If --brokerage and --data-provider-live are given, the options specific to the given brokerage/data provider live must also be given. + The Lean config is used as fallback when a brokerage/data provider live-specific option hasn't been passed in. If a required option is not given and cannot be found in the Lean config the command aborts. By default the official LEAN engine image is used. @@ -333,8 +333,8 @@ def deploy(project: Path, lean_config_manager = container.lean_config_manager - if environment is not None and (brokerage is not None or len(data_feed) > 0): - raise RuntimeError("--environment and --brokerage + --data-feed are mutually exclusive") + if environment is not None and (brokerage is not None or len(data_provider_live) > 0): + raise RuntimeError("--environment and --brokerage + --data-provider-live are mutually exclusive") if environment is not None: environment_name = environment @@ -385,7 +385,7 @@ def deploy(project: Path, [update_essential_properties_available([brokerage_configurer], kwargs)] [update_essential_properties_available(data_feed_configurers, kwargs)] - elif brokerage is not None or len(data_feed) > 0: + elif brokerage is not None or len(data_provider_live) > 0: ensure_options(["brokerage", "data_feed"]) environment_name = "lean-cli" @@ -398,7 +398,7 @@ def deploy(project: Path, [brokerage_configurer] = [get_and_build_module(brokerage, all_local_brokerages, kwargs, logger)] brokerage_configurer.configure(lean_config, environment_name) - for df in data_feed: + for df in data_provider_live: [data_feed_configurer] = [get_and_build_module(df, all_local_data_feeds, kwargs, logger)] data_feed_configurer.configure(lean_config, environment_name) @@ -407,8 +407,8 @@ def deploy(project: Path, lean_config = lean_config_manager.get_complete_lean_config(environment_name, algorithm_file, None) _configure_lean_config_interactively(lean_config, environment_name, kwargs, show_secrets=show_secrets) - if data_provider is not None: - [data_provider_configurer] = [get_and_build_module(data_provider, all_data_providers, kwargs, logger)] + if data_provider_historical is not None: + [data_provider_configurer] = [get_and_build_module(data_provider_historical, all_data_providers, kwargs, logger)] data_provider_configurer.configure(lean_config, environment_name) if "environments" not in lean_config or environment_name not in lean_config["environments"]: @@ -444,7 +444,7 @@ def deploy(project: Path, cash_balance_option, holdings_option, last_cash, last_holdings = get_last_portfolio_cash_holdings(container.api_client, env_brokerage, project_config.get("cloud-id", None), project) - if environment is None and brokerage is None and len(data_feed) == 0: # condition for using interactive panel + if environment is None and brokerage is None and len(data_provider_live) == 0: # condition for using interactive panel if cash_balance_option != LiveInitialStateInput.NotSupported: live_cash_balance = _configure_initial_cash_interactively(logger, cash_balance_option, last_cash) diff --git a/lean/commands/optimize.py b/lean/commands/optimize.py index eb459c17..0db2bfbb 100644 --- a/lean/commands/optimize.py +++ b/lean/commands/optimize.py @@ -97,14 +97,14 @@ def get_filename_timestamp(path: Path) -> datetime: type=str, multiple=True, help="The 'statistic operator value' pairs configuring the constraints of the optimization") -@option("--data-provider", +@option("--data-provider-historical", type=Choice([dp.get_name() for dp in all_data_providers], case_sensitive=False), default="Local", help="Update the Lean configuration file to retrieve data from the given provider") @option("--download-data", is_flag=True, default=False, - help="Update the Lean configuration file to download data from the QuantConnect API, alias for --data-provider QuantConnect") + help="Update the Lean configuration file to download data from the QuantConnect API, alias for --data-provider-historical QuantConnect") @option("--release", is_flag=True, default=False, @@ -150,7 +150,7 @@ def optimize(project: Path, target_direction: Optional[str], parameter: List[Tuple[str, float, float, float]], constraint: List[str], - data_provider: Optional[str], + data_provider_historical: Optional[str], download_data: bool, release: bool, image: Optional[str], @@ -299,10 +299,10 @@ def optimize(project: Path, organization_id = container.organization_manager.try_get_working_organization_id() if download_data: - data_provider = QuantConnectDataProvider.get_name() + data_provider_historical = QuantConnectDataProvider.get_name() - if data_provider is not None: - data_provider_configurer: DataProvider = get_and_build_module(data_provider, all_data_providers, kwargs, logger) + if data_provider_historical is not None: + data_provider_configurer: DataProvider = get_and_build_module(data_provider_historical, all_data_providers, kwargs, logger) data_provider_configurer.ensure_module_installed(organization_id) data_provider_configurer.configure(lean_config, environment) logger.info(lean_config) diff --git a/lean/commands/research.py b/lean/commands/research.py index 19b60b6c..261b23ad 100644 --- a/lean/commands/research.py +++ b/lean/commands/research.py @@ -37,7 +37,7 @@ def _check_docker_output(chunk: str, port: int) -> None: @command(cls=LeanCommand, requires_lean_config=True, requires_docker=True) @argument("project", type=PathParameter(exists=True, file_okay=False, dir_okay=True)) @option("--port", type=int, default=8888, help="The port to run Jupyter Lab on (defaults to 8888)") -@option("--data-provider", +@option("--data-provider-historical", type=Choice([dp.get_name() for dp in all_data_providers], case_sensitive=False), default="Local", help="Update the Lean configuration file to retrieve data from the given provider") @@ -45,10 +45,10 @@ def _check_docker_output(chunk: str, port: int) -> None: @option("--download-data", is_flag=True, default=False, - help=f"Update the Lean configuration file to download data from the QuantConnect API, alias for --data-provider {QuantConnectDataProvider.get_name()}") + help=f"Update the Lean configuration file to download data from the QuantConnect API, alias for --data-provider-historical {QuantConnectDataProvider.get_name()}") @option("--data-purchase-limit", type=int, - help="The maximum amount of QCC to spend on downloading data during the research session when using QuantConnect as data provider") + help="The maximum amount of QCC to spend on downloading data during the research session when using QuantConnect as data provider historical") @option("--detach", "-d", is_flag=True, default=False, @@ -77,7 +77,7 @@ def _check_docker_output(chunk: str, port: int) -> None: help="Use the local LEAN research image instead of pulling the latest version") def research(project: Path, port: int, - data_provider: Optional[str], + data_provider_historical: Optional[str], download_data: bool, data_purchase_limit: Optional[int], detach: bool, @@ -110,10 +110,10 @@ def research(project: Path, lean_config["research-object-store-name"] = algorithm_name if download_data: - data_provider = QuantConnectDataProvider.get_name() + data_provider_historical = QuantConnectDataProvider.get_name() - if data_provider is not None: - data_provider_configurer: DataProvider = get_and_build_module(data_provider, all_data_providers, kwargs, logger) + if data_provider_historical is not None: + data_provider_configurer: DataProvider = get_and_build_module(data_provider_historical, all_data_providers, kwargs, logger) data_provider_configurer.ensure_module_installed(container.organization_manager.try_get_working_organization_id()) data_provider_configurer.configure(lean_config, "backtesting") diff --git a/lean/components/api/live_client.py b/lean/components/api/live_client.py index 99055fd5..827f2ebe 100644 --- a/lean/components/api/live_client.py +++ b/lean/components/api/live_client.py @@ -71,7 +71,7 @@ def start(self, :param compile_id: the id of the compile to use for live trading :param node_id: the id of the node to start live trading on :param brokerage_settings: the brokerage settings to use - :param price_data_handler: the data feed to use + :param price_data_handler: the data provider live to use :param automatic_redeploy: whether automatic redeploys are enabled :param version_id: the id of the LEAN version to use :param notify_order_events: whether notifications should be sent on order events diff --git a/lean/components/config/lean_config_manager.py b/lean/components/config/lean_config_manager.py index 91951800..9de61811 100644 --- a/lean/components/config/lean_config_manager.py +++ b/lean/components/config/lean_config_manager.py @@ -297,7 +297,7 @@ def get_complete_lean_config(self, def configure_data_purchase_limit(self, lean_config: Dict[str, Any], data_purchase_limit: Optional[int]) -> None: """Updates the data purchase limit in the Lean config. - Logs a warning if the data provider is not configured to download from QuantConnect. + Logs a warning if the data provider historical is not configured to download from QuantConnect. :param lean_config: the Lean config dict to update :param data_purchase_limit: the data purchase limit provided by the user, or None if no such limit was provided @@ -307,7 +307,7 @@ def configure_data_purchase_limit(self, lean_config: Dict[str, Any], data_purcha if lean_config.get("data-provider", None) != "QuantConnect.Lean.Engine.DataFeeds.ApiDataProvider": self._logger.warn( - "--data-purchase-limit is ignored because the data provider is not set to download from the QuantConnect API, use --download-data to set that up") + "--data-purchase-limit is ignored because the data provider historical is not set to download from the QuantConnect API, use --download-data to set that up") return lean_config["data-purchase-limit"] = data_purchase_limit diff --git a/lean/models/brokerages/cloud/cloud_brokerage.py b/lean/models/brokerages/cloud/cloud_brokerage.py index d97c0e4e..a00b2dea 100644 --- a/lean/models/brokerages/cloud/cloud_brokerage.py +++ b/lean/models/brokerages/cloud/cloud_brokerage.py @@ -75,7 +75,7 @@ def get_settings(self) -> Dict[str, str]: return settings def get_price_data_handler(self) -> str: - """Returns the price data feed handler to use. + """Returns the price data provider live handler to use. :return: the value to assign to the "dataHandler" property of the live/create API endpoint """ # TODO: Handle this case with json conditions diff --git a/lean/models/brokerages/local/data_feed.py b/lean/models/brokerages/local/data_feed.py index 34be975e..54defe9b 100644 --- a/lean/models/brokerages/local/data_feed.py +++ b/lean/models/brokerages/local/data_feed.py @@ -16,7 +16,7 @@ class DataFeed(LeanConfigConfigurer): - """A JsonModule implementation for the Json data feed module.""" + """A JsonModule implementation for the Json data provider live module.""" def __init__(self, json_datafeed_data: Dict[str, Any]) -> None: super().__init__(json_datafeed_data) From e60cd9790ed1beb6bf40430166542f69d118affa Mon Sep 17 00:00:00 2001 From: Romazes Date: Wed, 7 Feb 2024 17:59:25 +0200 Subject: [PATCH 2/4] rename: data-provider in tests --- lean/commands/cloud/live/deploy.py | 2 +- .../cloud/live/test_cloud_live_commands.py | 4 +-- tests/commands/test_backtest.py | 2 +- tests/commands/test_live.py | 26 +++++++++---------- tests/commands/test_optimize.py | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lean/commands/cloud/live/deploy.py b/lean/commands/cloud/live/deploy.py index 457b349b..bf63f720 100644 --- a/lean/commands/cloud/live/deploy.py +++ b/lean/commands/cloud/live/deploy.py @@ -340,7 +340,7 @@ def deploy(project: str, logger.info(f"Environment: {brokerage_settings['environment'].title()}") logger.info(f"Server name: {live_node.name}") logger.info(f"Server type: {live_node.sku}") - logger.info(f"Data provider historical: {price_data_handler.replace('Handler', '')}") + logger.info(f"Data provider live: {price_data_handler.replace('Handler', '')}") logger.info(f"LEAN version: {cloud_project.leanVersionId}") logger.info(f"Order event notifications: {'Yes' if notify_order_events else 'No'}") logger.info(f"Insight notifications: {'Yes' if notify_insights else 'No'}") diff --git a/tests/commands/cloud/live/test_cloud_live_commands.py b/tests/commands/cloud/live/test_cloud_live_commands.py index 6f930272..6c1cd888 100644 --- a/tests/commands/cloud/live/test_cloud_live_commands.py +++ b/tests/commands/cloud/live/test_cloud_live_commands.py @@ -114,7 +114,7 @@ def test_cloud_live_deploy_with_ib_using_hybrid_datafeed() -> None: "--ib-account", "DU2366417", "--ib-password", "test_password"]) assert result.exit_code == 0 - assert "Data provider: quantconnecthandler+interactivebrokershandler" in result.output.split("\n") + assert "Data provider live: quantconnecthandler+interactivebrokershandler" in result.output.split("\n") def test_cloud_live_deploy_with_tradier_using_tradier_datafeed() -> None: create_fake_lean_cli_directory() @@ -135,7 +135,7 @@ def test_cloud_live_deploy_with_tradier_using_tradier_datafeed() -> None: "--tradier-access-token", "456", "--tradier-environment", "paper"]) assert result.exit_code == 0 - assert "Data provider: TradierBrokerage" in result.output.split("\n") + assert "Data provider live: TradierBrokerage" in result.output.split("\n") @pytest.mark.parametrize("notice_method,configs", [("emails", "customAddress:customSubject"), ("emails", "customAddress1:customSubject1,customAddress2:customSubject2"), diff --git a/tests/commands/test_backtest.py b/tests/commands/test_backtest.py index 18d64d65..a59ea0f0 100644 --- a/tests/commands/test_backtest.py +++ b/tests/commands/test_backtest.py @@ -612,7 +612,7 @@ def test_backtest_passes_data_purchase_limit_to_lean_runner() -> None: } """) - result = CliRunner().invoke(lean, ["backtest", "Python Project", "--data-provider", "QuantConnect", "--data-purchase-limit", "1000"]) + result = CliRunner().invoke(lean, ["backtest", "Python Project", "--data-provider-historical", "QuantConnect", "--data-purchase-limit", "1000"]) assert result.exit_code == 0 diff --git a/tests/commands/test_live.py b/tests/commands/test_live.py index b8ec5fd5..c418abdb 100644 --- a/tests/commands/test_live.py +++ b/tests/commands/test_live.py @@ -435,7 +435,7 @@ def test_live_calls_lean_runner_with_data_provider(data_provider: str) -> None: options.extend([f"--{key}", value]) result = CliRunner().invoke(lean, ["live", "CSharp Project", "--environment", "live-paper", - "--data-provider", data_provider, + "--data-provider-historical", data_provider, *options]) expected = 0 @@ -488,7 +488,7 @@ def test_live_non_interactive_aborts_when_missing_brokerage_options(brokerage: s result = CliRunner().invoke(lean, ["live", "Python Project", "--brokerage", brokerage, - "--data-feed", data_feed, + "---data-provider-live", data_feed, *options]) assert result.exit_code != 0 @@ -511,7 +511,7 @@ def test_live_non_interactive_aborts_when_missing_data_feed_options(data_feed: s result = CliRunner().invoke(lean, ["live", "Python Project", "--brokerage", "Paper Trading", - "--data-feed", data_feed, + "--data-provider-live", data_feed, "--live-cash-balance", "USD:100", *options]) @@ -541,7 +541,7 @@ def test_live_non_interactive_do_not_store_non_persistent_properties_in_lean_con result = CliRunner().invoke(lean, ["live", "Python Project", "--brokerage", brokerage, - "--data-feed", data_feed, + "--data-provider-live", data_feed, *options]) traceback.print_exception(*result.exc_info) @@ -583,7 +583,7 @@ def test_live_non_interactive_calls_run_lean_when_all_options_given(brokerage: s result = CliRunner().invoke(lean, ["live", "Python Project", "--brokerage", brokerage, - "--data-feed", data_feed, + "--data-provider-live", data_feed, *options]) traceback.print_exception(*result.exc_info) @@ -622,8 +622,8 @@ def test_live_non_interactive_calls_run_lean_when_all_options_given_with_multipl result = CliRunner().invoke(lean, ["live", "Python Project", "--brokerage", brokerage, - "--data-feed", data_feed1, - "--data-feed", data_feed2, + "--data-provider-live", data_feed1, + "--data-provider-live", data_feed2, *options]) traceback.print_exception(*result.exc_info) @@ -682,7 +682,7 @@ def test_live_non_interactive_falls_back_to_lean_config_for_brokerage_settings(b result = CliRunner().invoke(lean, ["live", "Python Project", "--brokerage", brokerage, - "--data-feed", data_feed, + "--data-provider-live", data_feed, *options]) traceback.print_exception(*result.exc_info) @@ -731,7 +731,7 @@ def test_live_non_interactive_falls_back_to_lean_config_for_data_feed_settings(d result = CliRunner().invoke(lean, ["live", "Python Project", "--brokerage", "Paper Trading", - "--data-feed", data_feed, + "--data-provider-live", data_feed, "--live-cash-balance", "USD:100", *options]) @@ -780,8 +780,8 @@ def test_live_non_interactive_falls_back_to_lean_config_for_multiple_data_feed_s result = CliRunner().invoke(lean, ["live", "Python Project", "--brokerage", "Paper Trading", - "--data-feed", data_feed1, - "--data-feed", data_feed2, + "--data-provider-live", data_feed1, + "--data-provider-live", data_feed2, "--live-cash-balance", "USD:100", *options]) @@ -924,7 +924,7 @@ def test_live_passes_live_cash_balance_to_lean_runner_when_given_as_option(broke result = CliRunner().invoke(lean, ["live", "Python Project", *options, "--brokerage", brokerage, "--live-cash-balance", cash, - "--data-feed", "Custom data only"]) + "--data-provider-live", "Custom data only"]) if brokerage not in ["Paper Trading", "Trading Technologies", "Terminal Link"] and cash != "": assert result.exit_code != 0 @@ -988,7 +988,7 @@ def test_live_passes_live_holdings_to_lean_runner_when_given_as_option(brokerage options.extend(["--live-cash-balance", "USD:100"]) result = CliRunner().invoke(lean, ["live", "Python Project", "--brokerage", brokerage, "--live-holdings", holdings, - "--data-feed", "Custom data only", *options]) + "--data-provider-live", "Custom data only", *options]) if brokerage not in ["Paper Trading", "Terminal Link"] and holdings != "": assert result.exit_code != 0 diff --git a/tests/commands/test_optimize.py b/tests/commands/test_optimize.py index 940ddf39..4810c683 100644 --- a/tests/commands/test_optimize.py +++ b/tests/commands/test_optimize.py @@ -801,7 +801,7 @@ def test_optimize_used_data_downloader_specified_with_data_provider_option() -> with mock.patch.object(ModuleManager, "install_module"): result = CliRunner().invoke(lean, ["optimize", "Python Project", - "--data-provider", "Polygon", + "--data-provider-historical", "Polygon", "--polygon-api-key", "my-key"]) assert result.exit_code == 0 From 8851249f3d6456d23640b6657a73c5cfc17be8a9 Mon Sep 17 00:00:00 2001 From: Romazes Date: Wed, 7 Feb 2024 20:26:03 +0200 Subject: [PATCH 3/4] typo: change words order feat: add missed words in help of historical-provider param --- lean/commands/backtest.py | 4 ++-- lean/commands/cloud/live/deploy.py | 8 ++++---- lean/commands/live/deploy.py | 12 ++++++------ lean/commands/optimize.py | 2 +- lean/commands/research.py | 4 ++-- lean/components/api/live_client.py | 2 +- lean/components/config/lean_config_manager.py | 4 ++-- lean/models/brokerages/cloud/cloud_brokerage.py | 2 +- lean/models/brokerages/local/data_feed.py | 2 +- lean/models/data_providers/data_provider.py | 2 +- .../commands/cloud/live/test_cloud_live_commands.py | 4 ++-- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lean/commands/backtest.py b/lean/commands/backtest.py index 373b1693..d3d781bc 100644 --- a/lean/commands/backtest.py +++ b/lean/commands/backtest.py @@ -254,7 +254,7 @@ def _select_organization() -> QCMinimalOrganization: @option("--data-provider-historical", type=Choice([dp.get_name() for dp in all_data_providers], case_sensitive=False), default="Local", - help="Update the Lean configuration file to retrieve data from the given provider") + help="Update the Lean configuration file to retrieve data from the given historical provider") @options_from_json(get_configs_for_options("backtest")) @option("--download-data", is_flag=True, @@ -262,7 +262,7 @@ def _select_organization() -> QCMinimalOrganization: help="Update the Lean configuration file to download data from the QuantConnect API, alias for --data-provider-historical QuantConnect") @option("--data-purchase-limit", type=int, - help="The maximum amount of QCC to spend on downloading data during the backtest when using QuantConnect as data provider historical") + help="The maximum amount of QCC to spend on downloading data during the backtest when using QuantConnect as historical data provider") @option("--release", is_flag=True, default=False, diff --git a/lean/commands/cloud/live/deploy.py b/lean/commands/cloud/live/deploy.py index bf63f720..ad9bb347 100644 --- a/lean/commands/cloud/live/deploy.py +++ b/lean/commands/cloud/live/deploy.py @@ -114,13 +114,13 @@ def _configure_brokerage(lean_config: Dict[str, Any], logger: Logger, user_provi hide_input=not show_secrets) def _configure_data_feed(brokerage: CloudBrokerage, logger: Logger) -> None: - """Configures the data provider live to use based on the brokerage given. + """Configures the live data provider to use based on the brokerage given. :param brokerage: the cloud brokerage :param logger: the logger to use """ if len(cloud_brokerage_data_feeds[brokerage]) != 0: - data_feed_selected = logger.prompt_list("Select a data provider live", [ + data_feed_selected = logger.prompt_list("Select a live data provider", [ Option(id=data_feed, label=data_feed) for data_feed in cloud_brokerage_data_feeds[brokerage] ], multiple=False) data_feed_property_name = [name for name in brokerage.get_required_properties([InternalInputUserInput]) if ("data-feed" in name)] @@ -265,7 +265,7 @@ def deploy(project: str, ensure_options(essential_properties) essential_properties_value = {brokerage_instance.convert_variable_to_lean_key(prop) : kwargs[prop] for prop in essential_properties} brokerage_instance.update_configs(essential_properties_value) - # now required properties can be fetched as per data provider historical from essential properties + # now required properties can be fetched as per historical data provider from essential properties required_properties = [brokerage_instance.convert_lean_key_to_variable(prop) for prop in brokerage_instance.get_required_properties([InternalInputUserInput])] ensure_options(required_properties) required_properties_value = {brokerage_instance.convert_variable_to_lean_key(prop) : kwargs[prop] for prop in required_properties} @@ -340,7 +340,7 @@ def deploy(project: str, logger.info(f"Environment: {brokerage_settings['environment'].title()}") logger.info(f"Server name: {live_node.name}") logger.info(f"Server type: {live_node.sku}") - logger.info(f"Data provider live: {price_data_handler.replace('Handler', '')}") + logger.info(f"Live data provider: {price_data_handler.replace('Handler', '')}") logger.info(f"LEAN version: {cloud_project.leanVersionId}") logger.info(f"Order event notifications: {'Yes' if notify_order_events else 'No'}") logger.info(f"Insight notifications: {'Yes' if notify_insights else 'No'}") diff --git a/lean/commands/live/deploy.py b/lean/commands/live/deploy.py index a913a84e..5ae1c916 100644 --- a/lean/commands/live/deploy.py +++ b/lean/commands/live/deploy.py @@ -171,7 +171,7 @@ def _configure_lean_config_interactively(lean_config: Dict[str, Any], brokerage.build(lean_config, logger, properties, hide_input=not show_secrets).configure(lean_config, environment_name) - data_feeds = logger.prompt_list("Select a data provider live", [ + data_feeds = logger.prompt_list("Select a live data provider", [ Option(id=data_feed, label=data_feed.get_name()) for data_feed in local_brokerage_data_feeds[brokerage] ], multiple= True) for data_feed in data_feeds: @@ -231,11 +231,11 @@ def _get_default_value(key: str) -> Optional[Any]: @option("--data-provider-live", type=Choice([d.get_name() for d in all_local_data_feeds], case_sensitive=False), multiple=True, - help="The data provider live to use") + help="The live data provider to use") @option("--data-provider-historical", type=Choice([dp.get_name() for dp in all_data_providers if dp._id != "TerminalLinkBrokerage"], case_sensitive=False), default="Local", - help="Update the Lean configuration file to retrieve data from the given provider") + help="Update the Lean configuration file to retrieve data from the given historical provider") @options_from_json(get_configs_for_options("live-local")) @option("--release", is_flag=True, @@ -302,14 +302,14 @@ def deploy(project: Path, If PROJECT is a directory, the algorithm in the main.py or Main.cs file inside it will be executed. If PROJECT is a file, the algorithm in the specified file will be executed. - By default an interactive wizard is shown letting you configure the brokerage and data provider live to use. + By default an interactive wizard is shown letting you configure the brokerage and live data provider to use. If --environment, --brokerage or --data-provider-live are given the command runs in non-interactive mode. In this mode the CLI does not prompt for input. If --environment is given it must be the name of a live environment in the Lean configuration. - If --brokerage and --data-provider-live are given, the options specific to the given brokerage/data provider live must also be given. - The Lean config is used as fallback when a brokerage/data provider live-specific option hasn't been passed in. + If --brokerage and --data-provider-live are given, the options specific to the given brokerage/live data provider must also be given. + The Lean config is used as fallback when a brokerage/live data provider-specific option hasn't been passed in. If a required option is not given and cannot be found in the Lean config the command aborts. By default the official LEAN engine image is used. diff --git a/lean/commands/optimize.py b/lean/commands/optimize.py index 0db2bfbb..05e02f27 100644 --- a/lean/commands/optimize.py +++ b/lean/commands/optimize.py @@ -100,7 +100,7 @@ def get_filename_timestamp(path: Path) -> datetime: @option("--data-provider-historical", type=Choice([dp.get_name() for dp in all_data_providers], case_sensitive=False), default="Local", - help="Update the Lean configuration file to retrieve data from the given provider") + help="Update the Lean configuration file to retrieve data from the given historical provider") @option("--download-data", is_flag=True, default=False, diff --git a/lean/commands/research.py b/lean/commands/research.py index 261b23ad..d8c17d35 100644 --- a/lean/commands/research.py +++ b/lean/commands/research.py @@ -40,7 +40,7 @@ def _check_docker_output(chunk: str, port: int) -> None: @option("--data-provider-historical", type=Choice([dp.get_name() for dp in all_data_providers], case_sensitive=False), default="Local", - help="Update the Lean configuration file to retrieve data from the given provider") + help="Update the Lean configuration file to retrieve data from the given historical provider") @options_from_json(get_configs_for_options("research")) @option("--download-data", is_flag=True, @@ -48,7 +48,7 @@ def _check_docker_output(chunk: str, port: int) -> None: help=f"Update the Lean configuration file to download data from the QuantConnect API, alias for --data-provider-historical {QuantConnectDataProvider.get_name()}") @option("--data-purchase-limit", type=int, - help="The maximum amount of QCC to spend on downloading data during the research session when using QuantConnect as data provider historical") + help="The maximum amount of QCC to spend on downloading data during the research session when using QuantConnect as historical data provider") @option("--detach", "-d", is_flag=True, default=False, diff --git a/lean/components/api/live_client.py b/lean/components/api/live_client.py index 827f2ebe..7548bc4f 100644 --- a/lean/components/api/live_client.py +++ b/lean/components/api/live_client.py @@ -71,7 +71,7 @@ def start(self, :param compile_id: the id of the compile to use for live trading :param node_id: the id of the node to start live trading on :param brokerage_settings: the brokerage settings to use - :param price_data_handler: the data provider live to use + :param price_data_handler: the live data provider to use :param automatic_redeploy: whether automatic redeploys are enabled :param version_id: the id of the LEAN version to use :param notify_order_events: whether notifications should be sent on order events diff --git a/lean/components/config/lean_config_manager.py b/lean/components/config/lean_config_manager.py index 9de61811..26622d5d 100644 --- a/lean/components/config/lean_config_manager.py +++ b/lean/components/config/lean_config_manager.py @@ -297,7 +297,7 @@ def get_complete_lean_config(self, def configure_data_purchase_limit(self, lean_config: Dict[str, Any], data_purchase_limit: Optional[int]) -> None: """Updates the data purchase limit in the Lean config. - Logs a warning if the data provider historical is not configured to download from QuantConnect. + Logs a warning if the historical data provider is not configured to download from QuantConnect. :param lean_config: the Lean config dict to update :param data_purchase_limit: the data purchase limit provided by the user, or None if no such limit was provided @@ -307,7 +307,7 @@ def configure_data_purchase_limit(self, lean_config: Dict[str, Any], data_purcha if lean_config.get("data-provider", None) != "QuantConnect.Lean.Engine.DataFeeds.ApiDataProvider": self._logger.warn( - "--data-purchase-limit is ignored because the data provider historical is not set to download from the QuantConnect API, use --download-data to set that up") + "--data-purchase-limit is ignored because the historical data provider is not set to download from the QuantConnect API, use --download-data to set that up") return lean_config["data-purchase-limit"] = data_purchase_limit diff --git a/lean/models/brokerages/cloud/cloud_brokerage.py b/lean/models/brokerages/cloud/cloud_brokerage.py index a00b2dea..1c30aea7 100644 --- a/lean/models/brokerages/cloud/cloud_brokerage.py +++ b/lean/models/brokerages/cloud/cloud_brokerage.py @@ -75,7 +75,7 @@ def get_settings(self) -> Dict[str, str]: return settings def get_price_data_handler(self) -> str: - """Returns the price data provider live handler to use. + """Returns the price live data provider handler to use. :return: the value to assign to the "dataHandler" property of the live/create API endpoint """ # TODO: Handle this case with json conditions diff --git a/lean/models/brokerages/local/data_feed.py b/lean/models/brokerages/local/data_feed.py index 54defe9b..10a8dec8 100644 --- a/lean/models/brokerages/local/data_feed.py +++ b/lean/models/brokerages/local/data_feed.py @@ -16,7 +16,7 @@ class DataFeed(LeanConfigConfigurer): - """A JsonModule implementation for the Json data provider live module.""" + """A JsonModule implementation for the Json live data provider module.""" def __init__(self, json_datafeed_data: Dict[str, Any]) -> None: super().__init__(json_datafeed_data) diff --git a/lean/models/data_providers/data_provider.py b/lean/models/data_providers/data_provider.py index c3c67ee8..9bc37372 100644 --- a/lean/models/data_providers/data_provider.py +++ b/lean/models/data_providers/data_provider.py @@ -15,7 +15,7 @@ from lean.models.lean_config_configurer import LeanConfigConfigurer class DataProvider(LeanConfigConfigurer): - """A JsonModule implementation for the Json data provider module.""" + """A JsonModule implementation for the Json historical data provider module.""" def __init__(self, json_data_provider_data: Dict[str, Any]) -> None: super().__init__(json_data_provider_data) diff --git a/tests/commands/cloud/live/test_cloud_live_commands.py b/tests/commands/cloud/live/test_cloud_live_commands.py index 6c1cd888..44fda70c 100644 --- a/tests/commands/cloud/live/test_cloud_live_commands.py +++ b/tests/commands/cloud/live/test_cloud_live_commands.py @@ -114,7 +114,7 @@ def test_cloud_live_deploy_with_ib_using_hybrid_datafeed() -> None: "--ib-account", "DU2366417", "--ib-password", "test_password"]) assert result.exit_code == 0 - assert "Data provider live: quantconnecthandler+interactivebrokershandler" in result.output.split("\n") + assert "Live data provider: quantconnecthandler+interactivebrokershandler" in result.output.split("\n") def test_cloud_live_deploy_with_tradier_using_tradier_datafeed() -> None: create_fake_lean_cli_directory() @@ -135,7 +135,7 @@ def test_cloud_live_deploy_with_tradier_using_tradier_datafeed() -> None: "--tradier-access-token", "456", "--tradier-environment", "paper"]) assert result.exit_code == 0 - assert "Data provider live: TradierBrokerage" in result.output.split("\n") + assert "Live data provider: TradierBrokerage" in result.output.split("\n") @pytest.mark.parametrize("notice_method,configs", [("emails", "customAddress:customSubject"), ("emails", "customAddress1:customSubject1,customAddress2:customSubject2"), From cc157fe4b672136c2fdc5023c949cb4c7af47381 Mon Sep 17 00:00:00 2001 From: Romazes Date: Wed, 7 Feb 2024 20:53:02 +0200 Subject: [PATCH 4/4] feat: update README --- README.md | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 0118c109..061f422c 100644 --- a/README.md +++ b/README.md @@ -143,8 +143,8 @@ Options: -d, --detach Run the backtest in a detached Docker container and return immediately --debug [pycharm|ptvsd|vsdbg|rider|local-platform] Enable a certain debugging method (see --help for more information) - --data-provider [IQFeed|Polygon|IEX|AlphaVantage|QuantConnect|Local|Terminal Link] - Update the Lean configuration file to retrieve data from the given provider + --data-provider-historical [IQFeed|Polygon|IEX|AlphaVantage|QuantConnect|Local|Terminal Link] + Update the Lean configuration file to retrieve data from the given historical provider --iqfeed-iqconnect TEXT The path to the IQConnect binary --iqfeed-username TEXT Your IQFeed username --iqfeed-password TEXT Your IQFeed password @@ -170,9 +170,9 @@ Options: --terminal-link-openfigi-api-key TEXT The Open FIGI API key to use for mapping options --download-data Update the Lean configuration file to download data from the QuantConnect API, alias - for --data-provider QuantConnect + for --data-provider-historical QuantConnect --data-purchase-limit INTEGER The maximum amount of QCC to spend on downloading data during the backtest when using - QuantConnect as data provider + QuantConnect as historical data provider --release Compile C# projects in release configuration instead of debug --image TEXT The LEAN engine image to use (defaults to quantconnect/lean:latest) --python-venv TEXT The path of the python virtual environment to be used @@ -1043,15 +1043,15 @@ Usage: lean live deploy [OPTIONS] PROJECT If PROJECT is a directory, the algorithm in the main.py or Main.cs file inside it will be executed. If PROJECT is a file, the algorithm in the specified file will be executed. - By default an interactive wizard is shown letting you configure the brokerage and data feed to use. If --environment, - --brokerage or --data-feed are given the command runs in non-interactive mode. In this mode the CLI does not prompt - for input. + By default an interactive wizard is shown letting you configure the brokerage and live data provider to use. If + --environment, --brokerage or --data-provider-live are given the command runs in non-interactive mode. In this mode + the CLI does not prompt for input. If --environment is given it must be the name of a live environment in the Lean configuration. - If --brokerage and --data-feed are given, the options specific to the given brokerage/data feed must also be given. - The Lean config is used as fallback when a brokerage/data feed-specific option hasn't been passed in. If a required - option is not given and cannot be found in the Lean config the command aborts. + If --brokerage and --data-provider-live are given, the options specific to the given brokerage/live data provider must + also be given. The Lean config is used as fallback when a brokerage/live data provider-specific option hasn't been + passed in. If a required option is not given and cannot be found in the Lean config the command aborts. By default the official LEAN engine image is used. You can override this using the --image option. Alternatively you can set the default engine image for all commands using `lean config set engine-image `. @@ -1062,10 +1062,10 @@ Options: -d, --detach Run the live deployment in a detached Docker container and return immediately --brokerage [Paper Trading|Interactive Brokers|Tradier|Oanda|Bitfinex|Coinbase Advanced Trade|Binance|Zerodha|Samco|Terminal Link|Trading Technologies|Kraken|TDAmeritrade|Bybit] The brokerage to use - --data-feed [Interactive Brokers|Tradier|Oanda|Bitfinex|Coinbase Advanced Trade|Binance|Zerodha|Samco|Terminal Link|Kraken|TDAmeritrade|IQFeed|Polygon|IEX|Custom data only|Bybit] - The data feed to use - --data-provider [IQFeed|Polygon|IEX|AlphaVantage|QuantConnect|Local] - Update the Lean configuration file to retrieve data from the given provider + --data-provider-live [Interactive Brokers|Tradier|Oanda|Bitfinex|Coinbase Advanced Trade|Binance|Zerodha|Samco|Terminal Link|Kraken|TDAmeritrade|IQFeed|Polygon|IEX|Custom data only|Bybit] + The live data provider to use + --data-provider-historical [IQFeed|Polygon|IEX|AlphaVantage|QuantConnect|Local] + Update the Lean configuration file to retrieve data from the given historical provider --ib-user-name TEXT Your Interactive Brokers username --ib-account TEXT Your Interactive Brokers account id --ib-password TEXT Your Interactive Brokers password @@ -1466,10 +1466,10 @@ Options: --parameter ... The 'parameter min max step' pairs configuring the parameters to optimize --constraint TEXT The 'statistic operator value' pairs configuring the constraints of the optimization - --data-provider [IQFeed|Polygon|IEX|AlphaVantage|QuantConnect|Local|Terminal Link] - Update the Lean configuration file to retrieve data from the given provider + --data-provider-historical [IQFeed|Polygon|IEX|AlphaVantage|QuantConnect|Local|Terminal Link] + Update the Lean configuration file to retrieve data from the given historical provider --download-data Update the Lean configuration file to download data from the QuantConnect API, alias - for --data-provider QuantConnect + for --data-provider-historical QuantConnect --release Compile C# projects in release configuration instead of debug --image TEXT The LEAN engine image to use (defaults to quantconnect/lean:latest) --update Pull the LEAN engine image before running the optimizer @@ -1606,8 +1606,8 @@ Usage: lean research [OPTIONS] PROJECT Options: --port INTEGER The port to run Jupyter Lab on (defaults to 8888) - --data-provider [IQFeed|Polygon|IEX|AlphaVantage|QuantConnect|Local|Terminal Link] - Update the Lean configuration file to retrieve data from the given provider + --data-provider-historical [IQFeed|Polygon|IEX|AlphaVantage|QuantConnect|Local|Terminal Link] + Update the Lean configuration file to retrieve data from the given historical provider --iqfeed-iqconnect TEXT The path to the IQConnect binary --iqfeed-username TEXT Your IQFeed username --iqfeed-password TEXT Your IQFeed password @@ -1633,9 +1633,9 @@ Options: --terminal-link-openfigi-api-key TEXT The Open FIGI API key to use for mapping options --download-data Update the Lean configuration file to download data from the QuantConnect API, alias - for --data-provider QuantConnect + for --data-provider-historical QuantConnect --data-purchase-limit INTEGER The maximum amount of QCC to spend on downloading data during the research session - when using QuantConnect as data provider + when using QuantConnect as historical data provider -d, --detach Run Jupyter Lab in a detached Docker container and return immediately --no-open Don't open the Jupyter Lab environment in the browser after starting it --image TEXT The LEAN research image to use (defaults to quantconnect/research:latest)