From 5f35241bf92168cfa4f7b53a5be270e375a8e479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Andr=C3=A9s=20Marino=20Rojas?= <47573394+Marinovsky@users.noreply.github.com> Date: Wed, 10 Jul 2024 17:41:54 -0500 Subject: [PATCH] address requested changes --- lean/components/api/api_client.py | 10 ++-------- lean/components/api/live_client.py | 2 -- lean/components/util/live_utils.py | 10 +++------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/lean/components/api/api_client.py b/lean/components/api/api_client.py index 48e578b3..c6787c75 100644 --- a/lean/components/api/api_client.py +++ b/lean/components/api/api_client.py @@ -142,12 +142,6 @@ def _request(self, method: str, endpoint: str, options: Dict[str, Any] = {}, ret version = 99999999 headers["User-Agent"] = f"Lean CLI {version}" - self._logger.info(f'full_url: {full_url}') - self._logger.info(f'headers: {headers}') - self._logger.info(f'self._user_id: {self._user_id}') - self._logger.info(f'password: {password}') - self._logger.info(f'options: {options}') - response = self._http_client.request(method, full_url, headers=headers, @@ -155,8 +149,8 @@ def _request(self, method: str, endpoint: str, options: Dict[str, Any] = {}, ret raise_for_status=False, **options) - self._logger.debug(f"Request response: {response.text}") - # if self._logger.debug_logging_enabled: + if self._logger.debug_logging_enabled: + self._logger.debug(f"Request response: {response.text}") if 500 <= response.status_code < 600 and retry_http_5xx: return self._request(method, endpoint, options, False) diff --git a/lean/components/api/live_client.py b/lean/components/api/live_client.py index f5872e6f..b04c6506 100644 --- a/lean/components/api/live_client.py +++ b/lean/components/api/live_client.py @@ -37,8 +37,6 @@ def get_project_by_id(self, :param project_id: the project id :return: a live algorithm which match the given filters """ - from lean.container import container - parameters = {"projectId": project_id} if status is not None: diff --git a/lean/components/util/live_utils.py b/lean/components/util/live_utils.py index 28ce2f32..bf4c0eec 100644 --- a/lean/components/util/live_utils.py +++ b/lean/components/util/live_utils.py @@ -26,10 +26,6 @@ def _get_last_portfolio(api_client: APIClient, project_id: str, project_name: Pa from datetime import datetime from lean.container import container - if not project_id: - # Project is not initialized in the cloud, hence project_id is None - return None - cloud_deployment = api_client.get("live/read", {"projectId": project_id}) container.logger.info(f'----- After cloud_deployment_list: {cloud_deployment}') cloud_last_time = utc.localize(datetime.min) @@ -73,11 +69,11 @@ def get_last_portfolio_cash_holdings(api_client: APIClient, brokerage_instance: from lean.container import container last_cash = [] last_holdings = [] - container.logger.info(f'brokerage_instance: {brokerage_instance}') + container.logger.debug(f'brokerage_instance: {brokerage_instance}') cash_balance_option = brokerage_instance._initial_cash_balance holdings_option = brokerage_instance._initial_holdings - container.logger.info(f'cash_balance_option: {cash_balance_option}') - container.logger.info(f'holdings_option: {holdings_option}') + container.logger.debug(f'cash_balance_option: {cash_balance_option}') + container.logger.debug(f'holdings_option: {holdings_option}') if cash_balance_option != LiveInitialStateInput.NotSupported or holdings_option != LiveInitialStateInput.NotSupported: last_portfolio = _get_last_portfolio(api_client, project_id, project) last_cash = last_portfolio["cash"] if last_portfolio else None