diff --git a/INSTALLATION.md b/INSTALLATION.md new file mode 100644 index 0000000..e15cfb3 --- /dev/null +++ b/INSTALLATION.md @@ -0,0 +1,70 @@ +## Requirements + +You will need to install [StreamLit](https://streamlit.io/). For information about Streamlit installation, see the instructions located at https://docs.streamlit.io/library/get-started/installation. + +You will also need to install either [Anaconda](https://www.anaconda.com/) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html) to get Conda: +* [Anaconda](https://www.anaconda.com/) is a comprehensive Python distribution that includes a large number of pre-installed data science libraries and packages. It is designed to be an all-in-one solution for data science and machine learning tasks. When you install Anaconda, it comes with a collection of popular Python packages like NumPy, pandas, matplotlib, scikit-learn, and more. +* [Miniconda](https://docs.conda.io/en/latest/miniconda.html) is a minimal version of Anaconda. It includes only the essential components, such as Python interpreter and Conda package manager. Unlike Anaconda, Miniconda doesn't come with pre-installed packages, which makes its download size much smaller. + +This repository is maintained by Hummingbot Foundation as a companion for users of [Hummingbot](https://github.com/hummingbot/hummingbot), the open source framework for building high-frequency crypto trading bots. + +Watch this video to understand how it works: +https://www.loom.com/share/72d05bcbaf4048a399e3f9247d756a63 + +## Installation + +1. Install Steamlit and Conda packages utilizing their instructions for your specific environment: +* Install [StreamLit](https://docs.streamlit.io/library/get-started/installation) +* Install [Anaconda](https://docs.anaconda.com/free/anaconda/install/index.html) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html) + +2. Clone this repo and navigate to the created directory +```bash +git clone https://github.com/hummingbot/dashboard.git +cd dashboard +``` + +3. Run conda command to create an isolated `conda` environment and install dependencies +``` +conda env create -f environment_conda.yml +``` + +4. Activate the isoldated 'conda' environment +```bash +conda activate dashboard +``` + +5. Run the app +```bash +streamlit run main.py +``` + +## Data Feed + +Your `dashboard` environment needs to have access to the database for your Hummingbot environment. This is done by setting up a symbolic link to the 'data' directory of your running Hummingbot instance. + +The data directory differs for Docker versus Source installed Hummingbot. Data directory for each is as follows: +* Docker installed: /path/to/hummingbot/hummingbot_files/data +* Source installed: /path/to/hummingbot/data + + +Create a symlink to your Hummingbot `/data` directory +```bash +# replace `/path/to/hummingbotdata` with the actual path +ln -s /path/to/hummingbotdata data + +# if you need to remove the symlink +unlink data +``` + +## Updating Dependencies + +To update the `dashboard` environment for new dependencies, run: +``` +conda env update -f environment_conda.yml +``` + +To updated the `dashboard` source for latest version, run: +``` +cd dashboard +git pull +``` diff --git a/README.md b/README.md index 61ad099..fb41e71 100644 --- a/README.md +++ b/README.md @@ -1,129 +1,31 @@ -# Hummingbot Dashboard +Hummingbot Dashboard is a community project to build dashboards that help you deploy, manage, backtest, and analyze Hummingbot instances (and much more!) Each dashboard is maintained by 1-2 community members. -Collection of data visualization and analysis Hummingbot-related dashboards. The dashboards helps you run and manage Hummingbot, analyze performance, analyze trade data, and much more! - -Dashboard is built using [StreamLit](https://streamlit.io/) and uses the Conda environment & package manager to simiplify installation, updates, and manage dependencies. - -You will need to install [StreamLit](https://streamlit.io/). For information about Streamlit installation, see the instructions located at https://docs.streamlit.io/library/get-started/installation. - -You will also need to install either [Anaconda](https://www.anaconda.com/) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html) to get Conda: -* [Anaconda](https://www.anaconda.com/) is a comprehensive Python distribution that includes a large number of pre-installed data science libraries and packages. It is designed to be an all-in-one solution for data science and machine learning tasks. When you install Anaconda, it comes with a collection of popular Python packages like NumPy, pandas, matplotlib, scikit-learn, and more. -* [Miniconda](https://docs.conda.io/en/latest/miniconda.html) is a minimal version of Anaconda. It includes only the essential components, such as Python interpreter and Conda package manager. Unlike Anaconda, Miniconda doesn't come with pre-installed packages, which makes its download size much smaller. - -This repository is maintained by Hummingbot Foundation as a companion for users of [Hummingbot](https://github.com/hummingbot/hummingbot), the open source framework for building high-frequency crypto trading bots. - -Watch this video to understand how it works: -https://www.loom.com/share/72d05bcbaf4048a399e3f9247d756a63 - - - -## Dashboards +### Dashboards Here are the current dashboards in the collection: -### πŸš€ Strategy Performance (WIP) +* πŸš€ **Strategy Performance**: Analyze the performance of a running Hummingbot instance +* πŸ™ **Bot Orchestration**: Deploy and manage Hummingbot instances +* βš™οΈ **Backtest Manager**: Deploy and manage backtests of directional strategies +* πŸ—‚ **Candles Downloader**: Download historical exchange data as OHLVC candles. Supports multiple trading pairs and custom time ranges/intervals. +* πŸ” **DB Inspector**: Inspect and analyze the orders and trades data contained in a Hummingbot strategy database +* πŸ§™ **Token Spreads**: Identify cross-exchange trading opportunities by analyzing differences in token spreads across venues +* πŸ¦‰ **TVL vs MCAPs**: Easily compare various DeFi protocols based on their market capitalization and total value locked, using DeFiLlama data. -Dashboard that helps you analyze the performance of a running Hummingbot instance +### Installation -### πŸ§™ XE Token Analyzer +This project is built using [StreamLit](https://streamlit.io/) and uses Anaconda and Docker to simplify installation, updates, and manage dependencies. -Dashboard that helps you visualize the bid-ask spread and volume of different tokens across the crypto exchange landscape. +See [Installation](https://github.com/hummingbot/dashboard/blob/feat/base-page-class/INSTALLATION.md) for how to install and update the dashboard. -This app is most helpful for Hummingbot users running the [Cross-Exchange Market Making](https://hummingbot.org/strategies/cross-exchange-market-making/) and [Arbitrage](https://hummingbot.org/strategies/arbitrage/) strategies. +### Contributions -### 🧳 Hummingbot DB +We welcome contributions from the community! See [Contribution](https://github.com/hummingbot/dashboard/blob/feat/base-page-class/CONTRIBUTING.md) for more information. -Inspect and analyze the orders and trades data contained in a SQLite database for a strategy or script. - -These files are located in the `/data` folder in Hummingbot, and are named `.sqlite`. - -### πŸ¦‰ TVL vs MCAP Analysis - -Easily compare various DeFi protocols based on their market capitalization and total value locked, using DeFiLlama data. - -### πŸ—‚ Candles Downloader - -Download historical exchange data as OHLVC candles. Supports multiple trading pairs and custom time ranges/intervals. - -Current Hummingbot connectors supported: -* `binance` -* `binance_perpetual` - -### πŸ“‹ Data - -Reference data for the various apps this collection. - -## Installation - -1. Install Steamlit and Conda packages utilizing their instructions for your specific environment: -* Install [StreamLit](https://docs.streamlit.io/library/get-started/installation) -* Install [Anaconda](https://docs.anaconda.com/free/anaconda/install/index.html) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html) - -2. Clone this repo and navigate to the created directory -```bash -git clone https://github.com/hummingbot/dashboard.git -cd dashboard -``` - -3. Run conda command to create an isolated `conda` environment and install dependencies -``` -conda env create -f environment_conda.yml -``` - -4. Activate the isoldated 'conda' environment -```bash -conda activate dashboard -``` - -5. Run the app -```bash -streamlit run main.py -``` - -## Data Feed - -Your `dashboard` environment needs to have access to the database for your Hummingbot environment. This is done by setting up a symbolic link to the 'data' directory of your running Hummingbot instance. - -The data directory differs for Docker versus Source installed Hummingbot. Data directory for each is as follows: -* Docker installed: /path/to/hummingbot/hummingbot_files/data -* Source installed: /path/to/hummingbot/data - - -Create a symlink to your Hummingbot `/data` directory -```bash -# replace `/path/to/hummingbotdata` with the actual path -ln -s /path/to/hummingbotdata data - -# if you need to remove the symlink -unlink data -``` - - - -## Updates - -To update the `dashboard` environment for new dependencies, run: -``` -conda env update -f environment_conda.yml -``` - -To updated the `dashboard` source for latest version, run: -``` -cd dashboard -git pull -``` - -## Contributions - -We welcome new data dashboards, bug fixes, and improvements by the community! - -To submit a contribution, fork a clone of repository, add or make changes, and issue a pull request. See general guidelines for contributing to Hummingbot listed at https://hummingbot.org/developers/contributions. - - -## Participation +### Meetings We hold bi-weekly livestream Dashboard project meetings. You can participate on our [Discord](https://discord.gg/hummingbot) -* Alternating Thursdays, 3pm GMT / 11am EST / 8am PST / 11pm SIN +* Alternating Wenesdays, 3pm GMT / 11am EST / 8am PST / 11pm SIN * Design, Status, Demos, etc diff --git a/environment_conda.yml b/environment_conda.yml index 82286d9..793e779 100644 --- a/environment_conda.yml +++ b/environment_conda.yml @@ -19,6 +19,8 @@ dependencies: - jupyter - optuna - optuna-dashboard + - pathlib - streamlit-ace + - st-pages - git+https://github.com/hummingbot/hbot-remote-client-py.git - git+https://github.com/hummingbot/docker-manager.git diff --git a/main.py b/main.py index b9f4047..9219568 100644 --- a/main.py +++ b/main.py @@ -1,19 +1,27 @@ import streamlit as st +from st_pages import Page, show_pages -apptitle = "High Frequency Trading" -st.set_page_config(page_title=apptitle, page_icon="πŸ¦…", layout="wide") +from utils.st_utils import initialize_st_page + + +initialize_st_page(title="Hummingbot Dashboard", icon="πŸ“Š") + +show_pages( + [ + Page("main.py", "Hummingbot Dashboard", "πŸ“Š"), + Page("pages/strategy_performance/app.py", "Strategy Performance", "πŸš€"), + Page("pages/bot_orchestration/app.py", "Bot Orchestration", "πŸ™"), + Page("pages/backtest_manager/app.py", "Backtest Manager", "βš™οΈ"), + Page("pages/candles_downloader/app.py", "Candles Downloader", "πŸ—‚"), + Page("pages/db_inspector/app.py", "DB Inspector", "πŸ”"), + Page("pages/token_spreads/app.py", "Token Spreads", "πŸ§™"), + Page("pages/tvl_vs_mcap/app.py", "TVL vs Market Cap", "πŸ¦‰"), + ] +) -st.title("Welcome!") -st.write("---") -st.code("πŸ’‘ The purpose of this dashboard is to provide useful information for high frequency trading traders") -st.write("") st.write("Watch this video to understand how the dashboard works! πŸ¦…") c1, c2, c3 = st.columns([1, 6, 1]) with c2: st.video("https://youtu.be/l6PWbN2pDK8") st.write("If you want to contribute, post your idea in #dev-channel of [hummingbot discord](https://discord.gg/CjxZtkrH)") st.write("---") - - - - diff --git a/pages/backtest_manager/README.md b/pages/backtest_manager/README.md new file mode 100644 index 0000000..e11eabf --- /dev/null +++ b/pages/backtest_manager/README.md @@ -0,0 +1 @@ +Deploy and manage backtests of directional strategies \ No newline at end of file diff --git a/pages/9_βš™οΈ_Backtesting.py b/pages/backtest_manager/app.py similarity index 98% rename from pages/9_βš™οΈ_Backtesting.py rename to pages/backtest_manager/app.py index e768cf7..583e0d6 100644 --- a/pages/9_βš™οΈ_Backtesting.py +++ b/pages/backtest_manager/app.py @@ -12,16 +12,15 @@ from utils.file_templates import strategy_optimization_template, directional_str from utils.os_utils import load_directional_strategies, save_file, get_function_from_file import optuna -st.set_page_config( - page_title="Hummingbot Dashboard", - page_icon="πŸš€", - layout="wide", -) +from utils.st_utils import initialize_st_page + + +initialize_st_page(title="Backtest Manager", icon="βš™οΈ") + +# Start content here if "strategy_params" not in st.session_state: st.session_state.strategy_params = {} -st.title("βš™οΈ Backtesting") - create, modify, backtest, optimize, analyze = st.tabs(["Create", "Modify", "Backtest", "Optimize", "Analyze"]) with create: diff --git a/pages/bot_orchestration/README.md b/pages/bot_orchestration/README.md new file mode 100644 index 0000000..6667358 --- /dev/null +++ b/pages/bot_orchestration/README.md @@ -0,0 +1 @@ +Deploy and manage Hummingbot instances \ No newline at end of file diff --git a/pages/8_πŸ™_Bot_Orchestration.py b/pages/bot_orchestration/app.py similarity index 96% rename from pages/8_πŸ™_Bot_Orchestration.py rename to pages/bot_orchestration/app.py index dc3b8ab..92920a7 100644 --- a/pages/8_πŸ™_Bot_Orchestration.py +++ b/pages/bot_orchestration/app.py @@ -1,21 +1,17 @@ import time - -import pandas as pd -from hbotrc import BotCommands -import streamlit as st -from docker_manager import DockerManager - import constants +import pandas as pd +import streamlit as st -st.set_page_config( - page_title="Hummingbot Dashboard", - page_icon=":bar_chart:", - layout="wide", - initial_sidebar_state="collapsed" -) -st.title("πŸ™ Bot Orchestration") -st.write("---") +from docker_manager import DockerManager +from hbotrc import BotCommands +from utils.st_utils import initialize_st_page + + +initialize_st_page(title="Bot Orchestration", icon="πŸ™") + +# Start content here docker_manager = DockerManager() active_containers = docker_manager.get_active_containers() diff --git a/pages/candles_downloader/README.md b/pages/candles_downloader/README.md new file mode 100644 index 0000000..1d08d65 --- /dev/null +++ b/pages/candles_downloader/README.md @@ -0,0 +1 @@ +Download historical exchange data as OHLVC candles. Supports multiple trading pairs and custom time ranges/intervals. \ No newline at end of file diff --git a/pages/6_πŸ—‚_Candles_Downloader.py b/pages/candles_downloader/app.py similarity index 94% rename from pages/6_πŸ—‚_Candles_Downloader.py rename to pages/candles_downloader/app.py index 7d33ca2..ecc11cf 100644 --- a/pages/6_πŸ—‚_Candles_Downloader.py +++ b/pages/candles_downloader/app.py @@ -7,14 +7,13 @@ import constants from utils import os_utils from docker_manager import DockerManager -st.set_page_config( - page_title="Candles Downloader", - page_icon=":bar_chart:", - layout="wide", -) +from utils.st_utils import initialize_st_page + + +initialize_st_page(title="Candles Downloader", icon="πŸ—‚οΈ") + +# Start content here docker_manager = DockerManager() -st.write(f"# πŸ—‚οΈ Candles Downloader") -st.write("---") c1, c2, c3 = st.columns([2, 2, 0.5]) with c1: diff --git a/pages/db_inspector/README.md b/pages/db_inspector/README.md new file mode 100644 index 0000000..2b0b7ca --- /dev/null +++ b/pages/db_inspector/README.md @@ -0,0 +1 @@ +Inspect and analyze the orders and trades data contained in a Hummingbot strategy database \ No newline at end of file diff --git a/pages/4_🧳_Hummingbot_DB.py b/pages/db_inspector/app.py similarity index 88% rename from pages/4_🧳_Hummingbot_DB.py rename to pages/db_inspector/app.py index cee4233..bde870f 100644 --- a/pages/4_🧳_Hummingbot_DB.py +++ b/pages/db_inspector/app.py @@ -3,6 +3,12 @@ import streamlit as st import sqlite3 import pandas as pd +from utils.st_utils import initialize_st_page + + +initialize_st_page(title="DB Inspector", icon="πŸ”") + +# Start content here @st.cache_data def get_table_data(database_name: str, table_name: str): conn = sqlite3.connect(database_name) @@ -17,9 +23,6 @@ def get_all_tables(database_name: str): tables = [table_row[0] for table_row in cursor.fetchall()] return tables -st.set_page_config(layout='wide') -st.title("🧳 Hummingbot Database Analyzer") -st.write("---") uploaded_file = st.file_uploader("Add your database") if uploaded_file is not None: diff --git a/pages/7_πŸ“‹_Data.py b/pages/reference_data/7_πŸ“‹_Data.py similarity index 92% rename from pages/7_πŸ“‹_Data.py rename to pages/reference_data/7_πŸ“‹_Data.py index 70786ba..c75547e 100644 --- a/pages/7_πŸ“‹_Data.py +++ b/pages/reference_data/7_πŸ“‹_Data.py @@ -3,30 +3,30 @@ import streamlit as st import CONFIG from utils.coingecko_utils import CoinGeckoUtils from utils.miner_utils import MinerUtils +from utils.st_utils import initialize_st_page + @st.cache_data def get_all_coins_df(): return CoinGeckoUtils().get_all_coins_df() + @st.cache_data def get_all_exchanges_df(): return CoinGeckoUtils().get_all_exchanges_df() + @st.cache_data def get_miner_stats_df(): return MinerUtils().get_miner_stats_df() + @st.cache_data def get_coin_tickers_by_id_list(coins_id: list): return CoinGeckoUtils().get_coin_tickers_by_id_list(coins_id) -st.set_page_config( - page_title="Crypto Data", - page_icon=":bar_chart:", - layout="wide", - initial_sidebar_state="collapsed" -) -st.title("πŸ“‹ Data Available") + +initialize_st_page(title="Crypto Data", icon=":bar_chart:") with st.spinner(text='In progress'): exchanges_df = get_all_exchanges_df() diff --git a/pages/strategy_performance/README.md b/pages/strategy_performance/README.md new file mode 100644 index 0000000..77acd50 --- /dev/null +++ b/pages/strategy_performance/README.md @@ -0,0 +1 @@ +This page helps you load the database file of a Hummingbot strategy and analyze its performance. \ No newline at end of file diff --git a/pages/2_πŸš€_Strategy_Performance.py b/pages/strategy_performance/app.py similarity index 97% rename from pages/2_πŸš€_Strategy_Performance.py rename to pages/strategy_performance/app.py index 963bc22..629565a 100644 --- a/pages/2_πŸš€_Strategy_Performance.py +++ b/pages/strategy_performance/app.py @@ -1,19 +1,15 @@ import os - import pandas as pd import streamlit as st from utils.database_manager import DatabaseManager from utils.graphs import CandlesGraph +from utils.st_utils import initialize_st_page -st.set_page_config( - page_title="Hummingbot Dashboard", - page_icon=":bar_chart:", - layout="wide", - initial_sidebar_state="collapsed" -) -st.title("πŸš€ Strategy Performance") +initialize_st_page(title="Strategy Performance", icon="πŸš€") + +# Start content here intervals = { "1m": 60, "3m": 60 * 3, @@ -25,6 +21,7 @@ intervals = { "1d": 60 * 60 * 24, } + @st.cache_resource def get_database(db_name: str): db_manager = DatabaseManager(db_name) diff --git a/pages/token_spreads/README.md b/pages/token_spreads/README.md new file mode 100644 index 0000000..4225df8 --- /dev/null +++ b/pages/token_spreads/README.md @@ -0,0 +1 @@ +Identify cross-exchange trading opportunities by analyzing differences in token spreads across venues \ No newline at end of file diff --git a/pages/3_πŸ§™_XE_Token_Analyzer.py b/pages/token_spreads/app.py similarity index 84% rename from pages/3_πŸ§™_XE_Token_Analyzer.py rename to pages/token_spreads/app.py index 9cfbfb9..1fa8eb0 100644 --- a/pages/3_πŸ§™_XE_Token_Analyzer.py +++ b/pages/token_spreads/app.py @@ -1,10 +1,15 @@ -import pandas as pd import streamlit as st +from pathlib import Path import plotly.express as px import CONFIG from utils.coingecko_utils import CoinGeckoUtils from utils.miner_utils import MinerUtils +from utils.st_utils import initialize_st_page + +initialize_st_page(title="Token Spreads", icon="πŸ§™") + +# Start content here cg_utils = CoinGeckoUtils() miner_utils = MinerUtils() @@ -24,10 +29,6 @@ def get_miner_stats_df(): def get_coin_tickers_by_id_list(coins_id: list): return cg_utils.get_coin_tickers_by_id_list(coins_id) -st.set_page_config(layout='wide') -st.title("πŸ§™β€Cross Exchange Token Analyzer") -st.write("---") - with st.spinner(text='In progress'): exchanges_df = get_all_exchanges_df() coins_df = get_all_coins_df() @@ -35,7 +36,6 @@ with st.spinner(text='In progress'): miner_coins = coins_df.loc[coins_df["symbol"].isin(miner_stats_df["base"].str.lower().unique()), "name"] -st.write("### Coins filter πŸ¦…") tokens = st.multiselect( "Select the tokens to analyze:", options=coins_df["name"], @@ -47,8 +47,7 @@ coins_id = coins_df.loc[coins_df["name"].isin(tokens), "id"].tolist() 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.sidebar.write("### Exchanges filter πŸ¦…") -exchanges = st.sidebar.multiselect( +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()] @@ -75,6 +74,6 @@ fig = px.scatter( } ) -st.sidebar.write("# Data filters 🏷") -st.sidebar.code("🧳 New filters coming. \nReach us on discord \nif you want to propose one!") +# st.write("# Data filters 🏷") +# st.code("🧳 New filters coming. \nReach us on discord \nif you want to propose one!") st.plotly_chart(fig, use_container_width=True) diff --git a/pages/tvl_vs_mcap/README.md b/pages/tvl_vs_mcap/README.md new file mode 100644 index 0000000..251fc88 --- /dev/null +++ b/pages/tvl_vs_mcap/README.md @@ -0,0 +1,3 @@ +Easily compare various DeFi protocols based on their market capitalization and total value locked, using DeFiLlama data. + +Data Source: [DefiLlama](https://defillama.com/) diff --git a/pages/5_πŸ¦‰_TVL_vs_MCAP_Analysis.py b/pages/tvl_vs_mcap/app.py similarity index 72% rename from pages/5_πŸ¦‰_TVL_vs_MCAP_Analysis.py rename to pages/tvl_vs_mcap/app.py index 19879f0..e553e46 100644 --- a/pages/5_πŸ¦‰_TVL_vs_MCAP_Analysis.py +++ b/pages/tvl_vs_mcap/app.py @@ -4,6 +4,12 @@ import pandas as pd import plotly.express as px from defillama import DefiLlama +from utils.st_utils import initialize_st_page + + +initialize_st_page(title="TVL vs Market Cap", icon="πŸ¦‰") + +# Start content here MIN_TVL = 1000000. MIN_MCAP = 1000000. @@ -17,18 +23,13 @@ def get_tvl_mcap_data(): def get_protocols_by_chain_category(protocols: pd.DataFrame, group_by: list, nth: list): return protocols.sort_values('tvl', ascending=False).groupby(group_by).nth(nth).reset_index() -st.set_page_config(layout='wide') -st.title("πŸ¦‰ TVL vs MCAP Analysis") -st.write("---") -st.code("πŸ’‘ Source: [DefiLlama](https://defillama.com/)") - with st.spinner(text='In progress'): tvl_mcap_df = get_tvl_mcap_data() default_chains = ["Ethereum", "Solana", "Binance", "Polygon", "Multi-Chain", "Avalanche"] -st.sidebar.write("### Chains filter πŸ”—") -chains = st.sidebar.multiselect( +st.write("### Chains πŸ”—") +chains = st.multiselect( "Select the chains to analyze:", options=tvl_mcap_df["chain"].unique(), default=default_chains) @@ -52,10 +53,10 @@ scatter = px.scatter( st.plotly_chart(scatter, use_container_width=True) -st.sidebar.write("---") -st.sidebar.write("### SunBurst filter πŸ”—") -groupby = st.sidebar.selectbox('Group by:', [['chain', 'category'], ['category', 'chain']]) -nth = st.sidebar.slider('Top protocols by Category', min_value=1, max_value=5) +st.write("---") +st.write("### SunBurst 🌞") +groupby = st.selectbox('Group by:', [['chain', 'category'], ['category', 'chain']]) +nth = st.slider('Top protocols by Category', min_value=1, max_value=5) proto_agg = get_protocols_by_chain_category(tvl_mcap_df[tvl_mcap_df["chain"].isin(chains)], groupby, np.arange(0, nth, 1).tolist()) groupby.append("slug") @@ -67,7 +68,4 @@ sunburst = px.sunburst( title="SunBurst", template="plotly_dark",) -st.plotly_chart(sunburst, use_container_width=True) - -st.sidebar.write("# Data filters 🏷") -st.sidebar.code("🧳 New filters coming. \nReach us on discord \nif you want to propose one!") +st.plotly_chart(sunburst, use_container_width=True) \ No newline at end of file diff --git a/utils/st_utils.py b/utils/st_utils.py new file mode 100644 index 0000000..51800d1 --- /dev/null +++ b/utils/st_utils.py @@ -0,0 +1,20 @@ +import os.path +from pathlib import Path +import inspect + +import streamlit as st + + +def initialize_st_page(title: str, icon: str, layout="wide"): + st.set_page_config( + page_title=title, + page_icon=icon, + layout=layout, + ) + st.title(f"{icon} {title}") + caller_frame = inspect.currentframe().f_back + + current_directory = Path(os.path.dirname(inspect.getframeinfo(caller_frame).filename)) + readme_path = current_directory / "README.md" + with st.expander("About This Page"): + st.write(readme_path.read_text())