(feat) adapt pages to get the backend api client

This commit is contained in:
cardosofede
2024-06-07 00:04:20 +02:00
parent 275b87ddc4
commit 04dc8a7d64
13 changed files with 26 additions and 27 deletions

View File

@@ -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.")

View File

@@ -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

View File

@@ -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!")

View File

@@ -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!")

View File

@@ -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

View File

@@ -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.")

View File

@@ -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

View File

@@ -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

View File

@@ -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!")

View File

@@ -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:

View File

@@ -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

View File

@@ -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.")

View File

@@ -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