Trading-Bots - Part 2 - Installation and configuring "ZenBot"


Disclaimer:
I am not responsible for anything done with this bot(s). You use it at your own risk. 
There are no warranties or guarantees expressed or implied. You assume all responsibility and liability.


Hey,

I´m back with the second part of my new series about the trading bots "ZenBot" and "Gekko". In this tutorial, you will learn how to install and setup "ZenBot" on a Windows 10 machine and on an Ubuntu 16/18 server, installing NodeJS as a requirement and configuring your installation with a config file. For these files, you need an API-Key from your exchange of chose. These are easy to obtain and only needed if you want to start the bot in "live trading" mode. But I will tell you more about the configuration after we have successfully installed our bot.

If you haven't read my first article covering "ZenBot" and "Gekko" you can do so here.

https://www.publish0x.com/trading-bots-all-about-zenbot-and-gekko/trading-bots-part-1-overview-and-introduction-xwqmmn

 

If you need to insert a command in the shell and I don´t mention the distribution, you can insert the command on Windows or Linux equally.

351665157-40cab446170535f928f24e18e3ad84df55b508cf31e8185a4791ce4059919ccd.png

Requirements:

For the sake of this tutorial, you need a Windows 10 or Ubuntu 16/18 machine with at least 100mb of free space and some experience with your operating system of choice. 

Windows 10 | Linux 16/18
Node.js (version 8.3.0 or higher)
MongoDB
Git (optional)


Install NodeJS:

NodeJS is crucial for the installation since it contains the NPM-Packetmanager to install all the node modules required by our bot. Now we need to download not the latest NodeJS version since "ZenBot" does require NodeJS version 8.x to run. So please go ahead and download this release.

https://nodejs.org/dist/latest-v8.x/node-v8.16.0-x64.msi

for linux type 

sudo apt-get update
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential


After installing NodeJS please install git so we can easily fetch our bot from GitHub. To do so, we need to open a command shell on Windows. This can be done with the keys on your keyboard.

Windows-Key + R

In command promt insert -> cmd <- then press -> ENTER <- or the "OK" button below

Now enter -> cd c:/ <- then press again -> ENTER <- to switch to your C: drive in windows

Perfect ... Now we can start to install more requirements before we start finally to install the bot. We need to install MongoDB to save the backfills we need to make any simulations on a specific selector like ETH-BTC. But I will tell you more on simulation and the selector in a later tutorial. Ok, you need to verify that NodeJS was successfully installed.

node -v  <-- show the current installed / used NodeJS version

it should show something like 

C:\Users\casp0or>node -v
v12.2.0


Install MongoDB:

After we checked that everything was done right and is working we can install MongoDB by downloading it from the official site on Windows 10 or following one of the following tutorials.

Windows 10

https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-4.0.10-signed.msi

Linux

https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-18-04

https://www.howtoforge.com/tutorial/install-mongodb-on-ubuntu-16.04/

 

Install GIT:

I hope the installation was successful and we can move on to the next step which is fully optional. To install GIT we only need to insert one command into our currently opened shell.

npm install -g git

This installs the GIT command line into our "GLOBAL NPM-Package" dir and we can use GIT now globally. This means, that you don´t have to download the files for installing the bot manually from GitHub. If you don´t want to use GIT, just download the Zip-File from https://github.com/deviavir/zenbot with the green button on the right side. Then unpack it to c:/zenbot...

git clone https://github.com/deviavir/zenbot.git

without GIT for linux do
wget https://github.com/deviavir/zenbot/archive/master.tar.gz
tar -xf zenbot-master.tar.gz
mv zenbot-master zenbot


Install "ZenBot":

Ok, now you have the needed files on your hard drive to install "ZenBot". Next, we need to switch our command shell to the folder just created by you or GIT and install the required NodeJS-Modules.

cd zenbot

npm install

When the installation is finished it should look something like this.

351665157-fbe93b67a698e455941ddcfbb1fd3acd4cd91bdd068c1c4f766e60683da86d50.png

 

Edit config file:
After installing the modules without any error, we can proceed to the config file and copy it to the same directory it is already in but without the "-sample" in its name. So copy the file "conf-sample.js" and rename it to "conf.js". Now open the just copied file and insert your API-Keys if you want to do live trading later on. How to obtain an API-key is something I want to do in a later tutorial since I want to cover all of the main exchanges in one single tutorial.

351665157-8a46a0244dfb7aa9d051dde4289cb1f2080bed72b5e2461a621e6ca06882a181.png

Please go to line 159 in your config file and edit the line 

c.currency_capital = 1000 

change to 
c.currency_capital = 1

351665157-710f244a08f1b143576334bdc60c231d5b01945ece3dc49ebc1cb13d2eda2577.png
This changes the amount of BTC the simulation is running with. I like to enter 1 or 0.1 so simulate some value I can afford. "currency_capital" is your value in BTC and "asset_capital" is your value in ETH. If you want to start simulating with ETH instead of BTC then you need to change these values.

351665157-5ae8c48649eb0f5cd77961d69dc5bbfd847f003f3c32564e3a09ca67799cd5bb.png

 

Start MongoDB:

Puh... this was a long way down here... but wait... If you haven´t started MongoDB, now it is the right time to do so. If you are on Linux and followed one of the tutorials above, then MongoDB should already be running. On Windows, you should open another command shell like described above and enter the command to start MongoDB.

mongod

This command should start your "local MongoDB community server". If you see an error like "command not found" you need to enter the directory the DB was installed to. In my case, this would be "C:\Program Files\MongoDB\Server\4.0\bin".

for "command not found" on Windows 10 enter 

cd C:\Program Files\MongoDB\Server\4.0\bin <- may vary on your installation

then press -> ENTER <-

after changing the directory enter

-> .\mongod <- and press  -> ENTER <-

 

 

First backfill:

I think we have everything set up to start our bot the first time. To be able to run a simulation, we need to fill our database with some data for the preferred selector and market. This is done by inserting a specific command into the first shell we opened before. On Linux, you should already be on the screen where you can see the directory where we installed "ZenBot". Something like this.

On Windows, it should look like this

351665157-9ee1748376e9527daeffffdd33acb18668f460888d3cdf8d27eec01a0b9982e6.png

On Linux like this

351665157-af81ccbfc40f160e266be7fa60e62d7728fe0e085ef601dc5dc567926433d16b.png

Now we are ready to start our first "backfill". Choose a selector you want to simulate and type the following command into your shell and press "ENTER" to start.

node zenbot backfill poloniex.ETH-BTC --days=60

This backfill will save all trades for the last 60 days on the exchange "Poloniex" with the market "ETH-BTC". Note the "--days=60" parameter I used to get the last 60 days of trading. This can be configured in the "conf.js" file so you don´t have to type this in all commands. The default value for days in the config file is 14 days. But for the sake of this last step, I don´t cover editing the config file here. You can play around with the values later on. But your current logs in the shell should look something like this if everything before was done right.

351665157-ffd2c146ed59dab156c1267a05a4b365434e3fd3d6e698f42c1ce01528567545.png351665157-7a59fd731d2012f2b7f48ca1bb14846cdd4fcac73cbc53ea6f6b897210c3107b.png

 

Finally the simulation:

Nice, the DB is filled with some trading data to simulate the last 60 days of trading Ethereum against Bitcoin on the exchange Poloniex. To start our simulation, we need to enter the command for simulating in our shell. Many parameters can be added to this command but for simplicity, we enter just our "--days=60" parameter. 

Ok here is now the command you are waiting for...

node zenbot sim poloniex.ETH-BTC rsi --days= 60

Here you can see we first inserted "node zenbot" this starts our bot. Next comes the command we want "ZenBot" to execute, here it is "sim" for simulating. Then comes the "exchange.market" here "poloniex.ETH-BTC". And finally the "--days=60" parameter to run the simulation for the last 60 days of trading Ethereum against Bitcoin on Poloniex.

351665157-ca6a8ecce4bd8d585c7b76144f6291c72dd090c6ffea321b64bb9611448bbe7c.png

 

Results:

A simulation result from "ZenBot" should look something like this. Here we didn´t make any profit but this was only a test without any real parameter tweaked.

351665157-dfa9f8353dd457d5c5fa79496ab4cbca0477f2770a5d5c1913905fb816ac2caf.png351665157-6a44c3fdc67d9b10363c7a04b7183f62499533389f4f824890e03daebb1a121c.png

After our simulation is ok and made some money, all we need to do is changing the "sim" command to "trade". But please wait for the next tutorials where I will cover more on simulating and finding the right coin and market for you. 

I hope you found this useful and please play a little bit around with the "sim command" to get familiar with the "workflow".

 

Best Regards
casp0or

How do you rate this article?


3

0

casp0or
casp0or

Web & App Developer


Trading-Bots - All about ZenBot and Gekko
Trading-Bots - All about ZenBot and Gekko

Here you can learn how to use the trading-bots "Gekko" and "ZenBot". Both are NodeJS high-frequency trading bots written in JavaScript. I will cover all aspects like setting up your own bot up to real trading. I will also publish my results every week.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.