Fork me on GitHub

Plugins #

This is a technical document explaining the role of Plugins in the Gekko codebase. For a non technical document about available plugins, see here.

Within Gekko most functionality is encapsulated into "plugins". These are simple modules that process some data (from Gekko events) and do something with it. For example emitting a new event or sending a message out to some external service like telegram, or doing a live trade at an exchange.

Whenever you run a Gekko (live trader, paper trader, backtester or importer) you are simply running a number of plugins and feeding them with market data. For a more detailed explanation, see the architecture doc.

For example, there is a plugin called the paperTrader which is responsible for simulating trades (used in backtests and paper trading). It does this by listening to advice events coming from a strategy, and simulating trades whenever they fire (and firing trade events). Find a longer list of plugins that come with Gekko here.

Structure of a plugin #

A plugin can be a very simple module that simply listens to some event:

// A plugin that will buy Champagne when we MOON

// example: doesn't actually work..
const alexa = require('alexa');

const MOON = 1000000;

const Plugin = function() {}

Plugin.prototype.processPortfolioValueChange = function(event) {
  if(event.value > MOON) {
    alexa.say('Alexa, buy the best Champagne!');

module.exports = Plugin;

Have a look at the events doc for all events your plugin can subscribe to. For technical inspiration it's easiest to look at the code of Gekko's plugins (here gekko/plugins.js).