Skip to content

Commit

Permalink
address requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Marinovsky committed Jul 11, 2024
1 parent 53bd786 commit 5f35241
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
10 changes: 2 additions & 8 deletions lean/components/api/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,15 @@ 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,
auth=(self._user_id, password),
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)
Expand Down
2 changes: 0 additions & 2 deletions lean/components/api/live_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 3 additions & 7 deletions lean/components/util/live_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5f35241

Please sign in to comment.