diff --git a/frontend/components/save_config.py b/frontend/components/save_config.py new file mode 100644 index 0000000..89896d7 --- /dev/null +++ b/frontend/components/save_config.py @@ -0,0 +1,22 @@ +import streamlit as st + +from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT +from backend.services.backend_api_client import BackendAPIClient + + +def render_save_config(controller_name: str, config_data: dict): + st.write("### Upload Config to BackendAPI") + c1, c2, c3 = st.columns([1, 1, 0.5]) + connector = config_data.get("connector_name", "") + trading_pair = config_data.get("trading_pair", "") + with c1: + config_base = st.text_input("Config Base", value=f"{controller_name}-{connector}-{trading_pair.split('-')[0]}") + with c2: + config_tag = st.text_input("Config Tag", value="1.1") + with c3: + upload_config_to_backend = st.button("Upload") + if upload_config_to_backend: + config_data["id"] = f"{config_base}-{config_tag}" + backend_api_client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) + backend_api_client.add_controller_config(config_data) + st.success("Config uploaded successfully!") diff --git a/frontend/pages/config/pmm_simple/app.py b/frontend/pages/config/pmm_simple/app.py index 164ab9d..5040909 100644 --- a/frontend/pages/config/pmm_simple/app.py +++ b/frontend/pages/config/pmm_simple/app.py @@ -1,6 +1,7 @@ import streamlit as st from backend.services.backend_api_client import BackendAPIClient from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT +from frontend.components.save_config import render_save_config # Import submodules from frontend.pages.config.pmm_simple.user_inputs import user_inputs @@ -24,7 +25,6 @@ st.plotly_chart(fig, use_container_width=True) bt_results = backtesting_section(inputs, backend_api_client) if bt_results: - st.write("---") fig = create_backtesting_figure( df=bt_results["processed_data"], executors=bt_results["executors"], @@ -37,3 +37,5 @@ if bt_results: render_accuracy_metrics(bt_results["results"]) st.write("---") render_close_types(bt_results["results"]) +st.write("---") +render_save_config("pmm_simple", inputs)