diff --git a/.gitignore b/.gitignore index a81c8ee1..35b2382f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ __pycache__/ # C extensions *.so +# JetBrains Rider +.idea/ + # Distribution / packaging .Python build/ diff --git a/README.md b/README.md index 49f298ce..40508192 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ Options: -d, --detach Run the backtest in a detached Docker container and return immediately --debug [pycharm|ptvsd|vsdbg|rider] Enable a certain debugging method (see --help for more information) - --data-provider [Local|QuantConnect|Bloomberg] + --data-provider [Local|QuantConnect|Terminal Link] Update the Lean configuration file to retrieve data from the given provider --download-data Update the Lean configuration file to download data from the QuantConnect API, alias for --data-provider QuantConnect @@ -720,9 +720,9 @@ Options: -d, --detach Run the live deployment in a detached Docker container and return immediately --gui Enable monitoring and controlling of the deployment via the local GUI --gui-organization TEXT The name or id of the organization with the local GUI module subscription - --brokerage [Paper Trading|Interactive Brokers|Tradier|OANDA|Bitfinex|Coinbase Pro|Binance|Zerodha|Bloomberg|Atreyu|Trading Technologies] + --brokerage [Paper Trading|Interactive Brokers|Tradier|OANDA|Bitfinex|Coinbase Pro|Binance|Zerodha|Terminal Link|Atreyu|Trading Technologies] The brokerage to use - --data-feed [Interactive Brokers|Tradier|OANDA|Bitfinex|Coinbase Pro|Binance|Zerodha|Bloomberg|Trading Technologies|Custom data only|IQFeed] + --data-feed [Interactive Brokers|Tradier|OANDA|Bitfinex|Coinbase Pro|Binance|Zerodha|Terminal Link|Trading Technologies|Custom data only|IQFeed] The data feed to use --ib-user-name TEXT Your Interactive Brokers username --ib-account TEXT Your Interactive Brokers account id @@ -764,7 +764,7 @@ Options: --iqfeed-password TEXT Your IQFeed password --iqfeed-product-name TEXT The product name of your IQFeed developer account --iqfeed-version TEXT The product version of your IQFeed developer account - --bloomberg-organization TEXT The name or id of the organization with the Bloomberg module subscription + --terminal-link-organization TEXT The name or id of the organization with the Terminal Link module subscription --bloomberg-environment [Production|Beta] The environment to run in --bloomberg-server-host TEXT The host of the Bloomberg server @@ -987,7 +987,7 @@ Usage: lean research [OPTIONS] PROJECT Options: --port INTEGER The port to run Jupyter Lab on (defaults to 8888) - --data-provider [Local|QuantConnect|Bloomberg] + --data-provider [Local|QuantConnect|Terminal Link] Update the Lean configuration file to retrieve data from the given provider --download-data Update the Lean configuration file to download data from the QuantConnect API, alias for --data-provider QuantConnect diff --git a/lean/commands/live.py b/lean/commands/live.py index a0f0715e..0b0fcd87 100644 --- a/lean/commands/live.py +++ b/lean/commands/live.py @@ -26,7 +26,7 @@ from lean.models.brokerages.local.atreyu import AtreyuBrokerage from lean.models.brokerages.local.binance import BinanceBrokerage, BinanceDataFeed from lean.models.brokerages.local.bitfinex import BitfinexBrokerage, BitfinexDataFeed -from lean.models.brokerages.local.bloomberg import BloombergBrokerage, BloombergDataFeed +from lean.models.brokerages.local.terminal_link import TerminalLinkBrokerage, TerminalLinkDataFeed from lean.models.brokerages.local.coinbase_pro import CoinbaseProBrokerage, CoinbaseProDataFeed from lean.models.brokerages.local.interactive_brokers import InteractiveBrokersBrokerage, InteractiveBrokersDataFeed from lean.models.brokerages.local.iqfeed import IQFeedDataFeed @@ -378,10 +378,10 @@ def _get_default_value(key: str) -> Optional[Any]: type=str, default=lambda: _get_default_value("iqfeed-version"), help="The product version of your IQFeed developer account") -@click.option("--bloomberg-organization", +@click.option("--terminal-link-organization", type=str, default=lambda: _get_default_value("job-organization-id"), - help="The name or id of the organization with the Bloomberg module subscription") + help="The name or id of the organization with the Terminal Link module subscription") @click.option("--bloomberg-environment", type=click.Choice(["Production", "Beta"], case_sensitive=False), default=lambda: _get_default_value("bloomberg-environment"), @@ -574,7 +574,7 @@ def live(project: Path, iqfeed_password: Optional[str], iqfeed_product_name: Optional[str], iqfeed_version: Optional[str], - bloomberg_organization: Optional[str], + terminal_link_organization: Optional[str], bloomberg_environment: Optional[str], bloomberg_server_host: Optional[str], bloomberg_server_port: Optional[int], @@ -698,24 +698,24 @@ def live(project: Path, zerodha_access_token, zerodha_product_type, zerodha_trading_segment) - elif brokerage == BloombergBrokerage.get_name(): + elif brokerage == TerminalLinkBrokerage.get_name(): ensure_options(["bloomberg_environment", "bloomberg_server_host", "bloomberg_server_port", "bloomberg_emsx_broker", "bloomberg_allow_modification"]) - brokerage_configurer = BloombergBrokerage(_get_organization_id(bloomberg_organization, "Bloomberg"), - bloomberg_environment, - bloomberg_server_host, - bloomberg_server_port, - bloomberg_symbol_map_file, - bloomberg_emsx_broker, - bloomberg_emsx_user_time_zone, - bloomberg_emsx_account, - bloomberg_emsx_strategy, - bloomberg_emsx_notes, - bloomberg_emsx_handling, - bloomberg_allow_modification) + brokerage_configurer = TerminalLinkBrokerage(_get_organization_id(terminal_link_organization, "Terminal Link"), + bloomberg_environment, + bloomberg_server_host, + bloomberg_server_port, + bloomberg_symbol_map_file, + bloomberg_emsx_broker, + bloomberg_emsx_user_time_zone, + bloomberg_emsx_account, + bloomberg_emsx_strategy, + bloomberg_emsx_notes, + bloomberg_emsx_handling, + bloomberg_allow_modification) elif brokerage == AtreyuBrokerage.get_name(): ensure_options(["atreyu_host", "atreyu_req_port", @@ -809,25 +809,25 @@ def live(project: Path, zerodha_product_type, zerodha_trading_segment), zerodha_history_subscription) - elif data_feed == BloombergDataFeed.get_name(): + elif data_feed == TerminalLinkDataFeed.get_name(): ensure_options(["bloomberg_environment", "bloomberg_server_host", "bloomberg_server_port", "bloomberg_emsx_broker", "bloomberg_allow_modification"]) - data_feed_configurer = BloombergDataFeed(BloombergBrokerage(_get_organization_id(bloomberg_organization, - "Bloomberg"), - bloomberg_environment, - bloomberg_server_host, - bloomberg_server_port, - bloomberg_symbol_map_file, - bloomberg_emsx_broker, - bloomberg_emsx_user_time_zone, - bloomberg_emsx_account, - bloomberg_emsx_strategy, - bloomberg_emsx_notes, - bloomberg_emsx_handling, - bloomberg_allow_modification)) + data_feed_configurer = TerminalLinkDataFeed(TerminalLinkBrokerage(_get_organization_id(terminal_link_organization, + "Terminal Link"), + bloomberg_environment, + bloomberg_server_host, + bloomberg_server_port, + bloomberg_symbol_map_file, + bloomberg_emsx_broker, + bloomberg_emsx_user_time_zone, + bloomberg_emsx_account, + bloomberg_emsx_strategy, + bloomberg_emsx_notes, + bloomberg_emsx_handling, + bloomberg_allow_modification)) elif data_feed == TradingTechnologiesDataFeed.get_name(): ensure_options(["tt_user_name", "tt_session_password", diff --git a/lean/components/docker/lean_runner.py b/lean/components/docker/lean_runner.py index e3370e73..404bdf38 100644 --- a/lean/components/docker/lean_runner.py +++ b/lean/components/docker/lean_runner.py @@ -31,7 +31,7 @@ from lean.components.util.project_manager import ProjectManager from lean.components.util.temp_manager import TempManager from lean.components.util.xml_manager import XMLManager -from lean.constants import MODULES_DIRECTORY, BLOOMBERG_PRODUCT_ID +from lean.constants import MODULES_DIRECTORY, TERMINAL_LINK_PRODUCT_ID from lean.models.config import DebuggingMethod from lean.models.docker import DockerImage @@ -180,7 +180,7 @@ def get_basic_docker_config(self, # Install the required modules when they're needed if lean_config.get("data-provider", None) == "QuantConnect.Lean.Engine.DataFeeds.DownloaderDataProvider" \ and lean_config.get("data-downloader", None) == "BloombergDataDownloader": - self._module_manager.install_module(BLOOMBERG_PRODUCT_ID, lean_config["job-organization-id"]) + self._module_manager.install_module(TERMINAL_LINK_PRODUCT_ID, lean_config["job-organization-id"]) # Force the use of the LocalDisk map/factor providers if no recent zip present and not using ApiDataProvider data_dir = self._lean_config_manager.get_data_directory() diff --git a/lean/constants.py b/lean/constants.py index ece415c3..37e23923 100644 --- a/lean/constants.py +++ b/lean/constants.py @@ -72,8 +72,8 @@ # The product id of the Security Master subscription SECURITY_MASTER_PRODUCT_ID = 37 -# The product id of the Bloomberg module -BLOOMBERG_PRODUCT_ID = 44 +# The product id of the Terminal Link module +TERMINAL_LINK_PRODUCT_ID = 44 # The product id of the Trading Technologies module TRADING_TECHNOLOGIES_PRODUCT_ID = 64 diff --git a/lean/models/brokerages/local/__init__.py b/lean/models/brokerages/local/__init__.py index 85a974c4..8b1a520a 100644 --- a/lean/models/brokerages/local/__init__.py +++ b/lean/models/brokerages/local/__init__.py @@ -19,7 +19,7 @@ from lean.models.brokerages.local.base import LocalBrokerage from lean.models.brokerages.local.binance import BinanceBrokerage, BinanceDataFeed from lean.models.brokerages.local.bitfinex import BitfinexBrokerage, BitfinexDataFeed -from lean.models.brokerages.local.bloomberg import BloombergBrokerage, BloombergDataFeed +from lean.models.brokerages.local.terminal_link import TerminalLinkBrokerage, TerminalLinkDataFeed from lean.models.brokerages.local.coinbase_pro import CoinbaseProBrokerage, CoinbaseProDataFeed from lean.models.brokerages.local.custom_data_only import CustomDataOnlyDataFeed from lean.models.brokerages.local.interactive_brokers import InteractiveBrokersBrokerage, InteractiveBrokersDataFeed @@ -40,7 +40,7 @@ CoinbaseProBrokerage, BinanceBrokerage, ZerodhaBrokerage, - BloombergBrokerage, + TerminalLinkBrokerage, AtreyuBrokerage, TradingTechnologiesBrokerage ] @@ -53,7 +53,7 @@ CoinbaseProDataFeed, BinanceDataFeed, ZerodhaDataFeed, - BloombergDataFeed, + TerminalLinkDataFeed, TradingTechnologiesDataFeed, CustomDataOnlyDataFeed ] @@ -67,7 +67,7 @@ CoinbaseProBrokerage: [CoinbaseProDataFeed], BinanceBrokerage: [BinanceDataFeed], ZerodhaBrokerage: [ZerodhaDataFeed], - BloombergBrokerage: [BloombergDataFeed], + TerminalLinkBrokerage: [TerminalLinkDataFeed], AtreyuBrokerage: [x for x in all_local_data_feeds if x != CustomDataOnlyDataFeed], TradingTechnologiesBrokerage: [TradingTechnologiesDataFeed] } diff --git a/lean/models/brokerages/local/bloomberg.py b/lean/models/brokerages/local/terminal_link.py similarity index 85% rename from lean/models/brokerages/local/bloomberg.py rename to lean/models/brokerages/local/terminal_link.py index 7c622241..44812d65 100644 --- a/lean/models/brokerages/local/bloomberg.py +++ b/lean/models/brokerages/local/terminal_link.py @@ -18,13 +18,13 @@ from lean.click import PathParameter from lean.components.util.logger import Logger -from lean.constants import BLOOMBERG_PRODUCT_ID +from lean.constants import TERMINAL_LINK_PRODUCT_ID from lean.container import container from lean.models.brokerages.local.base import LeanConfigConfigurer, LocalBrokerage from lean.models.logger import Option -class BloombergBrokerage(LocalBrokerage): +class TerminalLinkBrokerage(LocalBrokerage): """A LocalBrokerage implementation for the Bloomberg brokerage.""" _is_module_installed = False @@ -57,7 +57,7 @@ def __init__(self, @classmethod def get_name(cls) -> str: - return "Bloomberg" + return "Terminal Link" @classmethod def _build(cls, lean_config: Dict[str, Any], logger: Logger) -> LocalBrokerage: @@ -66,7 +66,7 @@ def _build(cls, lean_config: Dict[str, Any], logger: Logger) -> LocalBrokerage: organizations = api_client.organizations.get_all() options = [Option(id=organization.id, label=organization.name) for organization in organizations] - organization_id = logger.prompt_list("Select the organization with the Bloomberg module subscription", options) + organization_id = logger.prompt_list("Select the organization with the Terminal Link module subscription", options) environment = click.prompt("Environment", cls._get_default(lean_config, "bloomberg-environment"), @@ -91,18 +91,18 @@ def _build(cls, lean_config: Dict[str, Any], logger: Logger) -> LocalBrokerage: cls._get_default(lean_config, "bloomberg-allow-modification"), type=bool) - return BloombergBrokerage(organization_id, - environment, - server_host, - server_port, - symbol_map_file, - emsx_broker, - emsx_user_time_zone, - emsx_account, - emsx_strategy, - emsx_notes, - emsx_handling, - allow_modification) + return TerminalLinkBrokerage(organization_id, + environment, + server_host, + server_port, + symbol_map_file, + emsx_broker, + emsx_user_time_zone, + emsx_account, + emsx_strategy, + emsx_notes, + emsx_handling, + allow_modification) def _configure_environment(self, lean_config: Dict[str, Any], environment_name: str) -> None: self.ensure_module_installed() @@ -147,23 +147,23 @@ def configure_credentials(self, lean_config: Dict[str, Any]) -> None: def ensure_module_installed(self) -> None: if not self._is_module_installed: - container.module_manager().install_module(BLOOMBERG_PRODUCT_ID, self._organization_id) + container.module_manager().install_module(TERMINAL_LINK_PRODUCT_ID, self._organization_id) self._is_module_installed = True -class BloombergDataFeed(LeanConfigConfigurer): - """A LeanConfigConfigurer implementation for the Bloomberg data feed.""" +class TerminalLinkDataFeed(LeanConfigConfigurer): + """A LeanConfigConfigurer implementation for the Terminal Link data feed.""" - def __init__(self, brokerage: BloombergBrokerage) -> None: + def __init__(self, brokerage: TerminalLinkBrokerage) -> None: self._brokerage = brokerage @classmethod def get_name(cls) -> str: - return BloombergBrokerage.get_name() + return TerminalLinkBrokerage.get_name() @classmethod def build(cls, lean_config: Dict[str, Any], logger: Logger) -> LeanConfigConfigurer: - return BloombergDataFeed(BloombergBrokerage.build(lean_config, logger)) + return TerminalLinkDataFeed(TerminalLinkBrokerage.build(lean_config, logger)) def configure(self, lean_config: Dict[str, Any], environment_name: str) -> None: self._brokerage.ensure_module_installed() diff --git a/lean/models/data_providers/__init__.py b/lean/models/data_providers/__init__.py index b07554ec..de4bb5ed 100644 --- a/lean/models/data_providers/__init__.py +++ b/lean/models/data_providers/__init__.py @@ -11,12 +11,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -from lean.models.data_providers.bloomberg import BloombergDataProvider +from lean.models.data_providers.terminal_link import TerminalLinkDataProvider from lean.models.data_providers.local import LocalDataProvider from lean.models.data_providers.quantconnect import QuantConnectDataProvider all_data_providers = [ LocalDataProvider, QuantConnectDataProvider, - BloombergDataProvider + TerminalLinkDataProvider ] diff --git a/lean/models/data_providers/bloomberg.py b/lean/models/data_providers/terminal_link.py similarity index 85% rename from lean/models/data_providers/bloomberg.py rename to lean/models/data_providers/terminal_link.py index 0f08f0c7..d59441b9 100644 --- a/lean/models/data_providers/bloomberg.py +++ b/lean/models/data_providers/terminal_link.py @@ -14,21 +14,21 @@ from typing import Dict, Any from lean.components.util.logger import Logger -from lean.models.brokerages.local import BloombergBrokerage +from lean.models.brokerages.local import TerminalLinkBrokerage from lean.models.config import LeanConfigConfigurer -class BloombergDataProvider(LeanConfigConfigurer): - def __init__(self, brokerage: BloombergBrokerage) -> None: +class TerminalLinkDataProvider(LeanConfigConfigurer): + def __init__(self, brokerage: TerminalLinkBrokerage) -> None: self._brokerage = brokerage @classmethod def get_name(cls) -> str: - return "Bloomberg" + return "Terminal Link" @classmethod def build(cls, lean_config: Dict[str, Any], logger: Logger) -> LeanConfigConfigurer: - return BloombergDataProvider(BloombergBrokerage.build(lean_config, logger)) + return TerminalLinkDataProvider(TerminalLinkBrokerage.build(lean_config, logger)) def configure(self, lean_config: Dict[str, Any], environment_name: str) -> None: self._brokerage.configure_credentials(lean_config)