diff --git a/frontend/pages/config/bollinger_v1/app.py b/frontend/pages/config/bollinger_v1/app.py index 64cdfe7..a14a4fe 100644 --- a/frontend/pages/config/bollinger_v1/app.py +++ b/frontend/pages/config/bollinger_v1/app.py @@ -11,7 +11,7 @@ from frontend.components.backtesting import backtesting_section from frontend.components.config_loader import get_default_config_loader from frontend.components.save_config import render_save_config from frontend.pages.config.utils import get_max_records, get_candles -from frontend.st_utils import initialize_st_page +from frontend.st_utils import initialize_st_page, get_backend_api_client from frontend.pages.config.bollinger_v1.user_inputs import user_inputs from plotly.subplots import make_subplots @@ -26,7 +26,7 @@ from frontend.visualization.utils import add_traces_to_fig # Initialize the Streamlit page initialize_st_page(title="Bollinger V1", icon="📈", initial_sidebar_state="expanded") -backend_api_client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) +backend_api_client = get_backend_api_client() st.text("This tool will let you create a config for Bollinger V1 and visualize the strategy.") diff --git a/frontend/pages/config/dman_maker_v2/app.py b/frontend/pages/config/dman_maker_v2/app.py index 1505c38..830fe99 100644 --- a/frontend/pages/config/dman_maker_v2/app.py +++ b/frontend/pages/config/dman_maker_v2/app.py @@ -7,7 +7,7 @@ from frontend.components.config_loader import get_default_config_loader from frontend.components.dca_distribution import get_dca_distribution_inputs from frontend.components.save_config import render_save_config from frontend.pages.config.dman_maker_v2.user_inputs import user_inputs -from frontend.st_utils import initialize_st_page +from frontend.st_utils import initialize_st_page, get_backend_api_client from frontend.visualization.backtesting import create_backtesting_figure from frontend.visualization.backtesting_metrics import render_backtesting_metrics, render_accuracy_metrics, \ render_close_types @@ -16,7 +16,7 @@ from frontend.visualization.executors_distribution import create_executors_distr # Initialize the Streamlit page initialize_st_page(title="D-Man Maker V2", icon="🧙‍♂️") -backend_api_client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) +backend_api_client = get_backend_api_client() # Page content diff --git a/frontend/pages/config/dman_v5/app.py b/frontend/pages/config/dman_v5/app.py index ac39d9f..9522cb8 100644 --- a/frontend/pages/config/dman_v5/app.py +++ b/frontend/pages/config/dman_v5/app.py @@ -6,7 +6,7 @@ from plotly.subplots import make_subplots from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT from backend.services.backend_api_client import BackendAPIClient -from frontend.st_utils import initialize_st_page +from frontend.st_utils import initialize_st_page, get_backend_api_client # Initialize the Streamlit page initialize_st_page(title="D-Man V5", icon="📊", initial_sidebar_state="expanded") @@ -142,6 +142,6 @@ with c3: if upload_config_to_backend: - backend_api_client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) + backend_api_client = get_backend_api_client() backend_api_client.add_controller_config(config) st.success("Config uploaded successfully!") diff --git a/frontend/pages/config/kalman_filter_v1/app.py b/frontend/pages/config/kalman_filter_v1/app.py index 5f7e358..2479d18 100644 --- a/frontend/pages/config/kalman_filter_v1/app.py +++ b/frontend/pages/config/kalman_filter_v1/app.py @@ -7,7 +7,7 @@ from pykalman import KalmanFilter from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT from backend.services.backend_api_client import BackendAPIClient -from frontend.st_utils import initialize_st_page +from frontend.st_utils import initialize_st_page, get_backend_api_client # Initialize the Streamlit page initialize_st_page(title="Kalman Filter V1", icon="📈", initial_sidebar_state="expanded") @@ -220,6 +220,6 @@ with c3: if upload_config_to_backend: - backend_api_client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) + backend_api_client = get_backend_api_client() backend_api_client.add_controller_config(config) st.success("Config uploaded successfully!") \ No newline at end of file diff --git a/frontend/pages/config/macd_bb_v1/app.py b/frontend/pages/config/macd_bb_v1/app.py index a9f0e3e..75383e5 100644 --- a/frontend/pages/config/macd_bb_v1/app.py +++ b/frontend/pages/config/macd_bb_v1/app.py @@ -11,7 +11,7 @@ from frontend.components.config_loader import get_default_config_loader from frontend.components.save_config import render_save_config from frontend.pages.config.macd_bb_v1.user_inputs import user_inputs from frontend.pages.config.utils import get_candles, get_max_records -from frontend.st_utils import initialize_st_page +from frontend.st_utils import initialize_st_page, get_backend_api_client from frontend.visualization import theme from frontend.visualization.backtesting import create_backtesting_figure from frontend.visualization.backtesting_metrics import render_backtesting_metrics, render_accuracy_metrics, \ @@ -23,7 +23,7 @@ from frontend.visualization.utils import add_traces_to_fig # Initialize the Streamlit page initialize_st_page(title="MACD_BB V1", icon="📊", initial_sidebar_state="expanded") -backend_api_client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) +backend_api_client = get_backend_api_client() get_default_config_loader("macd_bb_v1") # User inputs diff --git a/frontend/pages/config/pmm_dynamic/app.py b/frontend/pages/config/pmm_dynamic/app.py index e43a8a2..8bbbbc8 100644 --- a/frontend/pages/config/pmm_dynamic/app.py +++ b/frontend/pages/config/pmm_dynamic/app.py @@ -13,7 +13,7 @@ from frontend.components.backtesting import backtesting_section from frontend.pages.config.pmm_dynamic.spread_and_price_multipliers import get_pmm_dynamic_multipliers from frontend.pages.config.pmm_dynamic.user_inputs import user_inputs from frontend.pages.config.utils import get_max_records, get_candles -from frontend.st_utils import initialize_st_page +from frontend.st_utils import initialize_st_page, get_backend_api_client from frontend.visualization import theme from frontend.visualization.backtesting import create_backtesting_figure from frontend.visualization.candles import get_candlestick_trace @@ -25,7 +25,7 @@ from frontend.visualization.utils import add_traces_to_fig # Initialize the Streamlit page initialize_st_page(title="PMM Dynamic", icon="👩‍🏫") -backend_api_client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) +backend_api_client = get_backend_api_client() # Page content st.text("This tool will let you create a config for PMM Dynamic, backtest and upload it to the Backend API.") diff --git a/frontend/pages/config/pmm_simple/app.py b/frontend/pages/config/pmm_simple/app.py index 69d60b5..445c362 100644 --- a/frontend/pages/config/pmm_simple/app.py +++ b/frontend/pages/config/pmm_simple/app.py @@ -7,7 +7,7 @@ from frontend.components.save_config import render_save_config # Import submodules from frontend.pages.config.pmm_simple.user_inputs import user_inputs from frontend.components.backtesting import backtesting_section -from frontend.st_utils import initialize_st_page +from frontend.st_utils import initialize_st_page, get_backend_api_client from frontend.visualization.backtesting import create_backtesting_figure from frontend.visualization.executors_distribution import create_executors_distribution_traces from frontend.visualization.backtesting_metrics import render_backtesting_metrics, render_close_types, \ @@ -15,7 +15,7 @@ from frontend.visualization.backtesting_metrics import render_backtesting_metric # Initialize the Streamlit page initialize_st_page(title="PMM Simple", icon="👨‍🏫") -backend_api_client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) +backend_api_client = get_backend_api_client() # Page content diff --git a/frontend/pages/config/supertrend_v1/app.py b/frontend/pages/config/supertrend_v1/app.py index 2438f66..3f00f5f 100644 --- a/frontend/pages/config/supertrend_v1/app.py +++ b/frontend/pages/config/supertrend_v1/app.py @@ -8,7 +8,7 @@ from frontend.components.config_loader import get_default_config_loader from frontend.components.save_config import render_save_config from frontend.pages.config.supertrend_v1.user_inputs import user_inputs from frontend.pages.config.utils import get_candles, get_max_records -from frontend.st_utils import initialize_st_page +from frontend.st_utils import initialize_st_page, get_backend_api_client from frontend.visualization import theme from frontend.visualization.backtesting import create_backtesting_figure from frontend.visualization.backtesting_metrics import render_backtesting_metrics, render_accuracy_metrics, \ @@ -20,7 +20,7 @@ from frontend.visualization.utils import add_traces_to_fig # Initialize the Streamlit page initialize_st_page(title="SuperTrend V1", icon="📊", initial_sidebar_state="expanded") -backend_api_client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) +backend_api_client = get_backend_api_client() get_default_config_loader("supertrend_v1") # User inputs diff --git a/frontend/pages/config/xemm_controller/app.py b/frontend/pages/config/xemm_controller/app.py index 00bd029..f78194d 100644 --- a/frontend/pages/config/xemm_controller/app.py +++ b/frontend/pages/config/xemm_controller/app.py @@ -4,7 +4,7 @@ import yaml from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT from backend.services.backend_api_client import BackendAPIClient -from frontend.st_utils import initialize_st_page +from frontend.st_utils import initialize_st_page, get_backend_api_client # Initialize the Streamlit page initialize_st_page(title="XEMM Multiple Levels", icon="⚡️") @@ -135,6 +135,6 @@ with c3: if upload_config_to_backend: - backend_api_client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) + backend_api_client = get_backend_api_client() backend_api_client.add_controller_config(config) st.success("Config uploaded successfully!") \ No newline at end of file diff --git a/frontend/pages/data/download_candles/app.py b/frontend/pages/data/download_candles/app.py index ee1a7cc..d03aca0 100644 --- a/frontend/pages/data/download_candles/app.py +++ b/frontend/pages/data/download_candles/app.py @@ -3,12 +3,11 @@ from datetime import datetime, time import pandas as pd import plotly.graph_objects as go -from backend.services.backend_api_client import BackendAPIClient -from frontend.st_utils import initialize_st_page +from frontend.st_utils import initialize_st_page, get_backend_api_client # Initialize Streamlit page initialize_st_page(title="Download Candles", icon="💾") -backend_api_client = BackendAPIClient.get_instance() +backend_api_client = get_backend_api_client() c1, c2, c3, c4 = st.columns([2, 2, 2, 0.5]) with c1: diff --git a/frontend/pages/orchestration/credentials/app.py b/frontend/pages/orchestration/credentials/app.py index c719fe3..d5a9883 100644 --- a/frontend/pages/orchestration/credentials/app.py +++ b/frontend/pages/orchestration/credentials/app.py @@ -1,13 +1,13 @@ from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT from backend.services.backend_api_client import BackendAPIClient -from frontend.st_utils import initialize_st_page +from frontend.st_utils import initialize_st_page, get_backend_api_client import streamlit as st initialize_st_page(title="Credentials", icon="🔑") # Page content -client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) +client = get_backend_api_client() NUM_COLUMNS = 4 diff --git a/frontend/pages/orchestration/instances/app.py b/frontend/pages/orchestration/instances/app.py index 512c65c..a9a81c1 100644 --- a/frontend/pages/orchestration/instances/app.py +++ b/frontend/pages/orchestration/instances/app.py @@ -8,7 +8,7 @@ from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT from frontend.components.bot_performance_card import BotPerformanceCardV2 from frontend.components.dashboard import Dashboard from backend.services.backend_api_client import BackendAPIClient -from frontend.st_utils import initialize_st_page +from frontend.st_utils import initialize_st_page, get_backend_api_client # Constants for UI layout CARD_WIDTH = 12 @@ -38,7 +38,7 @@ def update_active_bots(api_client): initialize_st_page(title="Instances", icon="🦅") -api_client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) +api_client = get_backend_api_client() if not api_client.is_docker_running(): st.warning("Docker is not running. Please start Docker and refresh the page.") diff --git a/frontend/pages/orchestration/portfolio/app.py b/frontend/pages/orchestration/portfolio/app.py index 286bc1b..f2c7e45 100644 --- a/frontend/pages/orchestration/portfolio/app.py +++ b/frontend/pages/orchestration/portfolio/app.py @@ -1,13 +1,13 @@ from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT from backend.services.backend_api_client import BackendAPIClient -from frontend.st_utils import initialize_st_page +from frontend.st_utils import initialize_st_page, get_backend_api_client import streamlit as st import pandas as pd initialize_st_page(title="Portfolio", icon="💰") # Page content -client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) +client = get_backend_api_client() NUM_COLUMNS = 4 @st.cache_data