From cd8c1bbb01345a91feef65352af2e3716ede36bb Mon Sep 17 00:00:00 2001 From: cardosofede Date: Tue, 16 Jul 2024 18:50:33 +0300 Subject: [PATCH] (feat) update backend style --- backend/services/backend_api_client.py | 5 +++-- backend/services/coingecko_client.py | 4 ++-- backend/utils/optuna_database_manager.py | 14 +------------- backend/utils/os_utils.py | 13 +++++++++---- 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/backend/services/backend_api_client.py b/backend/services/backend_api_client.py index 9bc128b..91b9979 100644 --- a/backend/services/backend_api_client.py +++ b/backend/services/backend_api_client.py @@ -1,4 +1,4 @@ -from typing import Optional, Dict +from typing import Dict, Optional import pandas as pd import requests @@ -115,7 +115,8 @@ class BackendAPIClient: def stop_bot(self, bot_name: str, skip_order_cancellation: bool = False, async_backend: bool = True): """Stop a Hummingbot bot.""" endpoint = "stop-bot" - return self.post(endpoint, payload={"bot_name": bot_name, "skip_order_cancellation": skip_order_cancellation, "async_backend": async_backend}) + return self.post(endpoint, payload={"bot_name": bot_name, "skip_order_cancellation": skip_order_cancellation, + "async_backend": async_backend}) def import_strategy(self, strategy_config: dict): """Import a trading strategy to a bot.""" diff --git a/backend/services/coingecko_client.py b/backend/services/coingecko_client.py index d870add..61ca5f7 100644 --- a/backend/services/coingecko_client.py +++ b/backend/services/coingecko_client.py @@ -1,8 +1,8 @@ +import re import time -from pycoingecko import CoinGeckoAPI import pandas as pd -import re +from pycoingecko import CoinGeckoAPI class CoinGeckoClient: diff --git a/backend/utils/optuna_database_manager.py b/backend/utils/optuna_database_manager.py index 9293c84..f6cc229 100644 --- a/backend/utils/optuna_database_manager.py +++ b/backend/utils/optuna_database_manager.py @@ -1,5 +1,5 @@ -import os import json +import os from typing import Optional import pandas as pd @@ -102,18 +102,6 @@ class OptunaDBManager: except Exception as e: return f"Error: {str(e)}" - @property - def trial_system_attributes(self): - return self._get_trial_system_attributes_table() - - def _get_trial_system_attributes_table(self): - try: - with self.session_maker() as session: - df = pd.read_sql_query(text("SELECT * FROM trial_system_attributes"), session.connection()) - return df - except Exception as e: - return f"Error: {str(e)}" - @property def version_info(self): return self._get_version_info_table() diff --git a/backend/utils/os_utils.py b/backend/utils/os_utils.py index bec7293..cd42a69 100644 --- a/backend/utils/os_utils.py +++ b/backend/utils/os_utils.py @@ -1,14 +1,19 @@ import glob -import subprocess import importlib.util import inspect import os +import subprocess import pandas as pd - import yaml -from hummingbot.strategy_v2.controllers.directional_trading_controller_base import DirectionalTradingControllerBase, DirectionalTradingControllerConfigBase -from hummingbot.strategy_v2.controllers.market_making_controller_base import MarketMakingControllerBase, MarketMakingControllerConfigBase +from hummingbot.strategy_v2.controllers.directional_trading_controller_base import ( + DirectionalTradingControllerBase, + DirectionalTradingControllerConfigBase, +) +from hummingbot.strategy_v2.controllers.market_making_controller_base import ( + MarketMakingControllerBase, + MarketMakingControllerConfigBase, +) def remove_files_from_directory(directory: str):