mirror of
https://github.com/aljazceru/hummingbot-dashboard.git
synced 2026-01-01 12:34:24 +01:00
(feat) clean up pmm simple page
This commit is contained in:
@@ -4,32 +4,30 @@ from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT
|
||||
|
||||
# Import submodules
|
||||
from frontend.pages.config.pmm_simple.user_inputs import user_inputs
|
||||
from frontend.pages.config.pmm_simple import calculate_orders
|
||||
from frontend.data_viz.visualization import visualize_orders
|
||||
from frontend.pages.config.pmm_simple import handle_config
|
||||
from frontend.components.backtesting import backtesting_section
|
||||
from frontend.st_utils import initialize_st_page
|
||||
from frontend.visualization.backtesting import create_backtesting_figure
|
||||
from frontend.visualization.executors_distribution import create_executors_distribution_traces
|
||||
|
||||
# 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)
|
||||
|
||||
# Page content
|
||||
st.text("This tool will let you create a config for PMM Simple and upload it to the BackendAPI.")
|
||||
st.text("This tool will let you create a config for PMM Simple, backtest and upload it to the Backend API.")
|
||||
st.write("---")
|
||||
|
||||
# Get user inputs
|
||||
inputs = user_inputs()
|
||||
st.write(inputs)
|
||||
fig = create_executors_distribution_traces(inputs)
|
||||
st.plotly_chart(fig, use_container_width=True)
|
||||
|
||||
# Calculate orders based on inputs
|
||||
order_data = calculate_orders(inputs)
|
||||
|
||||
# Visualize orders
|
||||
visualize_orders(order_data)
|
||||
|
||||
# Handle configuration
|
||||
handle_config(inputs, order_data, backend_api_client)
|
||||
|
||||
st.write("---")
|
||||
st.write("### Backtesting")
|
||||
backtesting_section(inputs, backend_api_client)
|
||||
bt_results = backtesting_section(inputs, backend_api_client)
|
||||
if bt_results:
|
||||
fig = create_backtesting_figure(
|
||||
df=bt_results["processed_data"],
|
||||
executors=bt_results["executors"],
|
||||
config=inputs)
|
||||
st.plotly_chart(fig, use_container_width=True)
|
||||
@@ -1,47 +1,40 @@
|
||||
import streamlit as st
|
||||
from hummingbot.connector.connector_base import OrderType
|
||||
|
||||
from frontend.components.executors_distribution import get_executors_distribution_inputs
|
||||
from frontend.components.market_making_general_inputs import get_market_making_general_inputs
|
||||
from frontend.components.risk_management import get_risk_management_inputs
|
||||
|
||||
|
||||
def user_inputs():
|
||||
c1, c2, c3, c4, c5, c6, c7 = st.columns(7)
|
||||
with c1:
|
||||
connector = st.text_input("Connector", value="binance_perpetual")
|
||||
with c2:
|
||||
trading_pair = st.text_input("Trading Pair", value="WLD-USDT")
|
||||
with c3:
|
||||
total_amount_quote = st.number_input("Total amount of quote", value=1000)
|
||||
with c4:
|
||||
leverage = st.number_input("Leverage", value=20)
|
||||
position_mode = st.selectbox("Position Mode", ("HEDGE", "ONEWAY"), index=0)
|
||||
with c5:
|
||||
executor_refresh_time = st.number_input("Refresh Time (minutes)", value=3)
|
||||
cooldown_time = st.number_input("Cooldown Time (minutes)", value=3)
|
||||
with c6:
|
||||
sl = st.number_input("Stop Loss (%)", min_value=0.0, max_value=100.0, value=2.0, step=0.1)
|
||||
tp = st.number_input("Take Profit (%)", min_value=0.0, max_value=100.0, value=3.0, step=0.1)
|
||||
take_profit_order_type = st.selectbox("Take Profit Order Type", (OrderType.LIMIT, OrderType.MARKET))
|
||||
with c7:
|
||||
ts_ap = st.number_input("Trailing Stop Activation Price (%)", min_value=0.0, max_value=100.0, value=1.0, step=0.1)
|
||||
ts_delta = st.number_input("Trailing Stop Delta (%)", min_value=0.0, max_value=100.0, value=0.3, step=0.1)
|
||||
time_limit = st.number_input("Time Limit (minutes)", min_value=0, value=60 * 6)
|
||||
|
||||
buy_order_levels = st.number_input("Number of Buy Order Levels", min_value=1, value=2)
|
||||
sell_order_levels = st.number_input("Number of Sell Order Levels", min_value=1, value=2)
|
||||
|
||||
inputs = {
|
||||
"connector": connector,
|
||||
st.title("PMM Simple Configuration")
|
||||
connector_name, trading_pair, leverage, total_amount_quote, position_mode, cooldown_time, executor_refresh_time = get_market_making_general_inputs()
|
||||
buy_spread_distributions, sell_spread_distributions, buy_order_amounts_pct, sell_order_amounts_pct = get_executors_distribution_inputs()
|
||||
sl, tp, time_limit, ts_ap, ts_delta, take_profit_order_type = get_risk_management_inputs()
|
||||
# Create the config
|
||||
config = {
|
||||
"controller_name": "pmm_simple",
|
||||
"controller_type": "market_making",
|
||||
"manual_kill_switch": None,
|
||||
"candles_config": [],
|
||||
"connector_name": connector_name,
|
||||
"trading_pair": trading_pair,
|
||||
"total_amount_quote": total_amount_quote,
|
||||
"leverage": leverage,
|
||||
"position_mode": position_mode,
|
||||
"buy_spreads": buy_spread_distributions,
|
||||
"sell_spreads": sell_spread_distributions,
|
||||
"buy_amounts_pct": buy_order_amounts_pct,
|
||||
"sell_amounts_pct": sell_order_amounts_pct,
|
||||
"executor_refresh_time": executor_refresh_time,
|
||||
"cooldown_time": cooldown_time,
|
||||
"sl": sl,
|
||||
"tp": tp,
|
||||
"take_profit_order_type": take_profit_order_type,
|
||||
"ts_ap": ts_ap,
|
||||
"ts_delta": ts_delta,
|
||||
"leverage": leverage,
|
||||
"position_mode": position_mode,
|
||||
"stop_loss": sl,
|
||||
"take_profit": tp,
|
||||
"time_limit": time_limit,
|
||||
"buy_order_levels": buy_order_levels,
|
||||
"sell_order_levels": sell_order_levels
|
||||
"take_profit_order_type": take_profit_order_type.value,
|
||||
"trailing_stop": {
|
||||
"activation_price": ts_ap,
|
||||
"trailing_delta": ts_delta
|
||||
}
|
||||
}
|
||||
return inputs
|
||||
|
||||
return config
|
||||
|
||||
Reference in New Issue
Block a user