这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,7 @@ dmypy.json

# Optimize studies and strategies
quants_lab/optimizations/*
quants_lab/strategy/experiments/*
quants_lab/strategy/experiments/*

# Master bot template user-added configs
hummingbot_files/templates/master_bot_conf/conf/*
1 change: 1 addition & 0 deletions constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
BOTS_FOLDER = "hummingbot_files/bot_configs"
DIRECTIONAL_STRATEGIES_PATH = "quants_lab/strategy/experiments"
OPTIMIZATIONS_PATH = "quants_lab/optimizations"
HUMMINGBOT_TEMPLATES = "hummingbot_files/templates"
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
### client_config_map config ###
####################################

instance_id: 039758736d451914503a45ff596e168902d62557
instance_id: hummingbot-master_bot_conf

log_level: INFO

Expand Down Expand Up @@ -67,42 +67,42 @@ pmm_script_mode: {}
# BTC: 0.1
# USDT: 1000
balance_asset_limit:
bybit_testnet: {}
lbank: {}
binance_us: {}
crypto_com: {}
ascend_ex_paper_trade: {}
hotbit: {}
gate_io_paper_trade: {}
bitmex_testnet: {}
ndax_testnet: {}
huobi: {}
probit_kr: {}
altmarkets: {}
hitbtc: {}
foxbit: {}
ascend_ex: {}
ascend_ex_paper_trade: {}
binance: {}
okx: {}
ciex: {}
bitmex: {}
binance_paper_trade: {}
binance_us: {}
bitfinex: {}
probit: {}
kraken: {}
kucoin: {}
bitmart: {}
bybit: {}
bitmex: {}
bitmex_testnet: {}
bittrex: {}
btc_markets: {}
mock_paper_exchange: {}
bybit: {}
bybit_testnet: {}
ciex: {}
coinbase_pro: {}
crypto_com: {}
foxbit: {}
gate_io: {}
gate_io_paper_trade: {}
hitbtc: {}
hotbit: {}
huobi: {}
kraken: {}
kucoin: {}
kucoin_paper_trade: {}
ndax: {}
lbank: {}
loopring: {}
mexc: {}
mock_paper_exchange: {}
ndax: {}
ndax_testnet: {}
okx: {}
probit: {}
probit_kr: {}
whitebit: {}
coinbase_pro: {}
binance_paper_trade: {}
gate_io: {}

# Fixed gas price (in Gwei) for Ethereum transactions
manual_gas_price: 50.0
Expand Down Expand Up @@ -162,14 +162,14 @@ paper_trade:
- gate_io
paper_trade_account_balance:
BTC: 1.0
USDT: 1000.0
DAI: 1000.0
ETH: 10.0
ONE: 1000.0
USDQ: 1000.0
TUSD: 1000.0
ETH: 10.0
WETH: 10.0
USDC: 1000.0
DAI: 1000.0
USDQ: 1000.0
USDT: 1000.0
WETH: 10.0

color:
top_pane: '#000000'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,15 @@ polkadex_taker_percent_fee:
polkadex_buy_percent_fee_deducted_from_returns:
polkadex_maker_fixed_fees:
polkadex_taker_fixed_fees:
vertex_percent_fee_token:
vertex_maker_percent_fee:
vertex_taker_percent_fee:
vertex_buy_percent_fee_deducted_from_returns:
vertex_maker_fixed_fees:
vertex_taker_fixed_fees:
vertex_testnet_percent_fee_token:
vertex_testnet_maker_percent_fee:
vertex_testnet_taker_percent_fee:
vertex_testnet_buy_percent_fee_deducted_from_returns:
vertex_testnet_maker_fixed_fees:
vertex_testnet_taker_fixed_fees:
9 changes: 5 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@

from utils.st_utils import initialize_st_page

initialize_st_page(title="Hummingbot Dashboard", icon="📊")
initialize_st_page(title="Hummingbot Dashboard", icon="📊", initial_sidebar_state="expanded")

show_pages(
[
Page("main.py", "Hummingbot Dashboard", "📊"),
Section("Bot Orchestration", "🐙"),
Page("pages/bot_orchestration/app.py", "Bots Manager", "🦅"),
Page("pages/file_manager/app.py", "File Manager", "🗂"),
Page("pages/master_conf/app.py", "Credentials", "🗝️"),
Page("pages/bot_orchestration/app.py", "Instances", "🦅"),
Page("pages/file_manager/app.py", "Strategy Configs", "🗂"),
Section("Backtest Manager", "⚙️"),
Page("pages/candles_downloader/app.py", "Get Data", "💾"),
Page("pages/backtest_manager/create.py", "Create", "⚔️"),
Page("pages/backtest_manager/optimize.py", "Optimize", "🧪"),
Page("pages/backtest_manager/analyze.py", "Analyze", "🔬"),
Page("pages/backtest_manager/simulate.py", "Simulate", "📈"),
Section("Community Pages", "👨‍👩‍👧‍👦"),
Page("pages/strategy_performance/app.py", "Strategy Performance", "🚀"),
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", "🦉"),
Expand Down
76 changes: 23 additions & 53 deletions pages/bot_orchestration/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
from ui_components.bot_performance_card import BotPerformanceCard
from ui_components.dashboard import Dashboard
from ui_components.exited_bot_card import ExitedBotCard
from ui_components.launch_bot_card import LaunchBotCard
from ui_components.launch_broker_card import LaunchBrokerCard
from utils.st_utils import initialize_st_page

initialize_st_page(title="Bots Manager", icon="🦅", initial_sidebar_state="collapsed")
initialize_st_page(title="Instances", icon="🦅", initial_sidebar_state="collapsed")

if "is_broker_running" not in st.session_state:
st.session_state.is_broker_running = False
Expand All @@ -36,31 +38,14 @@
st.session_state.editor_tabs = {}


def manage_broker_container():
if st.session_state.is_broker_running:
docker_manager.stop_container("hummingbot-broker")
with st.spinner('Stopping Hummingbot Broker... you will not going to be able to manage bots anymore.'):
time.sleep(5)
else:
docker_manager.create_broker()
with st.spinner('Starting Hummingbot Broker... This process may take a few seconds'):
time.sleep(20)


def launch_new_bot():
bot_name = f"hummingbot-{st.session_state.new_bot_name.target.value}"
docker_manager.create_hummingbot_instance(instance_name=bot_name,
base_conf_folder=f"{constants.BOTS_FOLDER}/master_bot_conf/.",
target_conf_folder=f"{constants.BOTS_FOLDER}/{bot_name}/.")


def update_containers_info(docker_manager):
active_containers = docker_manager.get_active_containers()
st.session_state.is_broker_running = "hummingbot-broker" in active_containers
if st.session_state.is_broker_running:
try:
active_hbot_containers = [container for container in active_containers if
"hummingbot-" in container and "broker" not in container]
"hummingbot-" in container and "broker" not in container
and "master_bot_conf" not in container]
previous_active_bots = st.session_state.active_bots.keys()

# Remove bots that are no longer active
Expand Down Expand Up @@ -117,40 +102,25 @@ def get_grid_positions(n_cards: int, cols: int = NUM_CARD_COLS, card_width: int
return sorted(x_y, key=lambda x: (x[1], x[0]))


if "create_containers_board" not in st.session_state:
board = Dashboard()
create_containers_board = SimpleNamespace(
dashboard=board,
launch_bot=LaunchBotCard(board, 0, 0, 8, 1.5),
launch_broker=LaunchBrokerCard(board, 8, 0, 4, 1.5)
)
st.session_state.create_containers_board = create_containers_board

else:
create_containers_board = st.session_state.create_containers_board


with elements("create_bot"):
with mui.Grid(container=True, spacing=2):
with mui.Grid(item=True, xs=6):
with mui.Paper(style={"padding": "2rem"}, variant="outlined"):
with mui.Grid(container=True, spacing=2):
with mui.Grid(item=True, xs=12):
mui.Typography("🚀 Create Instance", variant="h5")
with mui.Grid(item=True, xs=8):
mui.TextField(label="Bot Name", variant="outlined", onChange=lazy(sync("new_bot_name")),
sx={"width": "100%"})
with mui.Grid(item=True, xs=4):
with mui.Button(onClick=launch_new_bot,
variant="outlined",
color="success",
sx={"width": "100%", "height": "100%"}):
mui.icon.AddCircleOutline()
mui.Typography("Create")
with mui.Grid(item=True, xs=6):
with mui.Paper(style={"padding": "2rem"}, variant="outlined"):
with mui.Grid(container=True, spacing=2):
with mui.Grid(item=True, xs=12):
mui.Typography("🐙 Manage Broker", variant="h5")
with mui.Grid(item=True, xs=8):
mui.Typography("Hummingbot Broker helps you control and monitor your bot instances.")
with mui.Grid(item=True, xs=4):
button_text = "Stop" if st.session_state.is_broker_running else "Start"
color = "error" if st.session_state.is_broker_running else "success"
icon = mui.icon.Stop if st.session_state.is_broker_running else mui.icon.PlayCircle
with mui.Button(onClick=manage_broker_container,
color=color,
variant="outlined",
sx={"width": "100%", "height": "100%"}):
icon()
mui.Typography(button_text)
with mui.Paper(elevation=3, style={"padding": "2rem"}, spacing=[2, 2], container=True):
with create_containers_board.dashboard():
create_containers_board.launch_bot()
create_containers_board.launch_broker()


with elements("active_instances_board"):
with mui.Paper(sx={"padding": "2rem"}, variant="outlined"):
Expand Down
2 changes: 1 addition & 1 deletion pages/candles_downloader/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from utils.st_utils import initialize_st_page


initialize_st_page(title="Candles Downloader", icon="🗂️")
initialize_st_page(title="Get Data", icon="💾", initial_sidebar_state="collapsed")

# Start content here
docker_manager = DockerManager()
Expand Down
2 changes: 1 addition & 1 deletion pages/file_manager/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from utils.st_utils import initialize_st_page


initialize_st_page(title="File Manager", icon="🗂️", initial_sidebar_state="collapsed")
initialize_st_page(title="Strategy Configs", icon="🗂️", initial_sidebar_state="collapsed")


if "fe_board" not in st.session_state:
Expand Down
19 changes: 19 additions & 0 deletions pages/master_conf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### 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.
48 changes: 48 additions & 0 deletions pages/master_conf/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import glob
import os
from types import SimpleNamespace
import streamlit as st
from streamlit_elements import elements, mui

import constants
from ui_components.dashboard import Dashboard
from ui_components.editor import Editor
from ui_components.launch_master_bot_card import LaunchMasterBotCard
from ui_components.master_conf_file_explorer import MasterConfFileExplorer
from utils.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()
4 changes: 2 additions & 2 deletions ui_components/bot_performance_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __call__(self, bot_config: dict):
mui.icon.DeleteForever()
mui.Typography("Stop Instance")
with mui.Grid(item=True, xs=6):
mui.TextField(disabled=True,
label="Attach to bot instance",
mui.TextField(InputProps={"readOnly": True},
label="Attach to instance",
value="docker attach " + bot_name,
sx={"width": "100%"})
2 changes: 1 addition & 1 deletion ui_components/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __call__(self):
with mui.Grid(container=True, spacing=4, sx={"display": "flex", "alignItems": "center"}):
with mui.Grid(item=True, xs=10, sx={"display": "flex", "alignItems": "center"}):
mui.icon.Terminal()
mui.Typography("Editor")
mui.Typography("Editor", variant="h6", sx={"marginLeft": 1})
with mui.Tabs(value=self._index, onChange=self._change_tab, scrollButtons=True,
variant="scrollable", sx={"flex": 1}):
for label in self._tabs.keys():
Expand Down
2 changes: 1 addition & 1 deletion ui_components/file_explorer_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __call__(self):
with mui.Grid(container=True, spacing=4, sx={"display": "flex", "alignItems": "center"}):
with mui.Grid(item=True, xs=6, sx={"display": "flex", "alignItems": "center"}):
mui.icon.Folder()
mui.Typography("File Explorer")
mui.Typography("File Explorer", variant="h6", sx={"marginLeft": 1})
with mui.Grid(item=True, xs=6, sx={"display": "flex", "justifyContent": "flex-end"}):
mui.IconButton(mui.icon.Delete, onClick=self.delete_file, sx={"mx": 1})
mui.IconButton(mui.icon.Edit, onClick=self.add_file_to_tab, sx={"mx": 1})
Expand Down
Loading