From f72835d43c007ec370dd4481f342b58529decb65 Mon Sep 17 00:00:00 2001 From: cardosofede Date: Mon, 9 Oct 2023 16:53:04 -0300 Subject: [PATCH 1/5] (feat) remove directional strategies card --- .../directional_strategies_file_explorer.py | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 ui_components/directional_strategies_file_explorer.py diff --git a/ui_components/directional_strategies_file_explorer.py b/ui_components/directional_strategies_file_explorer.py deleted file mode 100644 index 2a93988f..00000000 --- a/ui_components/directional_strategies_file_explorer.py +++ /dev/null @@ -1,16 +0,0 @@ -from streamlit_elements import mui - -import constants -from ui_components.file_explorer_base import FileExplorerBase -from utils.os_utils import get_python_files_from_directory - - -class DirectionalStrategiesFileExplorer(FileExplorerBase): - def add_tree_view(self): - with mui.lab.TreeView(defaultExpandIcon=mui.icon.ChevronRight, defaultCollapseIcon=mui.icon.ExpandMore, - onNodeSelect=lambda event, node_id: self.set_selected_file(event, node_id), - defaultExpanded=["directional_strategies"]): - with mui.lab.TreeItem(nodeId="directional_strategies", label=f"⚔️Directional Strategies"): - strategies = get_python_files_from_directory(constants.CONTROLLERS_PATH) - for strategy in strategies: - mui.lab.TreeItem(nodeId=strategy, label=f"🐍{strategy.split('/')[-1]}") From 3614149cbda26374b8abbc56c3584c345faf8722 Mon Sep 17 00:00:00 2001 From: cardosofede Date: Mon, 9 Oct 2023 16:53:14 -0300 Subject: [PATCH 2/5] (feat) add general controllers explorer --- ui_components/controllers_file_explorer.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 ui_components/controllers_file_explorer.py diff --git a/ui_components/controllers_file_explorer.py b/ui_components/controllers_file_explorer.py new file mode 100644 index 00000000..3940c77a --- /dev/null +++ b/ui_components/controllers_file_explorer.py @@ -0,0 +1,21 @@ +from streamlit_elements import mui + +import constants +from ui_components.file_explorer_base import FileExplorerBase +from utils.os_utils import get_python_files_from_directory, load_controllers + + +class ControllersFileExplorer(FileExplorerBase): + def add_tree_view(self): + with mui.lab.TreeView(defaultExpandIcon=mui.icon.ChevronRight, defaultCollapseIcon=mui.icon.ExpandMore, + onNodeSelect=lambda event, node_id: self.set_selected_file(event, node_id), + defaultExpanded=["directional_strategies"]): + available_controllers = load_controllers(constants.CONTROLLERS_PATH) + with mui.lab.TreeItem(nodeId="directional_strategies", label=f"⚔️Directional Strategies"): + for controller in available_controllers: + if available_controllers[controller]["type"] == "directional_trading": + mui.lab.TreeItem(nodeId=constants.CONTROLLERS_PATH + "/" + controller + ".py", label=f"🐍{controller}") + with mui.lab.TreeItem(nodeId="market_making_strategies", label=f"🪙Market Making Strategies"): + for controller in available_controllers: + if available_controllers[controller]["type"] == "market_making": + mui.lab.TreeItem(nodeId=constants.CONTROLLERS_PATH + "/" + controller + ".py", label=f"🐍{controller}") From 6a8d5f086e9d21648f549760a6daf6ccc06001d5 Mon Sep 17 00:00:00 2001 From: cardosofede Date: Mon, 9 Oct 2023 16:53:25 -0300 Subject: [PATCH 3/5] (feat) improve logic of optimization --- ui_components/optimization_creation_card.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui_components/optimization_creation_card.py b/ui_components/optimization_creation_card.py index 07e016d5..ee9a9b41 100644 --- a/ui_components/optimization_creation_card.py +++ b/ui_components/optimization_creation_card.py @@ -28,7 +28,7 @@ def _create_optimization(self, strategy_info): def __call__(self): available_strategies = load_controllers(constants.CONTROLLERS_PATH) - strategy_names = [strategy for strategy, strategy_info in available_strategies.items() if "class" in strategy_info] + strategy_names = [strategy for strategy, strategy_info in available_strategies.items() if strategy_info["type"] == "directional_trading"] with mui.Paper(key=self._key, sx={"display": "flex", "flexDirection": "column", "borderRadius": 3, "overflow": "hidden"}, elevation=1): From e30494affc4eccd340a89dd3498932c288dd365d Mon Sep 17 00:00:00 2001 From: cardosofede Date: Mon, 9 Oct 2023 16:53:34 -0300 Subject: [PATCH 4/5] (feat) add type of controller to dict --- utils/os_utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/utils/os_utils.py b/utils/os_utils.py index abb0863e..ba1e47b4 100644 --- a/utils/os_utils.py +++ b/utils/os_utils.py @@ -6,6 +6,8 @@ from hummingbot.smart_components.strategy_frameworks.directional_trading import DirectionalTradingControllerBase, DirectionalTradingControllerConfigBase import yaml +from hummingbot.smart_components.strategy_frameworks.market_making import MarketMakingControllerBase, \ + MarketMakingControllerConfigBase def remove_files_from_directory(directory: str): @@ -91,8 +93,14 @@ def load_controllers(path): for name, cls in inspect.getmembers(module, inspect.isclass): if issubclass(cls, DirectionalTradingControllerBase) and cls is not DirectionalTradingControllerBase: controllers[module_name]["class"] = cls + controllers[module_name]["type"] = "directional_trading" if issubclass(cls, DirectionalTradingControllerConfigBase) and cls is not DirectionalTradingControllerConfigBase: controllers[module_name]["config"] = cls + if issubclass(cls, MarketMakingControllerBase) and cls is not MarketMakingControllerBase: + controllers[module_name]["class"] = cls + controllers[module_name]["type"] = "market_making" + if issubclass(cls, MarketMakingControllerConfigBase) and cls is not MarketMakingControllerConfigBase: + controllers[module_name]["config"] = cls return controllers From 08b9074853e140439231419ad281380878249fde Mon Sep 17 00:00:00 2001 From: cardosofede Date: Mon, 9 Oct 2023 16:53:52 -0300 Subject: [PATCH 5/5] (feat) refactor create page to new ui componetns --- pages/backtest_manager/create.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/backtest_manager/create.py b/pages/backtest_manager/create.py index 2b0c7d9e..4e6322ad 100644 --- a/pages/backtest_manager/create.py +++ b/pages/backtest_manager/create.py @@ -4,7 +4,7 @@ from streamlit_elements import elements, mui from ui_components.dashboard import Dashboard -from ui_components.directional_strategies_file_explorer import DirectionalStrategiesFileExplorer +from ui_components.controllers_file_explorer import ControllersFileExplorer from ui_components.directional_strategy_creation_card import DirectionalStrategyCreationCard from ui_components.editor import Editor @@ -23,7 +23,7 @@ ds_board = SimpleNamespace( dashboard=board, create_strategy_card=DirectionalStrategyCreationCard(board, 0, 0, 12, 1), - file_explorer=DirectionalStrategiesFileExplorer(board, 0, 2, 3, 7), + file_explorer=ControllersFileExplorer(board, 0, 2, 3, 7), editor=Editor(board, 4, 2, 9, 7), ) st.session_state.ds_board = ds_board