Skip to content

2023

Docker Installation Guide

Introduction

This brief guide will introduce you to the process of installing and deploying Hummingbot using Docker. You will learn step-by-step how to set up Hummingbot using Docker Compose, a tool for defining and running multi-container Docker applications, and then run your first algo trading strategy!

What You Will Learn

  1. Install Docker: Step-by-step instructions to installing Docker and Docker Compose,

  2. Hummingbot Interface: Uncover the essentials of the Hummingbot interface, including layout and navigation.

  3. Running a Script: Learn how to run an algo trading strategy as a Hummingbot script.

  4. Connecting API Keys: Master the crucial process of integrating API keys with Hummingbot, ensuring secure API-based bot trading across various exchanges.

Let's Begin!

With all the groundwork in place, it's time to unlock the full capabilities of your trading tools. Let's dive in!

1. Install Docker

Docker Installation Guide - 1 - Installation

System Prerequisites

Hummingbot runs on commodity hardware and does not require much memory or storage.

  • MacOS 10.12.6+ / Linux (Ubuntu 20.04+, Debian 10+) / Windows 10+
  • Memory: 4 GB RAM per instance
  • Storage: 5 GB HDD space per instance

Install Docker

For Windows Users

Hummingbot requires Windows Subsystem for Linux 2 (WSL2).

Install Linux on your Windows system: https://learn.microsoft.com/en-us/windows/wsl/install.

Afterwards, execute the following commands in your terminal to install Docker:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER

For Mac Users

The easiest and recommended way to get Docker Compose is to install Docker Desktop. Docker Desktop includes Docker Compose along with Docker Engine and Docker CLI which are Compose prerequisites.

Download and install the Docker Desktop for Mac.

For Linux Users

If you already have Docker Engine and Docker CLI installed, you can install the Compose plugin from the command line:

sudo apt-get update
sudo apt-get install docker-compose-plugin

Clone Hummingbot Repo

In your terminal, clone the Hummingbot Github repository:

git clone https://github.com/hummingbot/hummingbot
cd hummingbot

Create Container

The docker-compose.yml file contains the basic instructions to deploy Humminggbot:

Use the following command to create the Docker container:

docker compose up -d

This will start the container in the background and we'll need to attach to it to be able to send commands to it. Run the following command below:

Attach to Container

docker attach hummingbot

We should now have Hummingbot running and in the next section we'll go over the Hummingbot Interface

2. Hummingbot Interface

Docker Installation Guide - 2 - User Interface

Hummingbot operates through a Command Line Interface (CLI), a text-based system ideal for automated cryptocurrency trading. Unlike graphical interfaces, CLIs rely on text commands to function. Let's dive into how to use it effectively.

Create a Password

Alt text

If you are using Hummingbot for the first time, the system will prompt you to create a password. There are no character requirements, although we recommend using a strong password for additional security.

The password in Hummingbot encrypts sensitive data such as API keys, secret keys, and wallet private keys. For security reasons, the password is only stored locally in encrypted form, and we do not have access to it.

After you set a password you should now be in the main Hummingbot screen

User Interface Guide

Alt text

The CLI is organized into several key areas:

  • Input Pane (Lower Left): Here, you input your commands.

  • Output Pane (Upper Left): This displays the results of your commands.

  • Log Pane (Right): Here, you can view log messages.

  • Top Navigation Bar: Shows the version, current strategy, and strategy file.

  • Bottom Navigation Bar: Displays trades, CPU usage, memory, threads, and duration.

For a more in-depth look, visit User Interface

Useful shortcuts

  • CTRL + P + CTRL + Q - This exits the bot but keeps it running in the background

  • CTRL + X - Exits config

  • Double CTRL + C - Exits the bot completely

  • CTRL + V to paste in Hummingbot does not work, to paste try one of the following commands:

    • CTRL+SHIFT+V

    • SHIFT + RMB (right-mouse button)

    • SHIFT + INS

Next, let's learn about running a simple PMM script in Hummingbot

Running a Script

Docker Installation Guide - 3 - Running a Script

Simple Directional RSI Example

Let's use the v2_directional_rsi.py script. This is a configurable script that uses the Relative Strength Index (RSI) to trade cryptocurrency futures contracts. For configurable scripts, the first step is to create a config file. Here's how to create one:

create --script-config v2_directional_rsi.py

When you enter the create --script-config command and press SPACE Hummingbot will display available scripts in the scripts folder, as shown below.

Alt text

Select the v2_directional_rsi.py script and press ENTER.

Alt text

You will then be guided to configure the settings. At this stage, you may modify the options or simply hit ENTER to accept the default values.

Alt text

Give the config a name and press press ENTER to save it.

Once the config is saved we can now launch the script. Enter the command below to launch the script!

start --script v2_directional_rsi.py --conf conf_v2_directional_rsi_config_1.yml

Note that the autocomplete will popup after pressing SPACE after both the --script and --conf parameters so you can just select the correct script / config file from the list and then press ENTER

Alt text

After pressing ENTER you should be able to see activity in the log pane. Use the status command for more details or press CTRL + S. It should resemble the screen below.

status

Default Configs

Please note that the default values for the script config may not work for each and every exchange / scenario. You may need to tweak the script config in order for the bot to be able to place orders. If you encounter any issues check the log pane and the log files for more information on what the issue may be.

Alt text

To stop the script from running, type the stop command in the Hummingbot terminal

stop

Congratulations! You've successfully run your first scripts Next, we'll learn how to connect API keys for live trading.

Connecting your API Keys

Docker Installation Guide - 4 - Adding API Keys

While paper trading in Hummingbot doesn't require API keys, live trading does. This guide will help you connect your exchange API keys to Hummingbot for real-time trading.

Generate API Keys

First, you need to generate API keys from the exchange you wish to connect. Each exchange has its own setup process.

In this example, we'll connect Binance API keys. Head over to the Binance Connector Docs for instructions on how to generate API keys for Binance.

Check the Connectors list for a list of exchanges that are currently integrated with Hummingbot

Warning

Please always keep your API keys secure and do not share them.

Connect API keys to Hummingbot

In the Hummingbot run the connect command for the exchange we want to connect to. In this case for Binance use the command below -

connect binance

Alt text

You should get a prompt to enter in your API keys - you can use the following commands below to paste them into the Hummingbot terminal. Note that CTRL + V doesn't work and you'll get a Pyperclip error in the log panel if you try to use it.

  • CTRL+SHIFT+V

  • SHIFT + RMB (right-mouse button)

  • SHIFT + INS

Alt text

After entering your API keys you should get a success message if everything went through okay. You can also confirm by running the connect command again and check that both columns next to Binance are showing Yes.

Alt text

Now your Binance API keys are connected to Hummingbot. Repeat these steps for other exchanges as needed.

What's Next?

If you're serious about delving deeper and enhancing your trading bot capabilities, consider Botcamp, a professional training program for market makers and algo traders. This comprehensive program combines new content modules and live sessions each month to help you understand the intricacies of the market. You'll learn to create and backtest market making strategies, directional trading, and other strategies using Dashboard.

Most importantly, you'll gain hands-on experience with Bot Battles, Botcamp's monthly bot trading competitions. It's a great opportunity to measure your progress and learn from others. In addition, joining the Botcamp community allows you to expand your professional network, form teams to compete together, and share insights.


Thank you once again for joining us on this journey. I hope the knowledge you've gained here serves you well in your trading endeavors. All the best with your future trading bot projects!

Using Dashboard to Deploy and Backtest Strategies

Introduction

Welcome to the Hummingbot Dashboard Quickstart Guide!

While Hummingbot started as a simple CLI-based market making bot in 2019, today it has evolved into a flexible platform that helps you create, backtest, optimize and deploy all types of algorithmic trading strategies.

This guide shows you the basics of how to use the new Hummingbot Dashboard application to create and deploy strategies at scale. Whether you're a seasoned trader or just starting out, this tutorial will provide you with the tools and knowledge to maximize your trading potential.

What You Will Learn

  1. Set up Dashboard: Understand the initial steps to get Dashboard up and running.
  2. Managing Credentials: Safeguard and manage your access credentials for optimal security.
  3. Using the Master Bot Profile: Dive deep into how to launch multiple bots and effectively orchestrate them.
  4. Managing Bots: Explore the process of executing and assessing bot strategies within the Hummingbot Dashboard for optimized trading.
  5. Analyzing Bot Performance: Grasp the fundamentals of formulating a robust trading strategy and fine-tuning it for maximum efficiency and profitability.
  6. Backtesting and Optimization: Dive into the intricacies of evaluating the effectiveness of your strategies using historical data, ensuring they align with your trading objectives.
  7. Deploying Strategies: Gain comprehensive insights into the process of testing strategies against past market data (backtesting), and optimizing them based on the results to achieve optimal trading outcomes.
  8. Conclusion and Next Steps: Familiarize yourself with the steps to roll out multiple trading configurations seamlessly, ensuring a smooth transition from testing to live trading environments.

Let's Begin!

With the foundation set, it's time to harness the full potential of the Dashboard. Let's dive in!

Set up Dashboard

Using Dashboard to Deploy and Backtest Strategies - Part 1

Introduction

Welcome to the second part of the Hummingbot Dashboard quickstart. In this section, we'll guide you through the essential steps to set up the project and get Dashboard up and running.

Prerequisites

Before diving in, there are a couple of essential tools you'll need:

Update Linux Packages

It's a good practice to ensure your Linux system is up-to-date. Updating your system ensures that you have the latest security patches, bug fixes, and system improvements, reducing potential conflicts or issues during installation.

Run the following command:

sudo apt update && sudo apt upgrade -y && sudo apt install -y build-essential

Anaconda

Anaconda is a powerful distribution of Python and R for scientific computing and data science. It's vital for managing different environments for your projects. Download the installer for your environment from the Anaconda website and then run it.

For example, here is how to download and run the Linux installer:

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh

Follow the prompts on the installer screens. If you are unsure about any setting, accept the defaults. You can change them later.

To make the changes take effect, close and then re-open your Terminal window. Afterwards, run the conda command from your path:

conda

You should see a response similar to:

usage: conda [-h] [-V] command ...

conda is a tool for managing and deploying applications, environments and packages.

Options:

positional arguments:
  command
    clean        Remove unused packages and caches.
    compare      Compare packages between conda environments.

Docker

Docker is a platform that allows you to develop, ship, and run applications inside containers. It's necessary for ensuring that the dashboard runs in a consistent environment. If Docker isn't installed on your system, click here to follow the installation guide.

The easiest way to install Docker is to install Docker Desktop, which includes Docker Compose along with Docker Engine and Docker CLI which are Compose prerequisites. Here are links to installers for each major OS:

For command-line Linux distributions, you can install Docker Engine following the steps below:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER

Installing Dashboard

1. Access the Dashboard Repo

Hummingbot Dashboard is open-source, allowing anyone to access, modify, and contribute to its codebase. To get started, visit the project repository on GitHub at the following link: hummingbot/dashboard.

2. Clone the Repository

To get a local copy of the project, clone the repository by running the command:

git clone https://github.com/hummingbot/dashboard

3. Set Up the Conda Environment

Once you've cloned the repository and navigated into its root directory, it's time to create a Conda environment. This environment ensures that all the required dependencies for the dashboard are installed and isolated from other projects. Run the following commands:

cd dashboard
make env_create

4. Activate the Environment

After creating the environment, you'll need to activate it:

conda activate dashboard

5. Launch the Dashboard

With the environment activated, initiate the dashboard with:

make run

It might take a while to load the dashboard for the first time. Subsequent launches will typically be faster. Once the dashboard is up, open a web browser and navigate to https://localhost:8501 to view it.

Next Steps

Congratulations - you've successfully set up the Hummingbot Dashboard. In the next tutorial, we'll delve into managing your credentials and understanding the registration process.

Manage Credentials

Using Dashboard to Deploy and Backtest Strategies - Part 2

Introduction

In this section, we'll dive into the importance of securely managing credentials in the Hummingbot Dashboard, ensuring that your information remains private and under your control.

Enabling Credential Management

If you plan to expose Dashboard externally or enable multiple users, managing credentials securely is paramount.

To add authentication layer to Dashboard, modify the AUTH_SYSTEM_ENABLED variable in the CONFIG.py file. By default, it is set to False.

Change it to True and save the file:

AUTH_SYSTEM_ENABLED = True

Afterwards, stop Dashboard and restart it with make run. Users will now be asked to log in when accessing Dashboard at https://localhost:8501.

Setting User Credentials

We present two methods for setting user credentials for Dashboard:

1. Manual Password Hashing

In this method, we manually declare the users and their corresponding passwords in the credentials.yml file.

credentials:
  usernames:
    admin:
      email: [email protected]
      name: Admin User
      password: abc # To be replaced with hashed password: hashed_passwords = stauth.Hasher(['abc', 'def']).generate()
In the default file above, the template password abc is a placeholder for the hashed password.

To generate a hashed password for a given string, follow these instructions:

  1. Run conda activate dashboard to ensure that you're in the Dashboard environment is active.
  2. Afterwards, enter the Python console with:
    python
    
  3. Import the auth library and hash the password:
    import streamlit_authenticator as st_auth
    hashed_password = st_auth.Hasher("YOUR_PASSWORD")
    hashed_password
    
  4. In the credentials.yml file, Replace the admin user's password with this hashed_password.
  5. Run exit() to exit the Python console.
  6. Access the dashboard at https://localhost:8501 and enter the username(admin) and string(YOUR_PASSWORD) used to generated the hashed password.

2. Whitelisted Email Registration

While the method works for 1-2 users, it might be cumbersome if numerous users interact with Dashboard.

Instead, you can edit the preauthorized section in credentials.yml. This method below allows you to whitelist a list of emails and allow users to set their own passwords. Each user is added to the credentials file.

  1. Define a whitelist of emails authorized to access the dashboard.
  2. In the pre_authorized: section of `credentials.yml``, add the emails of users who will be pre-authorized to register and create their credentials.
    pre_authorized:
      emails:
        - [email protected]
        - [email protected]
    
  3. Users with whitelisted emails can fill out a registration form upon their first login.
  4. Upon registration, Dashboard will hash and store their credentials automatically in this file.

Logging Out

Once logged in, you have the freedom to navigate through the various sections of the dashboard. However, to log out securely, ensure you return to the main Hummingbot Dashboard page and click the logout button. This ensures optimal security for your credentials and the dashboard's functionality.

Next Steps

Next, learn how to use the master bot profile to manage the keys you store in Dashboard.

Using the Master Bot Profile

Using Dashboard to Deploy and Backtest Strategies - Part 3

Introduction

In this installment, we show how to utilize the Master Bot Profiles to create and store API keys, along with exploring available scripts in the Hummingbot Dashboard. Let's break down the essentials!

Role of the Master Bot Profile

The Master Bot plays a pivotal role in the credential management process in Hummingbot. It serves as a centralized location where exchange API keys and the scripts/strategies available to new bots are securely stored. When spawning new bots from the dashboard, they inherit the encrypted keys and available scripts/strategies from the Master Bot.

How Does It Work?

  1. Create an instance of the Master Bot from Docker
  2. Connect to this Docker instance
  3. Add exchange credentials to this instance.
  4. Spawn new bots from Dashboard, which will use the encrypted data from the Master Bot for credential access.

Future Profiles

In the future, plans are in place to introduce additional bot profiles. Each profile can possess different API keys and available scripts, enabling users to specify the profile they want to use when spawning a new bot.

Adding Exchange Credentials

To test the Master Bot's functionality, we'll connect to the Binance exchange as an example:

  1. Ensure Docker is running, as it's essential for spawning new bots.
  2. Navigate to the Credentials tab in the dashboard.
  3. Click on the Start button to initiate the Master Bot.
  4. Open a terminal and enter the command docker attach hummingbot-master_bot_conf to attach to the Master Bot.
  5. Connect to the desired exchange (e.g., Binance) and input the required API keys using the command connect binance (replace binance wih the name of exchange you want to connect to).
  6. Fetch the balance to verify the connection.

Scripts Exploration

The Hummingbot Dashboard offers a variety of pre-written scripts that can be utilized as templates for new bots. Here's how you can explore and modify them:

  1. In the dashboard, navigate to the File Explorer.
  2. Browse through available scripts. Those prefixed with "V2" are part of the V2 framework.
  3. For deeper understanding and advanced configurations, consider joining the Bot Camp, which offers comprehensive training on these scripts.
  4. Open any script to view its content. The built-in editor allows for direct modifications.
  5. If you're more comfortable with an external IDE, you can edit scripts there and then upload them back to the dashboard.

Saving Changes

The process of integrating credentials and leveraging available scripts is streamlined to ensure both security and efficiency. Whether you're editing scripts directly in the dashboard or using an external IDE, remember to save your changes to any scripts you modify.

If you make modifications in the dashboard's editor, use Apply button to apply changes, and then Ctrl + S to save.

Next Steps

The Master Bot Profile ensures the secure handling of credentials and offers users flexibility in creating bots. Next, learn how to create and manage new instances:

Managing Bots

Using Dashboard to Deploy and Backtest Strategies - Part 4

Introduction

In this tutorial, we'll dive into the process of spawning new bots, starting a strategy, making modifications, and running one for a set duration. Let's get started!

Managing Bot Instances

Hummingbot Broker

On the instances page, to the right, you'll notice the Hummingbot broker. Before creating any bot, it's essential to start this broker. This component is responsible for enabling communication between the dashboard and the bot, facilitating commands such as starting or stopping a strategy.

Creating Bot Instances

On the left, you'll find the creation card. Here, you'll input:

  • Name of the container
  • Desired Docker image (useful if you have a custom Hummingbot version with unique strategies)
  • Profile to start from (for now, only the master bot is available, but more profiles will be added in the future)

Once a bot is created, a card will appear allowing you to select a strategy from those available. After choosing a strategy, press "Start" to launch the bot with the selected strategy.

Available Strategies

The strategies available for selection are the same ones present in the master bot. Once you've chosen one, simply press "Start," and the bot will initiate with your chosen strategy.

Customize Strategy

Below the instances page, the file explorer allows users to view and modify the specific scripts or files for each bot they create. Each bot has its distinct set of scripts that can be adapted to fit specific trading requirements or strategies.

Putting it all together

To provide a comprehensive example:

  1. Navigate to the Instances tab.
  2. Start the HB broker (may take a few minutes).
  3. Create a bot instance, giving it a name like "dman" and using the Hummingbot latest Docker image and the master bot profile.
  4. View the available strategies and select one (e.g., the "Bollingrid multiple pairs").
  5. Use the file explorer to customize the chosen strategy as needed.
  6. Execute the strategy, monitor its performance, and make necessary adjustments or stop it as required.

Next Steps

The subsequent chapter will focus on analyzing the results of our deployed strategies.

Analyze Bot Performance