(feat) refactor pages structure

This commit is contained in:
cardosofede
2024-05-16 13:17:37 -04:00
parent c7ecf7da49
commit b1635de38d
69 changed files with 21 additions and 162 deletions

View File

@@ -1,14 +1,14 @@
import streamlit as st
from frontend.components.st_inputs import initialize_st_page
from backend.services.backend_api_client import BackendAPIClient
from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT
# Import submodules
from frontend.pages.pmm_simple.user_inputs import user_inputs
from frontend.pages.pmm_simple.order_calculation import calculate_orders
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.pmm_simple.config_handling import handle_config
from frontend.pages.config.pmm_simple import handle_config
from frontend.components.backtesting import backtesting_section
from frontend.st_utils import initialize_st_page
# Initialize the Streamlit page
initialize_st_page(title="PMM Simple", icon="👨‍🏫", initial_sidebar_state="collapsed")

View File

@@ -1,19 +0,0 @@
### Description
This page helps you deploy and manage Hummingbot instances:
- Starting and stopping Hummingbot Broker
- Creating, starting and stopping bot instances
- Managing strategy and script files that instances run
- Fetching status of running instances
### Maintainers
This page is maintained by Hummingbot Foundation as a template other pages:
* [cardosfede](https://github.com/cardosfede)
* [fengtality](https://github.com/fengtality)
### Wiki
See the [wiki](https://github.com/hummingbot/dashboard/wiki/%F0%9F%90%99-Bot-Orchestration) for more information.

View File

@@ -1,43 +0,0 @@
from types import SimpleNamespace
import streamlit as st
from streamlit_elements import elements, mui
from frontend.components.dashboard import Dashboard
from frontend.components.editor import Editor
from frontend.components.launch_master_bot_card import LaunchMasterBotCard
from frontend.components.master_conf_file_explorer import MasterConfFileExplorer
from frontend.st_utils import initialize_st_page
initialize_st_page(title="Credentials", icon="🗝️", initial_sidebar_state="collapsed")
if "mc_board" not in st.session_state:
board = Dashboard()
mc_board = SimpleNamespace(
dashboard=board,
launch_master_bot=LaunchMasterBotCard(board, 0, 0, 12, 2),
file_explorer=MasterConfFileExplorer(board, 0, 4, 3, 7),
editor=Editor(board, 4, 4, 9, 7),
)
st.session_state.mc_board = mc_board
else:
mc_board = st.session_state.mc_board
# Add new tabs
for tab_name, content in mc_board.file_explorer.tabs.items():
if tab_name not in mc_board.editor.tabs:
mc_board.editor.add_tab(tab_name, content["content"], content["language"])
# Remove deleted tabs
for tab_name in list(mc_board.editor.tabs.keys()):
if tab_name not in mc_board.file_explorer.tabs:
mc_board.editor.remove_tab(tab_name)
with elements("file_manager"):
with mui.Paper(elevation=3, style={"padding": "2rem"}, spacing=[2, 2], container=True):
with mc_board.dashboard():
mc_board.launch_master_bot()
mc_board.file_explorer()
mc_board.editor()

View File

View File

@@ -1,74 +0,0 @@
import streamlit as st
import CONFIG
from backend.services.coingecko_client import CoinGeckoClient
from backend.services.miner_client import MinerClient
from frontend.st_utils import initialize_st_page
@st.cache_data
def get_all_coins_df():
return CoinGeckoClient().get_all_coins_df()
@st.cache_data
def get_all_exchanges_df():
return CoinGeckoClient().get_all_exchanges_df()
@st.cache_data
def get_miner_stats_df():
return MinerClient().get_miner_stats_df()
@st.cache_data
def get_coin_tickers_by_id_list(coins_id: list):
return CoinGeckoClient().get_coin_tickers_by_id_list(coins_id)
initialize_st_page(title="Crypto Data", icon=":bar_chart:")
with st.spinner(text='In progress'):
exchanges_df = get_all_exchanges_df()
coins_df = get_all_coins_df()
miner_stats_df = get_miner_stats_df()
data = st.container()
with data:
data.write("Data loaded successfully!")
miner_coins = coins_df.loc[coins_df["symbol"].isin(miner_stats_df["base"].str.lower().unique()), "name"]
default_miner_coins = ["Avalanche"]
st.write("---")
st.write("## Exchanges and coins data")
with st.expander('Coins data'):
st.dataframe(coins_df)
with st.expander('Exchanges data'):
st.dataframe(exchanges_df)
st.write("---")
st.write("## Tickers filtered")
st.write("### Coins filter 🦅")
tokens = st.multiselect(
"Select the tokens to analyze:",
options=coins_df["name"],
default=default_miner_coins)
coins_id = coins_df.loc[coins_df["name"].isin(tokens), "id"].tolist()
with st.spinner(text='Loading coin tickers data...'):
coin_tickers_df = get_coin_tickers_by_id_list(coins_id)
coin_tickers_df["coin_name"] = coin_tickers_df.apply(lambda x: coins_df.loc[coins_df["id"] == x.token_id, "name"].item(), axis=1)
st.write("### Exchanges filter 🦅")
exchanges = st.multiselect(
"Select the exchanges to analyze:",
options=exchanges_df["name"],
default=[exchange for exchange in CONFIG.MINER_EXCHANGES if exchange in exchanges_df["name"].unique()])
with st.expander('Coins Tickers Data'):
st.dataframe(coin_tickers_df)

39
main.py
View File

@@ -11,31 +11,26 @@ def main_page():
[
Page("main.py", "Hummingbot Dashboard", "📊"),
Section("Bot Orchestration", "🐙"),
Page("frontend/pages/bot_orchestration/app.py", "Instances", "🦅"),
Page("frontend/pages/launch_bot/app.py", "Deploy", "🚀"),
Section("Config Generator", "🎛️"),
Page("frontend/pages/pmm_simple/app.py", "PMM Simple", "👨‍🏫"),
Page("frontend/pages/dman_maker_v2/app.py", "D-Man Maker V2", "🤖"),
Page("frontend/pages/bollinger_v1/app.py", "Bollinger V1", "📈"),
# Page("frontend/pages/trend_follower_v1/app.py", "Trend Follower V1", "📈"),
# Page("frontend/pages/kalman_filter_v1/app.py", "Kalman Filter V1", "👨‍🔬"),
Page("frontend/pages/macd_bb_v1/app.py", "MACD_BB V1", "📊"),
# Page("frontend/pages/dman_v5/app.py", "D-Man V5", "📊"),
Page("frontend/pages/xemm_controller/app.py", "XEMM Controller", "⚡️"),
Page("frontend/pages/position_builder/app.py", "Position Builder", "🔭"),
Page("frontend/pages/dynamic_position_builder/app.py", "Dynamic Position Builder", "🔭"),
# Page("pages/master_conf/app.py", "Credentials", "🗝️"),
Page("frontend/pages/orchestration/instances/app.py", "Instances", "🦅"),
Page("frontend/pages/orchestration/launch_bot_v2/app.py", "Deploy", "🚀"),
# Page("pages/file_manager/app.py", "File Explorer", "🗂"),
Section("Config Generator", "🎛️"),
Page("frontend/pages/config/pmm_simple/app.py", "PMM Simple", "👨‍🏫"),
Page("frontend/pages/config/dman_maker_v2/app.py", "D-Man Maker V2", "🤖"),
Page("frontend/pages/config/bollinger_v1/app.py", "Bollinger V1", "📈"),
Page("frontend/pages/config/macd_bb_v1/app.py", "MACD_BB V1", "📊"),
Page("frontend/pages/config/xemm_controller/app.py", "XEMM Controller", "⚡️"),
Page("frontend/pages/config/position_builder/app.py", "Position Builder", "🔭"),
Section("Data", "💾"),
Page("frontend/pages/data_download_candles/app.py", "Download Candles", "💹"),
# Page("pages/backtest_create/create.py", "Create", "⚔️"),
# Page("pages/backtest_optimize/optimize.py", "Optimize", "🧪"),
# Page("pages/backtest_analyze/analyze.py", "Analyze", "🔬"),
Page("frontend/pages/data/download_candles/app.py", "Download Candles", "💹"),
# Page("pages/create/create.py", "Create", "⚔️"),
# Page("pages/optimize/optimize.py", "Optimize", "🧪"),
# Page("pages/analyze/analyze.py", "Analyze", "🔬"),
Section("Community Pages", "👨‍👩‍👧‍👦"),
Page("frontend/pages/strategy_performance/app.py", "Strategy Performance", "🚀"),
Page("frontend/pages/db_inspector/app.py", "DB Inspector", "🔍"),
Page("frontend/pages/token_spreads/app.py", "Token Spreads", "🧙"),
Page("frontend/pages/tvl_vs_mcap/app.py", "TVL vs Market Cap", "🦉"),
Page("frontend/pages/performance/strategy_performance/app.py", "Strategy Performance", "🚀"),
Page("frontend/pages/performance/db_inspector/app.py", "DB Inspector", "🔍"),
Page("frontend/pages/data/token_spreads/app.py", "Token Spreads", "🧙"),
Page("frontend/pages/data/tvl_vs_mcap/app.py", "TVL vs Market Cap", "🦉"),
]
)