diff --git a/pages/orchestration/credentials/app.py b/pages/orchestration/credentials/app.py index 666f054..3e57f88 100644 --- a/pages/orchestration/credentials/app.py +++ b/pages/orchestration/credentials/app.py @@ -1,8 +1,6 @@ -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, get_backend_api_client import streamlit as st +from frontend.st_utils import get_backend_api_client, initialize_st_page initialize_st_page(title="Credentials", icon="🔑") @@ -15,6 +13,7 @@ NUM_COLUMNS = 4 def get_all_connectors_config_map(): return client.get_all_connectors_config_map() + # Section to display available accounts and credentials accounts = client.get_accounts() all_connector_config_map = get_all_connectors_config_map() @@ -58,7 +57,8 @@ with c1: with c2: # Section to delete an existing account st.header("Delete an Account") - delete_account_name = st.selectbox("Select Account to Delete", options=accounts if accounts else ["No accounts available"], ) + delete_account_name = st.selectbox("Select Account to Delete", + options=accounts if accounts else ["No accounts available"], ) if st.button("Delete Account"): if delete_account_name and delete_account_name != "No accounts available": response = client.delete_account(delete_account_name) @@ -69,11 +69,14 @@ with c2: with c3: # Section to delete a credential from an existing account st.header("Delete Credential") - delete_account_cred_name = st.selectbox("Select the credentials account", options=accounts if accounts else ["No accounts available"],) + delete_account_cred_name = st.selectbox("Select the credentials account", + options=accounts if accounts else ["No accounts available"], ) creds_for_account = [credential.split(".")[0] for credential in client.get_credentials(delete_account_cred_name)] - delete_cred_name = st.selectbox("Select a Credential to Delete", options=creds_for_account if creds_for_account else ["No credentials available"]) + delete_cred_name = st.selectbox("Select a Credential to Delete", + options=creds_for_account if creds_for_account else ["No credentials available"]) if st.button("Delete Credential"): - if (delete_account_cred_name and delete_account_cred_name != "No accounts available") and (delete_cred_name and delete_cred_name != "No credentials available"): + if (delete_account_cred_name and delete_account_cred_name != "No accounts available") and \ + (delete_cred_name and delete_cred_name != "No credentials available"): response = client.delete_credential(delete_account_cred_name, delete_cred_name) st.warning(response) else: @@ -88,7 +91,8 @@ with c1: account_name = st.selectbox("Select Account", options=accounts if accounts else ["No accounts available"]) with c2: all_connectors = list(all_connector_config_map.keys()) - binance_perpetual_index = all_connectors.index("binance_perpetual") if "binance_perpetual" in all_connectors else None + binance_perpetual_index = all_connectors.index( + "binance_perpetual") if "binance_perpetual" in all_connectors else None connector_name = st.selectbox("Select Connector", options=all_connectors, index=binance_perpetual_index) config_map = all_connector_config_map[connector_name] @@ -103,4 +107,4 @@ with cols[-1]: if st.button("Submit Credentials"): response = client.add_connector_keys(account_name, connector_name, config_inputs) if response: - st.success(response) \ No newline at end of file + st.success(response) diff --git a/pages/orchestration/file_manager/app.py b/pages/orchestration/file_manager/app.py index 8f20839..f771d54 100644 --- a/pages/orchestration/file_manager/app.py +++ b/pages/orchestration/file_manager/app.py @@ -1,4 +1,5 @@ from types import SimpleNamespace + import streamlit as st from streamlit_elements import elements, mui diff --git a/pages/orchestration/instances/app.py b/pages/orchestration/instances/app.py index d506e95..59aaa99 100644 --- a/pages/orchestration/instances/app.py +++ b/pages/orchestration/instances/app.py @@ -1,18 +1,19 @@ import time +from types import SimpleNamespace import streamlit as st from streamlit_elements import elements, mui -from types import SimpleNamespace from frontend.components.bot_performance_card import BotPerformanceCardV2 from frontend.components.dashboard import Dashboard -from frontend.st_utils import initialize_st_page, get_backend_api_client +from frontend.st_utils import get_backend_api_client, initialize_st_page # Constants for UI layout CARD_WIDTH = 12 CARD_HEIGHT = 4 NUM_CARD_COLS = 1 + def get_grid_positions(n_cards: int, cols: int = NUM_CARD_COLS, card_width: int = CARD_WIDTH, card_height: int = CARD_HEIGHT): rows = n_cards // cols + 1 x_y = [(x * card_width, y * card_height) for x in range(cols) for y in range(rows)] @@ -28,7 +29,9 @@ def update_active_bots(api_client): new_bots = set(current_active_bots.keys()) - set(stored_bots.keys()) removed_bots = set(stored_bots.keys()) - set(current_active_bots.keys()) for bot in removed_bots: - st.session_state.active_instances_board.bot_cards = [card for card in st.session_state.active_instances_board.bot_cards if card[1] != bot] + st.session_state.active_instances_board.bot_cards = [card for card in + st.session_state.active_instances_board.bot_cards + if card[1] != bot] positions = get_grid_positions(len(current_active_bots), NUM_CARD_COLS, CARD_WIDTH, CARD_HEIGHT) for bot, (x, y) in zip(new_bots, positions[:len(new_bots)]): card = BotPerformanceCardV2(st.session_state.active_instances_board.dashboard, x, y, CARD_WIDTH, CARD_HEIGHT) @@ -70,4 +73,4 @@ with elements("active_instances_board"): while True: time.sleep(10) - st.rerun() \ No newline at end of file + st.rerun() diff --git a/pages/orchestration/launch_bot_v2_st/app.py b/pages/orchestration/launch_bot_v2_st/app.py index 50c2c08..0766de0 100644 --- a/pages/orchestration/launch_bot_v2_st/app.py +++ b/pages/orchestration/launch_bot_v2_st/app.py @@ -1,7 +1,6 @@ from frontend.components.deploy_v2_with_controllers import LaunchV2WithControllers from frontend.st_utils import initialize_st_page - initialize_st_page(title="Launch Bot ST", icon="🙌") diff --git a/pages/orchestration/portfolio/app.py b/pages/orchestration/portfolio/app.py index 27d8607..eefc60f 100644 --- a/pages/orchestration/portfolio/app.py +++ b/pages/orchestration/portfolio/app.py @@ -1,8 +1,8 @@ -from frontend.st_utils import initialize_st_page, get_backend_api_client -import streamlit as st import pandas as pd -import plotly.graph_objects as go import plotly.express as px +import streamlit as st + +from frontend.st_utils import get_backend_api_client, initialize_st_page initialize_st_page(title="Portfolio", icon="💰") @@ -91,7 +91,8 @@ for account in accounts: filtered_account_state[account] = {} for exchange in exchanges: if exchange in account_state[account]: - filtered_account_state[account][exchange] = [token_info for token_info in account_state[account][exchange] if token_info["token"] in tokens_available] + filtered_account_state[account][exchange] = [token_info for token_info in account_state[account][exchange] + if token_info["token"] in tokens_available] filtered_account_history = [] for record in account_history: @@ -101,7 +102,9 @@ for record in account_history: filtered_record["state"][account] = {} for exchange in exchanges: if exchange in record["state"][account]: - filtered_record["state"][account][exchange] = [token_info for token_info in record["state"][account][exchange] if token_info["token"] in tokens_available] + filtered_record["state"][account][exchange] = [token_info for token_info in + record["state"][account][exchange] if + token_info["token"] in tokens_available] filtered_account_history.append(filtered_record) if len(filtered_account_state) > 0: