Trading-Bots - Part 3 - Installation and configuring "Gekko"

Trading-Bots - Part 3 - Installation and configuring "Gekko"


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,

for the sake of simplicity I will copy some parts from my Trading-Bots - Part 2 - Installation and configuring "ZenBot" post since the first part is equal in most parts to the post before. Though I will still add some information to this part because on "Gekko" you need some things done differently. But now I´m back with the third part of my new series about the trading bots "ZenBot" and "Gekko". It took me some time because I tried to install "Gekko" on Windows 10 "the normal way" ... but this does not go well... some libarys are missing but dont get upset, you can use it on Windows 10 with something special called the Linux-SubSystem for Windows. This is an Ubuntu 16 or 18 shell right on your Windows 10 machine. Linux is not very hard to use but hard to master ;) with some practice you should be able to do all sorts of different stuff with this.

In this tutorial, you will learn how to install and setup "Gekko" on a Windows 10 machine running a Linux-SubSystem 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 articles covering "ZenBot" and "Gekko" you can do so here.

trading-bots-part-2-installation-and-configuring-zenbot

trading-bots-part-1-overview-and-introduction

 

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-ba59182ad23b3ac8f4f99b834ba98774c67388648f70519cc7f0c398620117bf.jpeg
*Image from "Gekko" GitHub page


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)
Git 

Unfortunately "Gekko" has currently some problems with installing on a Windows 10 machine... But this is not a problem since Windows 10 can use an Ubuntu 16 or 18 bash which can be installed through the Windows 10 store. To do so, we need to do some steps in preparation.

This is taken from the "Gekko" docs HERE but slightly altered because I followed these steps and it seems that they miss something.
(I believe it was written by a time where the ubuntu subsystem was in beta)

Enable Bash on Windows 10 
To install Bash shell on your Windows 10 PC, do the following (see here for more info):

Open Settings.
Click on Update & security.
Click on For Developers.
Under "Use developer features", select the Developer mode option to setup the environment to install Bash.
On the message box, click Yes to turn on developer mode.
After the necessary components install, you'll need to restart your computer.

Once the components installed on your computer, insert this command into a Windows 10 PowerShell. You can open these by using the "Windows-Key" on your keyboard and then you have to enter "powershell" and it should appear in the searchbar. Right click on it and select "Run as Administrator".

Now enter in the newly opened PowerShell running as "Administrator":

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux


After your computer restarts, you will notice that Bash will not appear in the "Recently added" list of apps, this is because Bash isn't actually installed yet. Now that you have setup the necessary components, use the following steps to complete the installation of Bash:

Go to the Windows 10 Store and enter ubuntu into the searchbar.

Select "Ubuntu 16.04 TLS" and install it. After the installation is completed, you can start Ubuntu 16.04.

Then you'll need to create a default UNIX user account. This account doesn't have to be the same as your Windows account. Enter the username in the required field and press Enter (you can't use the username "admin"). Close the "bash.exe" command prompt. Now that you completed the installation and setup, you can open the Bash tool from the Start menu like you would with any other app.

 

351665157-074c7a9e438b42ae9063a60075d3523f78cd4f7ccb302c0c5d40f6a593c8d896.png
Now you should see something like this... I entered the first command "sudo apt-get update" to verify that everything is working.


All steps below are inserted into the UBUNTU-SHELL

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.

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 we should check that we installed the correct version. This can be accomplished with a single line of code inserted into the Ubuntu-Shell.

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

It should show something like 

351665157-42a35449455a6dd54bff1603d7db38f06773bd8fff336ac90a4cd6ffec61d50d.png

 

Install GIT:

I hope the installation was successful and we can move on to the next step which is key for an easy process. I don´t know your Linux skills and for the sake of simplicity, we are working with some very basic commands. To install GIT we only need to insert one command into our currently opened shell, this way you don´t need to download the files manually and also you don´t need to extract them.

sudo npm install -g git

This installs the GIT command line into our "GLOBAL NPM-Package" dir (-g) 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. More advanced users who don´t want to use GIT can just download the Zip-File from https://github.com/askmike/gekko.git with the green button on the right side. Then unpack and mount the file location. Now go on an insert these two commands.

git clone git://github.com/askmike/gekko.git
cd gekko

351665157-25b87303de169145dc7bb5f81317e912d354b7a7483018e815857a27142d5747.png
It should look something like this.


Install "Gekko":

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

npm install --only=production


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

351665157-ae38ef02982c99abeb9515b5283eafd00f7f928bb7534f5992c2bff41ae6477b.png

Next, we need to install some more dependencies for the exchanges "Gekko" is using. Though we need to insert two more commands into the Ubuntu-Shell. One to switch to the "exchanges" folder and again an "npm install --only=production".


cd exchange
npm install --only=production
cd ..

351665157-93aa6b303643e61f83b6f30b18d049bccdff98f2d26d7b4d2500974f1510c56c.png


Nice, it should look something like this when this last installation has finished. Did you mention the "cd .." command from below? I think you should save it somewhere in your brain for later because we will make some use of it in later tutorials. I also have to mention, that these commands can be used on Windows or Linux equally. Oh... I almost forgot to tell you its function... with the "cd" command you can ChangeDir CD get it ;) On your current shell window you can type as an example this command.

"cd ##dirname##/##dirname" <-- this changes you current directory in the shell

"cd .." <-- this will move you out of the current folder. It changes back to the upper directory if there is any

 

Finished? Yeah, we are almost finished with part 3 of our Trading-Bot series covering the bots "Zenbot" and "Gekko". This last part will cover our first starting of "Gekko" and exploring the frontend it provides you in the browser. Last but not least we make some backfills to get market data for our pair of coins and chosen exchange as well as doing a simple simulation.

 

Starting "Gekko":

I´m covering these last steps with some images of the frontend as well as showing some functions we are going to use. But first let´s start our instance of "Gekko". Again a single command should do the magic.

node gekko --ui

351665157-00fef8a36f86b0213f347219bb6724f930f783be81d0ca95d5b6f59cf46ecb65.png

Your browser should automatically open with the UI. If it doesn't, and you see this message below, manually browse to http://localhost:3000.

351665157-8bcc3588d716fbe2a7a6803535c790e0032564a8dffa1d750d60ce1df2463b87.png

Stopping Gekko 
In bash hold ctrl + c.

Exploring the frontend:

Now comes some screenshots with descriptions what they are used for.

Home

351665157-787a5cd2e9d10d3491d89f71c3c1d4de8ebdd7bed03097917cee6766fe2ced8d.png
Home screen ... not really much to do here 😅

Live Gekkos

351665157-f919b9955c2b6c5df5c616bbc742d22bf9b34309b4fd6afa568620df8fea8026.png
Here you can start your bot in "Live Trading" mode so it uses your real money.

Backtest

351665157-aead5bb86f0e72eb7375ab8946b610f91227b9408e72a0ef57ed6e59d601df21.png
Here you can start the simulation with your chosen strategy on the data we collected on the "Local Data" tab following below.

Local Data

351665157-84d259d63716a0cd6ee5ff8cf4af2e1136082fbb1024865100012322e205de95.png
Next is the tab we want to use in a few minutes. Here you can save the "backfill" data for our simulations. To do so, we need to click on the button "Go to the importer" on the bottom of the page. Now you will see something like this.

351665157-a76b5185b33334c2fd91bc6b16be10f246bc9516310445a9c4fd6857f142a37f.png
I changed already our testing pair to BTC -> ETH and inserted the last month to start backfilling until the present day. After you clicked on the "Import" Button, you should see this.

351665157-03422a7a822386bb29c325845667a71531e4bc2c6fae2828c72fb21a565ffba6.png

Please wait for it to be completed

Config

351665157-83e5c15121fd79a31788ef93bc91dd7cf51b4caf03092a6c05261b1c5cf5230b.png
Here you can enter your API-Key(s) for the exchanges you want to be able to trade live on.

 

Nice we are almost finished. Just a last simulation with the data we downloaded before. I think it was not too difficult to come down here or was it? Since we have now a neat interface to play with, I think it was worth the pain 😜. To start the simulation, we need to go back to the "Backfill" tab and click the "Scan available data" button. This search the database for our data we should have already downloaded by now.

351665157-4edeff8338a25578886c52a5fdaf9299a3e4eb03dd024273fd39f708eea31c33.png351665157-12c837ec7034afaef8204cd7494cd18418adc1146134900a2374c7ad4bbc2b83.png

 

This was an easy task if you ask me. Next, we need to select our pair BTC -> ETH with the radio button right before our dataset and choose the strategy. I think we should go with RSI. You could adjust some parameter in the box on the right but for the sake of this tutorial, we will go with the standard parameter. Just enter 15 as candle size and change hours to minutes. 

351665157-fd84c5732fe3ac9e7586167d720ce32b8734000b51fd5115451de2449e2f52f6.png

Click "backtest" to start our first simulation. And voila we can see the result right below the "backtest" button.

351665157-793d1a65c8912d41a005187be3a14c1d80b1dd1907b3f6cc5834a218c3a1e4d1.png351665157-f30d13df4b25dd4ba8f6bf023772b6a94a79c1583922602aeebf3abfecce6a8c.png

Very good it already made some profit 😱. But don´t think that you are on the safe side. I think we should do some more test to see if we can make this result even better. 

This tutorial ends here and I hope you have learned something. Please let me know any issues below in the comments.

Best Regards
casp0or


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.