Skip to content

Instantly share code, notes, and snippets.

@Chubek
Last active May 1, 2024 10:31
Show Gist options
  • Save Chubek/5137a0b75a76d5f9f38d1e768d56d591 to your computer and use it in GitHub Desktop.
Save Chubek/5137a0b75a76d5f9f38d1e768d56d591 to your computer and use it in GitHub Desktop.
Hummingbot Gateway

1- wget setup_gateway.py:

wget -qO- https://gist.githubusercontent.com/Chubek/5137a0b75a76d5f9f38d1e768d56d591/raw/c4b8c8c25e6991f01367d9ed5a5fa2be7627d83d/setup_gateway.py > setup_gateway.py

2- Preprocess it with m4, using your credentials and pass it to python:

# For example
m4 -DEXCHANGE=binance -DAPI_KEY=4242 -DAPI_SECRET=2424 setup_gateway.py | python

python here is the python in the bin directory of your Conda env. You must activate it:

conda activate python

Keep in mind that you must install and set up Hummingbot first (with the provided install and compile scripts).

Another way to run them is:

make build
make install
make compile

This must be done in the directory of the source file.

import sys
from os.path import join
from hummingbot.client.settings import GLOBAL_CONFIG_PATH, generate_key_file_path, get_key_file_path
from hummingbot.client.config.global_config_map import global_config_map
exchange = "EXCHANGE"
api_key = "API_KEY"
api_secret = "API_SECRET"
def setup_gateway():
config_path = join(GLOBAL_CONFIG_PATH, "conf_global.yml")
key_file_path = generate_key_file_path(api_key)
global_config_map["key_file_path"].value = key_file_path
global_config_map["api_secret"].value = api_secret
with open(config_path, "w+") as f:
f.write(global_config_map.dump_to_yaml())
print(f"Gateway for {exchange} configured successfully.")
if __name__ == "__main__":
setup_gateway()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment