Skip to content

Commit

Permalink
Merge pull request #32 from QuantConnect/refactor-rename-plugin-termi…
Browse files Browse the repository at this point in the history
…nal-link

Rename plugin to Terminal Link
  • Loading branch information
Martin-Molinero authored Oct 5, 2021
2 parents c1051bd + e793a2c commit d154ddd
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 73 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ __pycache__/
# C extensions
*.so

# JetBrains Rider
.idea/

# Distribution / packaging
.Python
build/
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
62 changes: 31 additions & 31 deletions lean/commands/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions lean/components/docker/lean_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions lean/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lean/models/brokerages/local/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,7 +40,7 @@
CoinbaseProBrokerage,
BinanceBrokerage,
ZerodhaBrokerage,
BloombergBrokerage,
TerminalLinkBrokerage,
AtreyuBrokerage,
TradingTechnologiesBrokerage
]
Expand All @@ -53,7 +53,7 @@
CoinbaseProDataFeed,
BinanceDataFeed,
ZerodhaDataFeed,
BloombergDataFeed,
TerminalLinkDataFeed,
TradingTechnologiesDataFeed,
CustomDataOnlyDataFeed
]
Expand All @@ -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]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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"),
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions lean/models/data_providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Loading

0 comments on commit d154ddd

Please sign in to comment.