This project is not maintained anymore.

After many years of working on Gekko, I’ve decided to stop my involvement in maintaining this project. You can read more about this decision on medium.

I’m now putting all my focus on my new prop trading firm Folkvang. You can find an article about that here on Coindesk.

If you’re interested in following this new journey, feel free to add me on Twitter.

Best of luck to everyone in their trading. So long, and thanks for all the fish!

Fork me on GitHub

Gekko's architecture #

Gekko architecture

Every Gekko instance has two core components:

Communication between those two components is handled by Node.JS' Stream API. The Market implements a Readable Stream interface while the GekkoStream implements a Writeable Stream interface.

A Market #

All markets in Gekko eventually output candle data. Where these candles come from and how old they are does not matter to the GekkoStream they get piped into. On default Gekko looks for markets in the core/markets/ directory. The top orange block in the picture is a BudFox market (the default semi-realtime market that gets live data from exchanges).

Example Markets that come included with Gekko are:

A GekkoStream #

A GekkoStream is nothing more than a collection of plugins. Plugins are simple modules that can subscribe to events, and do something based on event data. The most basic event every GekkoStream has is the "candle" event, this event comes from the market.

However plugins are allowed to broadcast their own events, which other plugins can subscribe to. An example of this is the tradingAdvisor plugin. This plugin will implement a strategy that will be fed candle data. As soon as the strategy suggests to take a certain position in the market ("I detect an uptrend, I advice to go long") it will broadcast an advice event. The paperTrader is a plugin that simulates trading using these advices, the trader is a plugin that creates real market orders based on these advices. You can decide to only turn the paperTrader on or to turn the trader on (you now have a live trading bot).

When you run a backtest using Gekko the following things happen:

*Gekko refuses to load plugins that are unsupported in specific modes. During backtests you never want to enable the real trader to enter market orders. Because if you would the advice would be based on specific moments in the backtest, not on the current state of the market.

Plugins & Adapters #

Those two core components describe the majority of Gekko's flow. A lot "core functionality" like saving candles to disk are simply plugins that push all candles to a database.

Separated architecture #

The modular nature of Gekko makes it very dynamic and allows for rapidly creating new plugins. However there is an ugly side to this story:

The tradingAdvisor runs TA strategies against a market. The problem however is that most TA indicators need some history before they can give accurate results. If you want to use an EMA (exponential moving average), you need some history to base the initial average on. But because the tradingAdvisor doesn't know what market data is going to be made available later by the market, it needs to do some fetching itself and compare that to locally available market data (stored in the local database) to see if it can stitch the two sources.