(feat) add upload config to backend api

This commit is contained in:
cardosofede
2024-05-18 00:12:39 -04:00
parent 02a078b529
commit ef48c8fa98
2 changed files with 25 additions and 1 deletions

View File

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

View File

@@ -1,6 +1,7 @@
import streamlit as st import streamlit as st
from backend.services.backend_api_client import BackendAPIClient from backend.services.backend_api_client import BackendAPIClient
from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT
from frontend.components.save_config import render_save_config
# Import submodules # Import submodules
from frontend.pages.config.pmm_simple.user_inputs import user_inputs 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) bt_results = backtesting_section(inputs, backend_api_client)
if bt_results: if bt_results:
st.write("---")
fig = create_backtesting_figure( fig = create_backtesting_figure(
df=bt_results["processed_data"], df=bt_results["processed_data"],
executors=bt_results["executors"], executors=bt_results["executors"],
@@ -37,3 +37,5 @@ if bt_results:
render_accuracy_metrics(bt_results["results"]) render_accuracy_metrics(bt_results["results"])
st.write("---") st.write("---")
render_close_types(bt_results["results"]) render_close_types(bt_results["results"])
st.write("---")
render_save_config("pmm_simple", inputs)