Skip to content

Commit

Permalink
add helper methods to fetch backtest-name, container
Browse files Browse the repository at this point in the history
  • Loading branch information
rjra2611 committed Jul 26, 2022
1 parent 0fa60f7 commit f096b92
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lean/components/config/output_config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,32 @@ def get_backtest_id(self, backtest_directory: Path) -> int:
"""
return self._get_id(backtest_directory, 1)

def get_backtest_name(self, backtest_directory: Path) -> int:
"""Returns the name of a backtest.
:param backtest_directory: the path to the backtest to retrieve the id of
:return: the name of the given backtest
"""
config = self.get_output_config(backtest_directory)

if config.has("backtest-name"):
return config.get("backtest-name")

raise ValueError("Backtest name is not set")

def get_container_name(self, backtest_directory: Path) -> int:
"""Returns the name of a the docker container lean is running in.
:param backtest_directory: the path to the backtest to retrieve the id of
:return: the name of the docker container lean is running in.
"""
config = self.get_output_config(backtest_directory)

if config.has("container"):
return config.get("container")

raise ValueError("Container name is not set")

def get_backtest_by_id(self, backtest_id: int, root_directory: Optional[Path] = None) -> Path:
"""Finds the directory of a backtest by its id.
Expand Down

0 comments on commit f096b92

Please sign in to comment.