Using gekko trading platform, 2 years after the project was abandoned, was it worth it?

Background on why I started looking at Trading Bots

I have been trading crypto for over 10 years using many of the exchanges. I have always seen bots executing orders. For example, I put in a limit order to buy 100 crypto’s and when I look at the order book, I see various orders either ahead or behind me in price. Those orders have some very specific quantities such as 1325.57 to buy at let’s say 16,456.xxxx . I’ll see that particular quantity within seconds to change in price to 16,454.xxxx then to 16,449.xxxx. Sometimes happening very quickly, much faster than I can certainly cancel and re-enter a new limit order.

So are bots profitable and can they make you “more” than to do just a buy and hold? I recently read Deandree’s article and was truly motivated: This was very well written, inspirational, and great analysis!

So begins my quest to find something that I can create my own strategies and test them. When I searched the web, there were lots of platforms out there. Some were open source and some were public platforms. The open source ones allowed you to use code and programming to implement strategies. The public platforms, in some ways they also allowed you to implement custom strategies, but they were always somewhat limited by the construct of their framework. For example, coinrule, I might as well trade with one hand behind my back. While at first, it might look like “endless possibilities”, there are definite finite boundaries.

So I started looking at a couple of open source bots and narrowed down to gekko because it looked like it was well documented.

Getting it up and running

If you have been able to launch gekko, you likely have a good understanding of how node, npm, and javascript works. It’s not that bad and fairly straightfoward, however some of the dependencies are severely outdated. For example, it uses Node v. 8.x where currently Node is at v. 15.x.

My first run of gekko was installed on a raspberry pi 4 (8gb) with a desktop image. I have several images ready to go with the base install of raspbian. It’s like having aws instances that I can spin up in seconds with memory cards. I can also create images and restore very easily. I have scripts that will setup the right environments for different types of projects.

Initially I had installed it with the latest version of Node only to find that the dependencies had used prior Node version syntax that have been deprecated, errors, warnings, etc. So ultimately, I could only get things working by using v. 8.x. Maybe I was doing something wrong, but when I downgraded, I was able to finally move past some of the issues I had with the following node modules:


I was able to node install the gekko directory and the exchange directory, but not without warnings, errors, etc. But nothing that I can tell so far that is producing errors yet in acquiring data or backtesting. Perhaps the errors will show themselves in actual trading…

Acquiring market data with gekko

I started with loading various datasets from poloniex, kraken, and binance for 3 coins, btc, eth, and xtz with combinations 1 year, 3 months, and 1 week datasets. This way I can try some backtesting using hourly increments and daily increments.

Once I loaded data, I wanted to see what the data looked like in the gekko database. I used DB Browser for SQLlite and connected to the databases in /gekko/history folder.

The data is stored in candle format with OHLC and the lowest level of granularity is minutes. Any simulations or strategies have to be based on minute data for analysis.

The start is stored as a Unix epoch time:
1605114540 which is Nov 11, 2020 5:09:00 PM GMT
1605114600 which is Nov 11, 2020 5:10:00 PM GMT

Now, let’s create a strategy and test it with this data

Watching Mike’s strategy video was incredibly useful. One of the most useful tutorials and “how-to” that I have seen across all bots that I have looked at. Yes, that’s a bold claim, prove me wrong…

I created my own “moon” strategy that uses a couple of very simple things:

ema set to 5 yellow
ema set to 40 orange
sma set to 15 blue
sma set to 50 purple

If you look at this graph, you will see that when the yellow goes above the blue line, it is generally going up and when the yellow line is going below the blue line, it is generally going down. I tried to create a strategy that will BUY when the yellow is above the blue and SELL when the yellow line goes below the blue. Also, need to make sure that I do a buy first before selling. Here is my code in the moon.js strategies file:

strat.init = function() {
logic =
longpos: false
this.logic = logic;
//these values have been parameterized so that I can play with them
this.addTulipIndicator(‘ema1’, ‘ema’, {
this.addTulipIndicator(‘ema2’, ‘ema’, {
optInTimePeriod: this.settings.slow
// these indicators have not yet been parameterized, just hard coded
this.addIndicator(‘sma1’, ‘SMA’, 15);
this.addIndicator(‘sma2’, ‘SMA’, 50);
this.requiredHistory = 10; // require 10 candles before giving advice
strat.check = function(candle) {
// your code!
const ema1 = this.tulipIndicators.ema1.result.result;
const ema2 = this.tulipIndicators.ema2.result.result;
const sma1 = this.indicators.sma1.result;
const sma2 = this.indicators.sma2.result;
console.log(candle.start.format(‘lll’), ema1.toFixed(2), ema2.toFixed(2), sma1.toFixed(2), sma2.toFixed(2));
//first determine if I am long
//if the ema1 goes below sma1, then sell
this.logic.longpos = false;
} else { // there is no position and we should look to buy
//but if ema1 > than ema2, sma1, sma2
this.logic.longpos = true;

myconfig is set to run by the hour. I ran this as a command line backtest using:

In my output I saw the “ticks” for each hour and a simulated buy trade for my dataset for ETH starting Nov 22, 2020 11:55AM from my logging.

I then saw that trade also simulated sell trade on Nov 24 at 05:55 from my logging.

Now, let’s have a look at to see if this really worked as it should have. Based on Cryptowatch, we should
BUY Nov 22 10:00
SELL Nov 24 04:00

However the program output did a backtest buy at a slightly different time. My guess is that the candle at 10:55 completed and met the condition, the next candle signaled the opportunity to BUY:
BUY Nov 22 11:55
SELL Nov 24 5:55

However, the only issue that I see is that in the roundtrip, I am seeing different times than logging I did in the strategy.
BUY Nov 22 17:55
SELL Nov 24 11:55
(This seems to bee 6 hours head, which is what my local time zone is????)

I have not yet generated the output for what the price should be for buying minus the fees, but I just wanted to see if would buy at the right time based on the indicators. There is a couple of things that could be gong on here. The current graph on cryptowatch shows 1300, which is the local time here. That lead me to believe that cryptowatch is in my local time and not UTC.

Looking at the data from the backtest, the candle at:
Nov 22 10:55 EMA1 544.14 and SMA1 540.47

Looking at the data from
Nov 22 11:00 EMA1 544.39 and SMA1 540.10

The crypto watch candles are from the top of the hour to the top of the next hour, whereas the backtest if from the 55 minute mark to the next 55 minute mark. That could account for some of the difference between EMA1 and SMA1.

This tells me that the time s actually in UTC which is what I was hoping for. But if that is true, shouldn’t the current candle data show 1900 instead of 1300? As my current time is now 2:00PM CST

Despite the current date issue on cryptowatch, it looks like gekko did what it was supposed to do with good results:
The market went DOWN 8.39%, but my backtest strategy went UP 8.59%

With this very small dataset of ETH and a very simple strategy of anlyzing visually one weeks worth of data with only 1 coin. I was able to visually see what would work in cryptowatch with one coin for 1 week and implement. Will this work with all coins on all timeframes? I did test it and it doesn’t. It’s just a very simple strategy that is not a winner. You have been warned.

In Summary

I was able to set this up fairly easily and quickly. It only took me a few hours to do this. I also looked at the different indicators that are provided by Tulip and Talib that you can add to your strategy and I feel like I can focus on strategy now and backtest. That is probably the first part to bot trading that I should really understand and determine if I should do live trading with it.

I can also do some paper trading in parallel to see if I employ some strategies that I have come up with, how will it do going forward?

If I just want an environment where I can create strategies and backtest, this seems like a pretty good place to start. I haven’t spent more time analyzing down to the penny to see if things are calculated with fees, but that’s a next step. I am fairly familiar with Javascript and node which makes it very easy for me.

Pros and Cons of gekko, (developers, take note)

I’m am very fond of youtube videos showing real world examples and how to guides. Sometimes a video or picture is worth a thousand words that could not best describe how something works. The best thing that Mike had done with this was create that simple video showing how to create a strategy. From there on, it was pretty easy. Here are some observations of pros and cons for me:

1) Node and Javascript is easy to program
2) Loading datasets is easy from multiple exchanges
3) The mechanics of creating strategies is fairly straightforward
4) The video made it incredibly easy to follow along with examples like odd/even days, etc.
5) Datasets will load in the background so your not stuck waiting.
6) Documentation is good for getting started.

1) Backtest would start with a sell first
2) installation was a bit difficult, but I’m persistent
3) Code needs to be updated to pull data most optimized for the exchange
4) There are newer algorithms and neural nets that should be incorporated
5) The UI could use some work, especially to show some of the indicators like MACD, EMA, SMA, etc.
6) Lacks documentation on how the platform was developed.

IT Professional and technical geek