From 222c3e7f2ec641f0e15bae754f621ab4d43d1f2a Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Sat, 22 Jul 2023 09:37:09 -0400 Subject: [PATCH 01/10] (feat) initial base page --- environment_conda.yml | 1 + main.py | 32 +++++++++++++++++--------------- page.py | 16 ++++++++++++++++ 3 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 page.py diff --git a/environment_conda.yml b/environment_conda.yml index 82286d94..d9a027af 100644 --- a/environment_conda.yml +++ b/environment_conda.yml @@ -19,6 +19,7 @@ dependencies: - jupyter - optuna - optuna-dashboard + - pathlib - streamlit-ace - 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 b9f4047c..e34f8ce6 100644 --- a/main.py +++ b/main.py @@ -1,19 +1,21 @@ import streamlit as st +from pathlib import Path +from page import Page -apptitle = "High Frequency Trading" -st.set_page_config(page_title=apptitle, page_icon="πŸ¦…", layout="wide") - -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("---") - - +class HummingbotDashboardPage(Page): + def __init__(self): + super().__init__("Hummingbot Dashboard", Path("README.md").read_text()) + def write_page(self): + super().write_page() + 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)") +if __name__ == "__main__": + page = HummingbotDashboardPage() + page.write_page() \ No newline at end of file diff --git a/page.py b/page.py new file mode 100644 index 00000000..91d60e87 --- /dev/null +++ b/page.py @@ -0,0 +1,16 @@ +import streamlit as st + +class Page: + def __init__(self, title, description, icon="πŸ¦…", layout="wide"): + self.title = title + self.description = description + self.icon = icon + self.layout = layout + + def write_page(self): + st.set_page_config(page_title=self.title, page_icon=self.icon, layout=self.layout) + st.title(self.title) + st.write("---") + with st.expander("About This Page"): + st.write(self.description) + st.write("---") From c0d49d7061f1d23233e0ea7e40ae50bc5ad3ed4b Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Sat, 22 Jul 2023 16:42:10 -0400 Subject: [PATCH 02/10] (wip) test st-pages --- INSTALLATION.md | 70 +++++++++++ README.md | 117 ++---------------- environment_conda.yml | 1 + main.py | 54 +++++--- pages/strategy_performance/README.md | 1 + .../strategy_performance/app.py | 17 ++- 6 files changed, 133 insertions(+), 127 deletions(-) create mode 100644 INSTALLATION.md create mode 100644 pages/strategy_performance/README.md rename "pages/2_\360\237\232\200_Strategy_Performance.py" => pages/strategy_performance/app.py (95%) diff --git a/INSTALLATION.md b/INSTALLATION.md new file mode 100644 index 00000000..e15cfb3a --- /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 61ad099c..a7b4a203 100644 --- a/README.md +++ b/README.md @@ -4,126 +4,31 @@ Collection of data visualization and analysis Hummingbot-related dashboards. The 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 Here are the current dashboards in the collection: -### πŸš€ Strategy Performance (WIP) - -Dashboard that helps you analyze the performance of a running Hummingbot instance - -### πŸ§™ XE Token Analyzer - -Dashboard that helps you visualize the bid-ask spread and volume of different tokens across the crypto exchange landscape. - -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. - -### 🧳 Hummingbot DB - -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. +* πŸš€ **Strategy Performance**: Analyze the performance of a running Hummingbot instance +* πŸ™ **Bot Orchestration**: Deploy and manage Hummingbot instances +* πŸ§™ **XE Token Analyzer**: Identify cross-exchange trading opportunities by analyzing differences in token spreads across venues +* βš™οΈ **Backtesting**: Deploy and manage backtests of directional strategies +* 🧳 **Hummingbot DB**: Inspect and analyze the orders and trades data contained in a SQLite database for a strategy or script +* πŸ¦‰ **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. +* πŸ“‹ **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 -``` +See [Installation](https://github.com/hummingbot/dashboard/INSTALLATION.md) for how to install and update the dashboard. ## 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. - +We welcome contributions from the community! See [Contribution](https://github.com/hummingbot/dashboard/CONTRIBUTION.md) for more information. ## Participation 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 d9a027af..793e779f 100644 --- a/environment_conda.yml +++ b/environment_conda.yml @@ -21,5 +21,6 @@ dependencies: - 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 e34f8ce6..70ff5793 100644 --- a/main.py +++ b/main.py @@ -1,21 +1,43 @@ import streamlit as st from pathlib import Path -from page import Page +from st_pages import Page, show_pages -class HummingbotDashboardPage(Page): - def __init__(self): - super().__init__("Hummingbot Dashboard", Path("README.md").read_text()) +title = "Hummingbot Dashboard" +icon = "πŸ“Š" - def write_page(self): - super().write_page() - 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.set_page_config( + page_title=title, + page_icon=icon, + layout="wide", +) +st.title(f"{icon} {title}") -if __name__ == "__main__": - page = HummingbotDashboardPage() - page.write_page() \ No newline at end of file +current_directory = Path(__file__).parent +readme_path = current_directory / "README.md" +with st.expander("About This Page"): + st.write(readme_path.read_text()) + +show_pages( + [ + Page("main.py", "Hummingbot Dashboard", "πŸ“Š"), + Page("pages/strategy_performance/app.py", "Strategy Performance", "πŸš€"), + # # The pages appear in the order you pass them + # Page("example_app/example_four.py", "Example Four", "πŸ“–"), + # Page("example_app/example_two.py", "Example Two", "✏️"), + # # Will use the default icon and name based on the filename if you don't + # # pass them + # Page("example_app/example_three.py"), + # Page("example_app/example_five.py", "Example Five", "🧰"), + ] +) + +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/strategy_performance/README.md b/pages/strategy_performance/README.md new file mode 100644 index 00000000..77acd505 --- /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_\360\237\232\200_Strategy_Performance.py" b/pages/strategy_performance/app.py similarity index 95% rename from "pages/2_\360\237\232\200_Strategy_Performance.py" rename to pages/strategy_performance/app.py index 963bc227..af2dc059 100644 --- "a/pages/2_\360\237\232\200_Strategy_Performance.py" +++ b/pages/strategy_performance/app.py @@ -1,18 +1,25 @@ import os - import pandas as pd import streamlit as st +from pathlib import Path from utils.database_manager import DatabaseManager from utils.graphs import CandlesGraph +title = "Strategy Performance" +icon = "πŸš€" + st.set_page_config( - page_title="Hummingbot Dashboard", - page_icon=":bar_chart:", + page_title=title, + page_icon=icon, layout="wide", - initial_sidebar_state="collapsed" ) -st.title("πŸš€ Strategy Performance") +st.title(f"{icon} {title}") + +current_directory = Path(__file__).parent +readme_path = current_directory / "README.md" +with st.expander("About This Page"): + st.write(readme_path.read_text()) intervals = { "1m": 60, From 368061c04b5a8ac651eda543ddce5f62c9400839 Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Sat, 22 Jul 2023 17:10:11 -0400 Subject: [PATCH 03/10] (wip) added more pages --- README.md | 11 ++++---- main.py | 9 ++----- pages/backtesting/README.md | 1 + .../backtesting/app.py | 20 ++++++++++++--- pages/bot_orchestration/README.md | 1 + .../bot_orchestration/app.py | 25 +++++++++++++------ .../6_\360\237\227\202_Candles_Downloader.py" | 0 .../4_\360\237\247\263_Hummingbot_DB.py" | 0 .../7_\360\237\223\213_Data.py" | 0 pages/strategy_performance/app.py | 3 +++ .../3_\360\237\247\231_XE_Token_Analyzer.py" | 0 ..._\360\237\246\211_TVL_vs_MCAP_Analysis.py" | 0 12 files changed, 45 insertions(+), 25 deletions(-) create mode 100644 pages/backtesting/README.md rename "pages/9_\342\232\231\357\270\217_Backtesting.py" => pages/backtesting/app.py (95%) create mode 100644 pages/bot_orchestration/README.md rename "pages/8_\360\237\220\231_Bot_Orchestration.py" => pages/bot_orchestration/app.py (94%) rename "pages/6_\360\237\227\202_Candles_Downloader.py" => "pages/candles_downloader/6_\360\237\227\202_Candles_Downloader.py" (100%) rename "pages/4_\360\237\247\263_Hummingbot_DB.py" => "pages/database_inspector/4_\360\237\247\263_Hummingbot_DB.py" (100%) rename "pages/7_\360\237\223\213_Data.py" => "pages/reference_data/7_\360\237\223\213_Data.py" (100%) rename "pages/3_\360\237\247\231_XE_Token_Analyzer.py" => "pages/token_spreads/3_\360\237\247\231_XE_Token_Analyzer.py" (100%) rename "pages/5_\360\237\246\211_TVL_vs_MCAP_Analysis.py" => "pages/tvl_vs_mcap/5_\360\237\246\211_TVL_vs_MCAP_Analysis.py" (100%) diff --git a/README.md b/README.md index a7b4a203..16de4d74 100644 --- a/README.md +++ b/README.md @@ -10,20 +10,19 @@ Here are the current dashboards in the collection: * πŸš€ **Strategy Performance**: Analyze the performance of a running Hummingbot instance * πŸ™ **Bot Orchestration**: Deploy and manage Hummingbot instances -* πŸ§™ **XE Token Analyzer**: Identify cross-exchange trading opportunities by analyzing differences in token spreads across venues * βš™οΈ **Backtesting**: Deploy and manage backtests of directional strategies -* 🧳 **Hummingbot DB**: Inspect and analyze the orders and trades data contained in a SQLite database for a strategy or script -* πŸ¦‰ **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. -* πŸ“‹ **Data**: Reference data for the various apps this collection +* 🧳 **Database 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. ## Installation -See [Installation](https://github.com/hummingbot/dashboard/INSTALLATION.md) for how to install and update the dashboard. +See [Installation](https://github.com/hummingbot/dashboard/blob/feat/base-page-class/INSTALLATION.md) for how to install and update the dashboard. ## Contributions -We welcome contributions from the community! See [Contribution](https://github.com/hummingbot/dashboard/CONTRIBUTION.md) for more information. +We welcome contributions from the community! See [Contribution](https://github.com/hummingbot/dashboard/blob/feat/base-page-class/CONTRIBUTING.md) for more information. ## Participation diff --git a/main.py b/main.py index 70ff5793..765e7075 100644 --- a/main.py +++ b/main.py @@ -21,13 +21,8 @@ [ Page("main.py", "Hummingbot Dashboard", "πŸ“Š"), Page("pages/strategy_performance/app.py", "Strategy Performance", "πŸš€"), - # # The pages appear in the order you pass them - # Page("example_app/example_four.py", "Example Four", "πŸ“–"), - # Page("example_app/example_two.py", "Example Two", "✏️"), - # # Will use the default icon and name based on the filename if you don't - # # pass them - # Page("example_app/example_three.py"), - # Page("example_app/example_five.py", "Example Five", "🧰"), + Page("pages/bot_orchestration/app.py", "Bot Orchestration", "πŸ™"), + Page("pages/backtesting/app.py", "Backtesting", "βš™οΈ"), ] ) diff --git a/pages/backtesting/README.md b/pages/backtesting/README.md new file mode 100644 index 00000000..e11eabf3 --- /dev/null +++ b/pages/backtesting/README.md @@ -0,0 +1 @@ +Deploy and manage backtests of directional strategies \ No newline at end of file diff --git "a/pages/9_\342\232\231\357\270\217_Backtesting.py" b/pages/backtesting/app.py similarity index 95% rename from "pages/9_\342\232\231\357\270\217_Backtesting.py" rename to pages/backtesting/app.py index e768cf77..4c22101e 100644 --- "a/pages/9_\342\232\231\357\270\217_Backtesting.py" +++ b/pages/backtesting/app.py @@ -3,6 +3,7 @@ import webbrowser import streamlit as st +from pathlib import Path from streamlit_ace import st_ace import constants @@ -12,16 +13,27 @@ from utils.os_utils import load_directional_strategies, save_file, get_function_from_file import optuna +# Page metadata +title = "Backtesting" +icon = "βš™οΈ" + st.set_page_config( - page_title="Hummingbot Dashboard", - page_icon="πŸš€", + page_title=title, + page_icon=icon, layout="wide", ) +st.title(f"{icon} {title}") + +# About this page +current_directory = Path(__file__).parent +readme_path = current_directory / "README.md" +with st.expander("About This Page"): + st.write(readme_path.read_text()) + +# 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 00000000..66673584 --- /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_\360\237\220\231_Bot_Orchestration.py" b/pages/bot_orchestration/app.py similarity index 94% rename from "pages/8_\360\237\220\231_Bot_Orchestration.py" rename to pages/bot_orchestration/app.py index dc3b8aba..9b810ad1 100644 --- "a/pages/8_\360\237\220\231_Bot_Orchestration.py" +++ b/pages/bot_orchestration/app.py @@ -1,21 +1,30 @@ import time - +import constants import pandas as pd -from hbotrc import BotCommands import streamlit as st +from pathlib import Path + from docker_manager import DockerManager +from hbotrc import BotCommands -import constants +# Page metadata +title = "Bot Orchestration" +icon = "πŸ™" st.set_page_config( - page_title="Hummingbot Dashboard", - page_icon=":bar_chart:", + page_title=title, + page_icon=icon, layout="wide", - initial_sidebar_state="collapsed" ) -st.title("πŸ™ Bot Orchestration") -st.write("---") +st.title(f"{icon} {title}") + +# About this page +current_directory = Path(__file__).parent +readme_path = current_directory / "README.md" +with st.expander("About This Page"): + st.write(readme_path.read_text()) +# Start content here docker_manager = DockerManager() active_containers = docker_manager.get_active_containers() diff --git "a/pages/6_\360\237\227\202_Candles_Downloader.py" "b/pages/candles_downloader/6_\360\237\227\202_Candles_Downloader.py" similarity index 100% rename from "pages/6_\360\237\227\202_Candles_Downloader.py" rename to "pages/candles_downloader/6_\360\237\227\202_Candles_Downloader.py" diff --git "a/pages/4_\360\237\247\263_Hummingbot_DB.py" "b/pages/database_inspector/4_\360\237\247\263_Hummingbot_DB.py" similarity index 100% rename from "pages/4_\360\237\247\263_Hummingbot_DB.py" rename to "pages/database_inspector/4_\360\237\247\263_Hummingbot_DB.py" diff --git "a/pages/7_\360\237\223\213_Data.py" "b/pages/reference_data/7_\360\237\223\213_Data.py" similarity index 100% rename from "pages/7_\360\237\223\213_Data.py" rename to "pages/reference_data/7_\360\237\223\213_Data.py" diff --git a/pages/strategy_performance/app.py b/pages/strategy_performance/app.py index af2dc059..1d72a1ad 100644 --- a/pages/strategy_performance/app.py +++ b/pages/strategy_performance/app.py @@ -6,6 +6,7 @@ from utils.database_manager import DatabaseManager from utils.graphs import CandlesGraph +# Page metadata title = "Strategy Performance" icon = "πŸš€" @@ -16,11 +17,13 @@ ) st.title(f"{icon} {title}") +# About this page current_directory = Path(__file__).parent readme_path = current_directory / "README.md" with st.expander("About This Page"): st.write(readme_path.read_text()) +# Start content here intervals = { "1m": 60, "3m": 60 * 3, diff --git "a/pages/3_\360\237\247\231_XE_Token_Analyzer.py" "b/pages/token_spreads/3_\360\237\247\231_XE_Token_Analyzer.py" similarity index 100% rename from "pages/3_\360\237\247\231_XE_Token_Analyzer.py" rename to "pages/token_spreads/3_\360\237\247\231_XE_Token_Analyzer.py" diff --git "a/pages/5_\360\237\246\211_TVL_vs_MCAP_Analysis.py" "b/pages/tvl_vs_mcap/5_\360\237\246\211_TVL_vs_MCAP_Analysis.py" similarity index 100% rename from "pages/5_\360\237\246\211_TVL_vs_MCAP_Analysis.py" rename to "pages/tvl_vs_mcap/5_\360\237\246\211_TVL_vs_MCAP_Analysis.py" From 102b87c63644bd808ddede900563c7d5c6fa29e4 Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Sun, 23 Jul 2023 09:20:28 -0400 Subject: [PATCH 04/10] (feat) added all pages --- README.md | 20 ++++----- main.py | 6 ++- .../README.md | 0 .../{backtesting => backtest_manager}/app.py | 2 +- pages/candles_downloader/README.md | 1 + .../candles_downloader/app.py | 20 +++++++-- pages/db_inspector/README.md | 1 + .../db_inspector/app.py | 22 ++++++++-- pages/token_spreads/README.md | 1 + .../token_spreads/app.py | 31 ++++++++++---- pages/tvl_vs_mcap/README.md | 3 ++ .../tvl_vs_mcap/app.py | 41 ++++++++++++------- 12 files changed, 104 insertions(+), 44 deletions(-) rename pages/{backtesting => backtest_manager}/README.md (100%) rename pages/{backtesting => backtest_manager}/app.py (99%) create mode 100644 pages/candles_downloader/README.md rename "pages/candles_downloader/6_\360\237\227\202_Candles_Downloader.py" => pages/candles_downloader/app.py (87%) create mode 100644 pages/db_inspector/README.md rename "pages/database_inspector/4_\360\237\247\263_Hummingbot_DB.py" => pages/db_inspector/app.py (70%) create mode 100644 pages/token_spreads/README.md rename "pages/token_spreads/3_\360\237\247\231_XE_Token_Analyzer.py" => pages/token_spreads/app.py (78%) create mode 100644 pages/tvl_vs_mcap/README.md rename "pages/tvl_vs_mcap/5_\360\237\246\211_TVL_vs_MCAP_Analysis.py" => pages/tvl_vs_mcap/app.py (71%) diff --git a/README.md b/README.md index 16de4d74..fb41e71c 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,28 @@ -# 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. - -## Dashboards +### Dashboards Here are the current dashboards in the collection: * πŸš€ **Strategy Performance**: Analyze the performance of a running Hummingbot instance * πŸ™ **Bot Orchestration**: Deploy and manage Hummingbot instances -* βš™οΈ **Backtesting**: Deploy and manage backtests of directional strategies +* βš™οΈ **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. -* 🧳 **Database Inspector**: Inspect and analyze the orders and trades data contained in a Hummingbot strategy database +* πŸ” **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. -## Installation +### Installation + +This project is built using [StreamLit](https://streamlit.io/) and uses Anaconda and Docker to simplify installation, updates, and manage dependencies. See [Installation](https://github.com/hummingbot/dashboard/blob/feat/base-page-class/INSTALLATION.md) for how to install and update the dashboard. -## Contributions +### Contributions We welcome contributions from the community! See [Contribution](https://github.com/hummingbot/dashboard/blob/feat/base-page-class/CONTRIBUTING.md) for more information. -## Participation +### Meetings We hold bi-weekly livestream Dashboard project meetings. You can participate on our [Discord](https://discord.gg/hummingbot) * Alternating Wenesdays, 3pm GMT / 11am EST / 8am PST / 11pm SIN diff --git a/main.py b/main.py index 765e7075..231f2576 100644 --- a/main.py +++ b/main.py @@ -22,7 +22,11 @@ Page("main.py", "Hummingbot Dashboard", "πŸ“Š"), Page("pages/strategy_performance/app.py", "Strategy Performance", "πŸš€"), Page("pages/bot_orchestration/app.py", "Bot Orchestration", "πŸ™"), - Page("pages/backtesting/app.py", "Backtesting", "βš™οΈ"), + 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", "πŸ¦‰"), ] ) diff --git a/pages/backtesting/README.md b/pages/backtest_manager/README.md similarity index 100% rename from pages/backtesting/README.md rename to pages/backtest_manager/README.md diff --git a/pages/backtesting/app.py b/pages/backtest_manager/app.py similarity index 99% rename from pages/backtesting/app.py rename to pages/backtest_manager/app.py index 4c22101e..5423349b 100644 --- a/pages/backtesting/app.py +++ b/pages/backtest_manager/app.py @@ -14,7 +14,7 @@ import optuna # Page metadata -title = "Backtesting" +title = "Backtest Manager" icon = "βš™οΈ" st.set_page_config( diff --git a/pages/candles_downloader/README.md b/pages/candles_downloader/README.md new file mode 100644 index 00000000..1d08d65a --- /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/candles_downloader/6_\360\237\227\202_Candles_Downloader.py" b/pages/candles_downloader/app.py similarity index 87% rename from "pages/candles_downloader/6_\360\237\227\202_Candles_Downloader.py" rename to pages/candles_downloader/app.py index 7d33ca20..ed8a7310 100644 --- "a/pages/candles_downloader/6_\360\237\227\202_Candles_Downloader.py" +++ b/pages/candles_downloader/app.py @@ -2,19 +2,31 @@ from subprocess import CalledProcessError import streamlit as st +from pathlib import Path import constants from utils import os_utils from docker_manager import DockerManager +# Page metadata +title = "Candles Downloader" +icon = "πŸ—‚οΈ" + st.set_page_config( - page_title="Candles Downloader", - page_icon=":bar_chart:", + page_title=title, + page_icon=icon, layout="wide", ) +st.title(f"{icon} {title}") + +# About this page +current_directory = Path(__file__).parent +readme_path = current_directory / "README.md" +with st.expander("About This Page"): + st.write(readme_path.read_text()) + +# 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 00000000..2b0b7ca7 --- /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/database_inspector/4_\360\237\247\263_Hummingbot_DB.py" b/pages/db_inspector/app.py similarity index 70% rename from "pages/database_inspector/4_\360\237\247\263_Hummingbot_DB.py" rename to pages/db_inspector/app.py index cee42332..4212e2d2 100644 --- "a/pages/database_inspector/4_\360\237\247\263_Hummingbot_DB.py" +++ b/pages/db_inspector/app.py @@ -1,8 +1,27 @@ import streamlit as st +from pathlib import Path import sqlite3 import pandas as pd +# Page metadata +title = "DB Inspector" +icon = "πŸ”" + +st.set_page_config( + page_title=title, + page_icon=icon, + layout="wide", +) +st.title(f"{icon} {title}") + +# About this page +current_directory = Path(__file__).parent +readme_path = current_directory / "README.md" +with st.expander("About This Page"): + st.write(readme_path.read_text()) + +# Start content here @st.cache_data def get_table_data(database_name: str, table_name: str): conn = sqlite3.connect(database_name) @@ -17,9 +36,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/token_spreads/README.md b/pages/token_spreads/README.md new file mode 100644 index 00000000..4225df86 --- /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/token_spreads/3_\360\237\247\231_XE_Token_Analyzer.py" b/pages/token_spreads/app.py similarity index 78% rename from "pages/token_spreads/3_\360\237\247\231_XE_Token_Analyzer.py" rename to pages/token_spreads/app.py index 9cfbfb93..75fe1a1c 100644 --- "a/pages/token_spreads/3_\360\237\247\231_XE_Token_Analyzer.py" +++ b/pages/token_spreads/app.py @@ -1,10 +1,29 @@ 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 +# Page metadata +title = "Token Spreads" +icon = "πŸ§™" + +st.set_page_config( + page_title=title, + page_icon=icon, + layout="wide", +) +st.title(f"{icon} {title}") + +# About this page +current_directory = Path(__file__).parent +readme_path = current_directory / "README.md" +with st.expander("About This Page"): + st.write(readme_path.read_text()) + +# Start content here cg_utils = CoinGeckoUtils() miner_utils = MinerUtils() @@ -24,10 +43,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 +50,6 @@ def get_coin_tickers_by_id_list(coins_id: list): 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 +61,7 @@ def get_coin_tickers_by_id_list(coins_id: list): 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 +88,6 @@ def get_coin_tickers_by_id_list(coins_id: list): } ) -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 00000000..251fc880 --- /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/tvl_vs_mcap/5_\360\237\246\211_TVL_vs_MCAP_Analysis.py" b/pages/tvl_vs_mcap/app.py similarity index 71% rename from "pages/tvl_vs_mcap/5_\360\237\246\211_TVL_vs_MCAP_Analysis.py" rename to pages/tvl_vs_mcap/app.py index 19879f08..c8ed6145 100644 --- "a/pages/tvl_vs_mcap/5_\360\237\246\211_TVL_vs_MCAP_Analysis.py" +++ b/pages/tvl_vs_mcap/app.py @@ -1,9 +1,28 @@ import numpy as np import streamlit as st +from pathlib import Path import pandas as pd import plotly.express as px from defillama import DefiLlama +# Page metadata +title = "TVL vs Market Cap" +icon = "πŸ¦‰" + +st.set_page_config( + page_title=title, + page_icon=icon, + layout="wide", +) +st.title(f"{icon} {title}") + +# About this page +current_directory = Path(__file__).parent +readme_path = current_directory / "README.md" +with st.expander("About This Page"): + st.write(readme_path.read_text()) + +# Start content here MIN_TVL = 1000000. MIN_MCAP = 1000000. @@ -17,18 +36,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 +66,10 @@ def get_protocols_by_chain_category(protocols: pd.DataFrame, group_by: list, nth 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 +81,4 @@ def get_protocols_by_chain_category(protocols: pd.DataFrame, group_by: list, nth 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 From cb4904cf96a96f43f77a3f07db82c435fbdd6692 Mon Sep 17 00:00:00 2001 From: cardosofede Date: Mon, 24 Jul 2023 17:20:43 +0200 Subject: [PATCH 05/10] (feat) remove unused class --- page.py | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 page.py diff --git a/page.py b/page.py deleted file mode 100644 index 91d60e87..00000000 --- a/page.py +++ /dev/null @@ -1,16 +0,0 @@ -import streamlit as st - -class Page: - def __init__(self, title, description, icon="πŸ¦…", layout="wide"): - self.title = title - self.description = description - self.icon = icon - self.layout = layout - - def write_page(self): - st.set_page_config(page_title=self.title, page_icon=self.icon, layout=self.layout) - st.title(self.title) - st.write("---") - with st.expander("About This Page"): - st.write(self.description) - st.write("---") From c81fe36d71c464dd9772404beffe00e239bc784a Mon Sep 17 00:00:00 2001 From: cardosofede Date: Mon, 24 Jul 2023 17:20:55 +0200 Subject: [PATCH 06/10] (feat) add function to initialize pages --- utils/st_utils.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 utils/st_utils.py diff --git a/utils/st_utils.py b/utils/st_utils.py new file mode 100644 index 00000000..51800d11 --- /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()) From 1e4cce67470f1eb90ac747012fd8497c0ee234c1 Mon Sep 17 00:00:00 2001 From: cardosofede Date: Mon, 24 Jul 2023 17:22:56 +0200 Subject: [PATCH 07/10] (feat) add initialize st_page to main page --- main.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/main.py b/main.py index 231f2576..acdd84ed 100644 --- a/main.py +++ b/main.py @@ -1,21 +1,10 @@ import streamlit as st -from pathlib import Path from st_pages import Page, show_pages -title = "Hummingbot Dashboard" -icon = "πŸ“Š" +from utils.st_utils import initialize_st_page -st.set_page_config( - page_title=title, - page_icon=icon, - layout="wide", -) -st.title(f"{icon} {title}") -current_directory = Path(__file__).parent -readme_path = current_directory / "README.md" -with st.expander("About This Page"): - st.write(readme_path.read_text()) +initialize_st_page(title="Hummingbot Dashboard", icon="πŸ“Š") show_pages( [ From a3ff2bf0ed714e27a954e2605af2e145e710261a Mon Sep 17 00:00:00 2001 From: cardosofede Date: Mon, 24 Jul 2023 17:23:06 +0200 Subject: [PATCH 08/10] (feat) add initialize st_page to backtest manager --- pages/backtest_manager/app.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/pages/backtest_manager/app.py b/pages/backtest_manager/app.py index 5423349b..4e6a217c 100644 --- a/pages/backtest_manager/app.py +++ b/pages/backtest_manager/app.py @@ -13,22 +13,10 @@ from utils.os_utils import load_directional_strategies, save_file, get_function_from_file import optuna -# Page metadata -title = "Backtest Manager" -icon = "βš™οΈ" - -st.set_page_config( - page_title=title, - page_icon=icon, - layout="wide", -) -st.title(f"{icon} {title}") - -# About this page -current_directory = Path(__file__).parent -readme_path = current_directory / "README.md" -with st.expander("About This Page"): - st.write(readme_path.read_text()) +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: From 9a1df4ec31d06c19b51fa97b224bc63006c698fd Mon Sep 17 00:00:00 2001 From: cardosofede Date: Mon, 24 Jul 2023 17:29:21 +0200 Subject: [PATCH 09/10] (feat) refactor all pages --- pages/backtest_manager/app.py | 1 - pages/bot_orchestration/app.py | 21 ++++--------------- pages/candles_downloader/app.py | 17 ++------------- pages/db_inspector/app.py | 21 ++++--------------- .../7_\360\237\223\213_Data.py" | 14 ++++++------- pages/strategy_performance/app.py | 19 +++-------------- pages/token_spreads/app.py | 18 ++-------------- pages/tvl_vs_mcap/app.py | 17 ++------------- 8 files changed, 24 insertions(+), 104 deletions(-) diff --git a/pages/backtest_manager/app.py b/pages/backtest_manager/app.py index 4e6a217c..583e0d6d 100644 --- a/pages/backtest_manager/app.py +++ b/pages/backtest_manager/app.py @@ -3,7 +3,6 @@ import webbrowser import streamlit as st -from pathlib import Path from streamlit_ace import st_ace import constants diff --git a/pages/bot_orchestration/app.py b/pages/bot_orchestration/app.py index 9b810ad1..92920a74 100644 --- a/pages/bot_orchestration/app.py +++ b/pages/bot_orchestration/app.py @@ -2,27 +2,14 @@ import constants import pandas as pd import streamlit as st -from pathlib import Path from docker_manager import DockerManager from hbotrc import BotCommands -# Page metadata -title = "Bot Orchestration" -icon = "πŸ™" - -st.set_page_config( - page_title=title, - page_icon=icon, - layout="wide", -) -st.title(f"{icon} {title}") - -# About this page -current_directory = Path(__file__).parent -readme_path = current_directory / "README.md" -with st.expander("About This Page"): - st.write(readme_path.read_text()) +from utils.st_utils import initialize_st_page + + +initialize_st_page(title="Bot Orchestration", icon="πŸ™") # Start content here docker_manager = DockerManager() diff --git a/pages/candles_downloader/app.py b/pages/candles_downloader/app.py index ed8a7310..ecc11cfd 100644 --- a/pages/candles_downloader/app.py +++ b/pages/candles_downloader/app.py @@ -2,28 +2,15 @@ from subprocess import CalledProcessError import streamlit as st -from pathlib import Path import constants from utils import os_utils from docker_manager import DockerManager -# Page metadata -title = "Candles Downloader" -icon = "πŸ—‚οΈ" +from utils.st_utils import initialize_st_page -st.set_page_config( - page_title=title, - page_icon=icon, - layout="wide", -) -st.title(f"{icon} {title}") -# About this page -current_directory = Path(__file__).parent -readme_path = current_directory / "README.md" -with st.expander("About This Page"): - st.write(readme_path.read_text()) +initialize_st_page(title="Candles Downloader", icon="πŸ—‚οΈ") # Start content here docker_manager = DockerManager() diff --git a/pages/db_inspector/app.py b/pages/db_inspector/app.py index 4212e2d2..bde870f0 100644 --- a/pages/db_inspector/app.py +++ b/pages/db_inspector/app.py @@ -1,25 +1,12 @@ import streamlit as st -from pathlib import Path import sqlite3 import pandas as pd -# Page metadata -title = "DB Inspector" -icon = "πŸ”" - -st.set_page_config( - page_title=title, - page_icon=icon, - layout="wide", -) -st.title(f"{icon} {title}") - -# About this page -current_directory = Path(__file__).parent -readme_path = current_directory / "README.md" -with st.expander("About This Page"): - st.write(readme_path.read_text()) +from utils.st_utils import initialize_st_page + + +initialize_st_page(title="DB Inspector", icon="πŸ”") # Start content here @st.cache_data diff --git "a/pages/reference_data/7_\360\237\223\213_Data.py" "b/pages/reference_data/7_\360\237\223\213_Data.py" index 70786ba8..c75547ec 100644 --- "a/pages/reference_data/7_\360\237\223\213_Data.py" +++ "b/pages/reference_data/7_\360\237\223\213_Data.py" @@ -3,30 +3,30 @@ 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/app.py b/pages/strategy_performance/app.py index 1d72a1ad..629565a9 100644 --- a/pages/strategy_performance/app.py +++ b/pages/strategy_performance/app.py @@ -1,27 +1,13 @@ import os import pandas as pd import streamlit as st -from pathlib import Path from utils.database_manager import DatabaseManager from utils.graphs import CandlesGraph +from utils.st_utils import initialize_st_page -# Page metadata -title = "Strategy Performance" -icon = "πŸš€" -st.set_page_config( - page_title=title, - page_icon=icon, - layout="wide", -) -st.title(f"{icon} {title}") - -# About this page -current_directory = Path(__file__).parent -readme_path = current_directory / "README.md" -with st.expander("About This Page"): - st.write(readme_path.read_text()) +initialize_st_page(title="Strategy Performance", icon="πŸš€") # Start content here intervals = { @@ -35,6 +21,7 @@ "1d": 60 * 60 * 24, } + @st.cache_resource def get_database(db_name: str): db_manager = DatabaseManager(db_name) diff --git a/pages/token_spreads/app.py b/pages/token_spreads/app.py index 75fe1a1c..1fa8eb00 100644 --- a/pages/token_spreads/app.py +++ b/pages/token_spreads/app.py @@ -1,27 +1,13 @@ -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 -# Page metadata -title = "Token Spreads" -icon = "πŸ§™" -st.set_page_config( - page_title=title, - page_icon=icon, - layout="wide", -) -st.title(f"{icon} {title}") - -# About this page -current_directory = Path(__file__).parent -readme_path = current_directory / "README.md" -with st.expander("About This Page"): - st.write(readme_path.read_text()) +initialize_st_page(title="Token Spreads", icon="πŸ§™") # Start content here cg_utils = CoinGeckoUtils() diff --git a/pages/tvl_vs_mcap/app.py b/pages/tvl_vs_mcap/app.py index c8ed6145..e553e461 100644 --- a/pages/tvl_vs_mcap/app.py +++ b/pages/tvl_vs_mcap/app.py @@ -1,26 +1,13 @@ import numpy as np import streamlit as st -from pathlib import Path import pandas as pd import plotly.express as px from defillama import DefiLlama -# Page metadata -title = "TVL vs Market Cap" -icon = "πŸ¦‰" +from utils.st_utils import initialize_st_page -st.set_page_config( - page_title=title, - page_icon=icon, - layout="wide", -) -st.title(f"{icon} {title}") -# About this page -current_directory = Path(__file__).parent -readme_path = current_directory / "README.md" -with st.expander("About This Page"): - st.write(readme_path.read_text()) +initialize_st_page(title="TVL vs Market Cap", icon="πŸ¦‰") # Start content here MIN_TVL = 1000000. From 4b05c02778224918f56efe6e8fb31545bbe402d9 Mon Sep 17 00:00:00 2001 From: cardosofede Date: Mon, 24 Jul 2023 17:30:55 +0200 Subject: [PATCH 10/10] (feat) remove text from main page --- main.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/main.py b/main.py index acdd84ed..92195689 100644 --- a/main.py +++ b/main.py @@ -19,10 +19,6 @@ ] ) -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: