Tutorial: Setting Up the Honey Framework Algo Server

Cris Mihalache
Bitfinex
Published in
5 min readOct 29, 2018

This guide will walk through setting up a Linux server on Linode and using it to run Honey Framework algorithmic orders via the bfx-hf-algo-server. The end result is an HF server connected to your Bitfinex trading account, ready to accept algorithmic orders.

We will be using the standard 2GB server instance, as the HF algo server is not resource intensive and can scale efficiently with limited RAM.

If you find that the server is slow or reaches memory limits, upgrade your Linode server to a larger instance.

Initializing the Server

To begin with, create a new 2GB server instance and select a server location close to the Bitfinex cluster in Europe. We recommend Frankfurt, DE.

Then, deploy a new Ubuntu 18.10 image on the fresh instance, and set a root password.

This password will be used to login to the Linode immediately after creation, in order to set up your user account. Make sure to save it somewhere, although it can be reset from the Linode interface if needed.

Once the deploy completes, boot your Linode and head over to the Remote Access tab in order to launch a console interface and access your server:

Login to the console with the username root and the password you configured earlier. This will open a shell instance via which you can configure the server. Note that the password will not appear as you type it.

Creating a User & Installing Dependencies

Before continuing, you should create a new user on the server in order to not run the HF as root, which is the system administrator. To do this, type in adduser USERNAME and follow the prompts that appear to set a user password.

Once complete, give the user administrative privileges by running usermod -a -G sudo USERNAME. Then, close the session with exit and login as the user you just created.

You will need Node.JS in order to run the HF algo server; to install it run sudo apt-get install nodejs npm and follow the prompts. We also recommend updating the server packages by running sudo apt-get update.

Running the HF Algo Server

To set up the HF algo server, clone the code into a folder and install node dependencies with:

git clone https://github.com/bitfinexcom/bfx-hf-algo-server.git
cd bfx-hf-algo-server
npm i

Once this is complete, set up your API key & secret combination, along with connection credentials if you are trading on ethfinex by creating a .env file in the code folder with the following contents:

API_KEY=...
API_SECRET=...
# If trading on ethfinex
PLATFORM=ethfinex
WS_URL=wss://api.ethfinex.com/ws/2

You can create this file by running nano .env, which will open the nano text editor. Once you’ve populated the file contents, close the editor and save your changes with CTRL+X (press ‘y’ for confirmation’).

Running the algo server should be done in a tmux session for persistence; processes that are started in a tmux session will continue after you disconnect from the server, otherwise the algo server will terminate upon disconnect if you simply run it in the Lish shell.

To create a new session, run tmux new -s hf and in the future when opening up the Lish console again, attach to it with tmux attach -t hf

To start the server, within this tmux session, run the following command:

npm start

After the embedded mongodb instance downloads, you should see the order form layouts automatically registered on your account:

Followed by active heartbeats from the algo server, to notify the Bitfinex UI that it is connected:

At this point you can close the Lish console and use the algo server directly from the Bitfinex UI. You should see the new order types available in your order form dropdown:

Using the Algo Server

From here on out, submit your orders normally via the Bitfinex UI and the algo server will take care of the rest. Keep in mind all open orders will be cancelled as a safety precaution when the algo server disconnects from the Bitfinex/Ethfinex APIs. The server will automatically recreate all known orders when it starts up again.

To clear all known orders and reset the database, stop the server and delete the contents of the db folder with:

rm -rf db/*

To update the server to the latest version, log in periodically and attach to the tmux session, stop the server, and run:

git pull origin master
npm update bfx-hf-algo

This will pull the latest changes from Github/NPM. Afterwards, you can run npm start again to start the server.

We hope this guide has been helpful in getting set up with the Honey Framework. If you have any questions or suggestions, feel free to open a ticket on our Github issue tracker for bfx-hf-algo or bfx-hf-algo-server.

Stay up to date with Bitfinex on Twitter, Telegram, LinkedIn & YouTube.

We’ve recently open-sourced a number of the development libraries most essential to us. To learn more about these, please visit the Bitfinex Github.

Join us on our mission to create the most innovative & industry-leading cryptocurrency exchange.

--

--