mirror of
https://github.com/aljazceru/hummingbot-dashboard.git
synced 2025-12-21 15:34:19 +01:00
(feat) add input components
This commit is contained in:
@@ -1,15 +1,17 @@
|
|||||||
import streamlit as st
|
import streamlit as st
|
||||||
from datetime import datetime
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
|
||||||
def backtesting_section(inputs, backend_api_client):
|
def backtesting_section(inputs, backend_api_client):
|
||||||
c1, c2, c3, c4, c5 = st.columns(5)
|
c1, c2, c3, c4, c5 = st.columns(5)
|
||||||
|
default_end_time = datetime.now().date()
|
||||||
|
default_start_time = default_end_time - timedelta(days=2)
|
||||||
with c1:
|
with c1:
|
||||||
start_date = st.date_input("Start Date", datetime(2024, 5, 1))
|
start_date = st.date_input("Start Date", default_start_time)
|
||||||
with c2:
|
with c2:
|
||||||
end_date = st.date_input("End Date", datetime(2024, 5, 2))
|
end_date = st.date_input("End Date", default_end_time)
|
||||||
with c3:
|
with c3:
|
||||||
backtesting_resolution = st.selectbox("Backtesting Resolution", options=["1m", "3m", "5m", "15m", "30m"], index=1)
|
backtesting_resolution = st.selectbox("Backtesting Resolution", options=["1m", "3m", "5m", "15m", "30m", "1h", "1s"], index=0)
|
||||||
with c4:
|
with c4:
|
||||||
trade_cost = st.number_input("Trade Cost (%)", min_value=0.0, value=0.06, step=0.01, format="%.2f")
|
trade_cost = st.number_input("Trade Cost (%)", min_value=0.0, value=0.06, step=0.01, format="%.2f")
|
||||||
with c5:
|
with c5:
|
||||||
@@ -25,4 +27,5 @@ def backtesting_section(inputs, backend_api_client):
|
|||||||
trade_cost=trade_cost / 100,
|
trade_cost=trade_cost / 100,
|
||||||
config=inputs,
|
config=inputs,
|
||||||
)
|
)
|
||||||
|
|
||||||
return backtesting_results
|
return backtesting_results
|
||||||
|
|||||||
49
frontend/components/executors_distribution.py
Normal file
49
frontend/components/executors_distribution.py
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import streamlit as st
|
||||||
|
from frontend.components.st_inputs import get_distribution, normalize, distribution_inputs
|
||||||
|
|
||||||
|
|
||||||
|
def get_executors_distribution_inputs():
|
||||||
|
with st.expander("Executors Configuration", expanded=True):
|
||||||
|
col_buy, col_sell = st.columns(2)
|
||||||
|
with col_buy:
|
||||||
|
st.header("Buy Order Settings")
|
||||||
|
buy_order_levels = st.number_input("Number of Buy Order Levels", min_value=1, value=2,
|
||||||
|
help="Enter the number of buy order levels (e.g., 2).")
|
||||||
|
with col_sell:
|
||||||
|
st.header("Sell Order Settings")
|
||||||
|
sell_order_levels = st.number_input("Number of Sell Order Levels", min_value=1, value=2,
|
||||||
|
help="Enter the number of sell order levels (e.g., 2).")
|
||||||
|
col_buy_spreads, col_buy_amounts, col_sell_spreads, col_sell_amounts = st.columns(4)
|
||||||
|
with col_buy_spreads:
|
||||||
|
buy_spread_dist_type, buy_spread_start, buy_spread_base, buy_spread_scaling, buy_spread_step, buy_spread_ratio, buy_manual_spreads = distribution_inputs(
|
||||||
|
col_buy_spreads, "Spread", buy_order_levels)
|
||||||
|
with col_buy_amounts:
|
||||||
|
buy_amount_dist_type, buy_amount_start, buy_amount_base, buy_amount_scaling, buy_amount_step, buy_amount_ratio, buy_manual_amounts = distribution_inputs(
|
||||||
|
col_buy_amounts, "Amount", buy_order_levels)
|
||||||
|
with col_sell_spreads:
|
||||||
|
sell_spread_dist_type, sell_spread_start, sell_spread_base, sell_spread_scaling, sell_spread_step, sell_spread_ratio, sell_manual_spreads = distribution_inputs(
|
||||||
|
col_sell_spreads, "Spread", sell_order_levels)
|
||||||
|
with col_sell_amounts:
|
||||||
|
sell_amount_dist_type, sell_amount_start, sell_amount_base, sell_amount_scaling, sell_amount_step, sell_amount_ratio, sell_manual_amounts = distribution_inputs(
|
||||||
|
col_sell_amounts, "Amount", sell_order_levels)
|
||||||
|
|
||||||
|
# Generate distributions
|
||||||
|
buy_spread_distributions = get_distribution(buy_spread_dist_type, buy_order_levels, buy_spread_start,
|
||||||
|
buy_spread_base, buy_spread_scaling, buy_spread_step, buy_spread_ratio,
|
||||||
|
buy_manual_spreads)
|
||||||
|
sell_spread_distributions = get_distribution(sell_spread_dist_type, sell_order_levels, sell_spread_start,
|
||||||
|
sell_spread_base, sell_spread_scaling, sell_spread_step,
|
||||||
|
sell_spread_ratio, sell_manual_spreads)
|
||||||
|
|
||||||
|
buy_amount_distributions = get_distribution(buy_amount_dist_type, buy_order_levels, buy_amount_start, buy_amount_base, buy_amount_scaling,
|
||||||
|
buy_amount_step, buy_amount_ratio, buy_manual_amounts)
|
||||||
|
sell_amount_distributions = get_distribution(sell_amount_dist_type, sell_order_levels, sell_amount_start, sell_amount_base,
|
||||||
|
sell_amount_scaling, sell_amount_step, sell_amount_ratio, sell_manual_amounts)
|
||||||
|
|
||||||
|
# Normalize and calculate order amounts
|
||||||
|
all_orders_amount_normalized = normalize(buy_amount_distributions + sell_amount_distributions)
|
||||||
|
buy_order_amounts_pct = [amount for amount in all_orders_amount_normalized[:buy_order_levels]]
|
||||||
|
sell_order_amounts_pct = [amount for amount in all_orders_amount_normalized[buy_order_levels:]]
|
||||||
|
buy_spread_distributions = [spread / 100 for spread in buy_spread_distributions]
|
||||||
|
sell_spread_distributions = [spread / 100 for spread in sell_spread_distributions]
|
||||||
|
return buy_spread_distributions, sell_spread_distributions, buy_order_amounts_pct, sell_order_amounts_pct
|
||||||
28
frontend/components/market_making_general_inputs.py
Normal file
28
frontend/components/market_making_general_inputs.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import streamlit as st
|
||||||
|
|
||||||
|
|
||||||
|
def get_market_making_general_inputs():
|
||||||
|
with st.expander("General Settings", expanded=True):
|
||||||
|
c1, c2, c3, c4, c5, c6, c7 = st.columns(7)
|
||||||
|
with c1:
|
||||||
|
connector_name = st.text_input("Connector", value="binance_perpetual",
|
||||||
|
help="Enter the name of the exchange to trade on (e.g., binance_perpetual).")
|
||||||
|
with c2:
|
||||||
|
trading_pair = st.text_input("Trading Pair", value="WLD-USDT",
|
||||||
|
help="Enter the trading pair to trade on (e.g., WLD-USDT).")
|
||||||
|
with c3:
|
||||||
|
leverage = st.number_input("Leverage", value=20,
|
||||||
|
help="Set the leverage to use for trading (e.g., 20 for 20x leverage). Set it to 1 for spot trading.")
|
||||||
|
with c4:
|
||||||
|
total_amount_quote = st.number_input("Total amount of quote", value=1000,
|
||||||
|
help="Enter the total amount in quote asset to use for trading (e.g., 1000).")
|
||||||
|
with c5:
|
||||||
|
position_mode = st.selectbox("Position Mode", ("HEDGE", "ONEWAY"), index=0,
|
||||||
|
help="Enter the position mode (HEDGE/ONEWAY).")
|
||||||
|
with c6:
|
||||||
|
cooldown_time = st.number_input("Cooldown Time (minutes)", value=60,
|
||||||
|
help="Specify the cooldown time in minutes (e.g., 60).") * 60
|
||||||
|
with c7:
|
||||||
|
executor_refresh_time = st.number_input("Executor Refresh Time (minutes)", value=60,
|
||||||
|
help="Enter the refresh time in minutes for executors (e.g., 60).") * 60
|
||||||
|
return connector_name, trading_pair, leverage, total_amount_quote, position_mode, cooldown_time, executor_refresh_time
|
||||||
27
frontend/components/risk_management.py
Normal file
27
frontend/components/risk_management.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import streamlit as st
|
||||||
|
from hummingbot.connector.connector_base import OrderType
|
||||||
|
|
||||||
|
|
||||||
|
def get_risk_management_inputs():
|
||||||
|
with st.expander("Risk Management", expanded=True):
|
||||||
|
c1, c2, c3, c4, c5, c6 = st.columns(6)
|
||||||
|
with c1:
|
||||||
|
sl = st.number_input("Stop Loss (%)", min_value=0.0, max_value=100.0, value=3.0, step=0.1,
|
||||||
|
help="Enter the stop loss as a percentage (e.g., 2.0 for 2%).") / 100
|
||||||
|
with c2:
|
||||||
|
tp = st.number_input("Take Profit (%)", min_value=0.0, max_value=100.0, value=2.0, step=0.1,
|
||||||
|
help="Enter the take profit as a percentage (e.g., 3.0 for 3%).") / 100
|
||||||
|
with c3:
|
||||||
|
time_limit = st.number_input("Time Limit (minutes)", min_value=0, value=60 * 6,
|
||||||
|
help="Enter the time limit in minutes (e.g., 360 for 6 hours).") * 60
|
||||||
|
with c4:
|
||||||
|
ts_ap = st.number_input("Trailing Stop Act. Price (%)", min_value=0.0, max_value=100.0, value=1.8,
|
||||||
|
step=0.1,
|
||||||
|
help="Enter the tr ailing stop activation price as a percentage (e.g., 1.0 for 1%).") / 100
|
||||||
|
with c5:
|
||||||
|
ts_delta = st.number_input("Trailing Stop Delta (%)", min_value=0.0, max_value=100.0, value=0.2, step=0.1,
|
||||||
|
help="Enter the trailing stop delta as a percentage (e.g., 0.3 for 0.3%).") / 100
|
||||||
|
with c6:
|
||||||
|
take_profit_order_type = st.selectbox("Take Profit Order Type", (OrderType.LIMIT, OrderType.MARKET),
|
||||||
|
help="Enter the order type for taking profit (LIMIT/MARKET).")
|
||||||
|
return sl, tp, time_limit, ts_ap, ts_delta, take_profit_order_type
|
||||||
@@ -6,7 +6,7 @@ from hummingbot.strategy_v2.utils.distributions import Distributions
|
|||||||
|
|
||||||
def normalize(values):
|
def normalize(values):
|
||||||
total = sum(values)
|
total = sum(values)
|
||||||
return [Decimal(val / total) for val in values]
|
return [val / total for val in values]
|
||||||
|
|
||||||
|
|
||||||
def distribution_inputs(column, dist_type_name, levels=3):
|
def distribution_inputs(column, dist_type_name, levels=3):
|
||||||
|
|||||||
Reference in New Issue
Block a user