Skip to content

Commit

Permalink
rename: data-provider and data-feed
Browse files Browse the repository at this point in the history
  • Loading branch information
Romazes committed Feb 7, 2024
1 parent bab821e commit 42d3754
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 46 deletions.
14 changes: 7 additions & 7 deletions lean/commands/backtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,18 @@ 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")
@options_from_json(get_configs_for_options("backtest"))
@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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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")

Expand Down
8 changes: 4 additions & 4 deletions lean/commands/cloud/live/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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'}")
Expand Down
34 changes: 17 additions & 17 deletions lean/commands/live/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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],
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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)

Expand All @@ -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"]:
Expand Down Expand Up @@ -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)

Expand Down
12 changes: 6 additions & 6 deletions lean/commands/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions lean/commands/research.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ 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")
@options_from_json(get_configs_for_options("research"))
@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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion lean/components/api/live_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lean/components/config/lean_config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lean/models/brokerages/cloud/cloud_brokerage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lean/models/brokerages/local/data_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 42d3754

Please sign in to comment.