diff --git a/CONFIG.py b/CONFIG.py index 4cf953f..bf3ab9e 100644 --- a/CONFIG.py +++ b/CONFIG.py @@ -1,3 +1,7 @@ +import os + +from dotenv import load_dotenv + MINER_COINS = ["Algorand", "Avalanche", "DAO Maker", "Faith Tribe", "Fear", "Frontier", "Harmony", "Hot Cross", "HUMAN Protocol", "Oddz", "Shera", "Firo", "Vesper Finance", "Youclout", "Nimiq"] @@ -12,3 +16,7 @@ CERTIFIED_EXCHANGES = ["ascendex", "binance", "bybit", "gate.io", "hitbtc", "huo CERTIFIED_STRATEGIES = ["xemm", "cross exchange market making", "pmm", "pure market making"] AUTH_SYSTEM_ENABLED = False +load_dotenv() + +BACKEND_API_HOST = os.getenv("BACKEND_API_HOST", "localhost") +BACKEND_API_PORT = os.getenv("BACKEND_API_PORT", 8000) \ No newline at end of file diff --git a/pages/bot_orchestration/app.py b/pages/bot_orchestration/app.py index a74f3c3..a7289da 100644 --- a/pages/bot_orchestration/app.py +++ b/pages/bot_orchestration/app.py @@ -1,6 +1,7 @@ import streamlit as st from streamlit_elements import elements, mui +from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT from ui_components.bot_performance_card_v2 import BotPerformanceCardV2 from ui_components.dashboard import Dashboard from utils.backend_api_client import BackendAPIClient @@ -19,7 +20,7 @@ def get_grid_positions(n_cards: int, cols: int = NUM_CARD_COLS, card_width: int initialize_st_page(title="Instances", icon="🦅", initial_sidebar_state="collapsed") -api_client = BackendAPIClient.get_instance(host="localhost", port=8000) +api_client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) if not api_client.is_docker_running(): diff --git a/pages/dman_maker_v2/app.py b/pages/dman_maker_v2/app.py index 283013b..78bf932 100644 --- a/pages/dman_maker_v2/app.py +++ b/pages/dman_maker_v2/app.py @@ -5,6 +5,7 @@ import plotly.graph_objects as go from decimal import Decimal import yaml +from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT from utils.backend_api_client import BackendAPIClient from utils.st_utils import initialize_st_page from hummingbot.smart_components.utils.distributions import Distributions @@ -430,8 +431,8 @@ config = { "connector_name": connector, "trading_pair": trading_pair, "total_amount_quote": total_amount_quote, - "buy_spreads": buy_spread_distributions, - "sell_spreads": sell_spread_distributions, + "buy_spreads": [spread / 100 for spread in buy_spread_distributions], + "sell_spreads": [spread / 100 for spread in sell_spread_distributions], "buy_amounts_pct": buy_order_amounts_quote, "sell_amounts_pct": sell_order_amounts_quote, "executor_refresh_time": executor_refresh_time * 60, @@ -463,6 +464,6 @@ with c3: if upload_config_to_backend: - backend_api_client = BackendAPIClient.get_instance() + backend_api_client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) backend_api_client.add_controller_config(config) st.success("Config uploaded successfully!") \ No newline at end of file diff --git a/ui_components/bot_performance_card_v2.py b/ui_components/bot_performance_card_v2.py index aaf2546..27901f3 100644 --- a/ui_components/bot_performance_card_v2.py +++ b/ui_components/bot_performance_card_v2.py @@ -1,16 +1,17 @@ from streamlit_elements import mui, lazy + +from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT from ui_components.dashboard import Dashboard import streamlit as st import time import pandas as pd -import datetime from utils.backend_api_client import BackendAPIClient TRADES_TO_SHOW = 5 -WIDE_COL_WIDTH = 150 +WIDE_COL_WIDTH = 180 MEDIUM_COL_WIDTH = 140 -backend_api_client = BackendAPIClient.get_instance() +backend_api_client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) def stop_bot(bot_name): diff --git a/ui_components/launch_strategy_v2.py b/ui_components/launch_strategy_v2.py index 1cf7724..b261041 100644 --- a/ui_components/launch_strategy_v2.py +++ b/ui_components/launch_strategy_v2.py @@ -1,11 +1,9 @@ -import json import time import streamlit as st -from hummingbot.core.data_type.common import PositionMode, OrderType, TradeType -from hummingbot.smart_components.utils.config_encoder_decoder import ConfigEncoderDecoder from streamlit_elements import mui, lazy +from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT from utils.backend_api_client import BackendAPIClient from .dashboard import Dashboard @@ -28,21 +26,21 @@ class LaunchStrategyV2(Dashboard.Item): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self._backend_api_client = BackendAPIClient.get_instance() + self._backend_api_client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) self._controller_configs_available = self._backend_api_client.get_all_controllers_config() self._controller_config_selected = None self._bot_name = None - self._image_name = "hummingbot/hummingbot:latest" + self._image_name = "dardonacci/hummingbot:latest" self._credentials = "master_account" def _set_bot_name(self, event): self._bot_name = event.target.value - def _set_image_name(self, event): - self._image_name = event.target.value + def _set_image_name(self, _, childs): + self._image_name = childs.props.value - def _set_credentials(self, event): - self._credentials = event.target.value + def _set_credentials(self, _, childs): + self._credentials = childs.props.value def _set_controller(self, event): self._controller_selected = event.target.value