mirror of
https://github.com/aljazceru/hummingbot-dashboard.git
synced 2026-01-07 15:34:23 +01:00
(feat) rename controllers for strategies
This commit is contained in:
@@ -12,9 +12,11 @@ def remove_files_from_directory(directory: str):
|
||||
for file in os.listdir(directory):
|
||||
os.remove(f"{directory}/{file}")
|
||||
|
||||
|
||||
def remove_file(file_path: str):
|
||||
os.remove(file_path)
|
||||
|
||||
|
||||
def remove_directory(directory: str):
|
||||
process = subprocess.Popen(f"rm -rf {directory}", shell=True)
|
||||
process.wait()
|
||||
@@ -76,22 +78,22 @@ def get_yml_files_from_directory(directory: str) -> list:
|
||||
return yml
|
||||
|
||||
|
||||
def load_directional_strategies(path):
|
||||
strategies = {}
|
||||
def load_controllers(path):
|
||||
controllers = {}
|
||||
for filename in os.listdir(path):
|
||||
if filename.endswith('.py') and "__init__" not in filename:
|
||||
module_name = filename[:-3] # strip the .py to get the module name
|
||||
strategies[module_name] = {"module": module_name}
|
||||
controllers[module_name] = {"module": module_name}
|
||||
file_path = os.path.join(path, filename)
|
||||
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
for name, cls in inspect.getmembers(module, inspect.isclass):
|
||||
if issubclass(cls, DirectionalTradingControllerBase) and cls is not DirectionalTradingControllerBase:
|
||||
strategies[module_name]["class"] = cls
|
||||
controllers[module_name]["class"] = cls
|
||||
if issubclass(cls, DirectionalTradingControllerConfigBase) and cls is not DirectionalTradingControllerConfigBase:
|
||||
strategies[module_name]["config"] = cls
|
||||
return strategies
|
||||
controllers[module_name]["config"] = cls
|
||||
return controllers
|
||||
|
||||
|
||||
def get_function_from_file(file_path: str, function_name: str):
|
||||
|
||||
Reference in New Issue
Block a user