Gekko Forum
New Strategy Format - Printable Version

+- Gekko Forum (https://forum.gekko.wizb.it)
+-- Forum: Gekko (https://forum.gekko.wizb.it/forum-13.html)
+--- Forum: Strategy Development (https://forum.gekko.wizb.it/forum-12.html)
+--- Thread: New Strategy Format (/thread-57723.html)



New Strategy Format - askmike - 10-19-2018

Gekko Strategies are about to change! The main thing I need to update now is meta information (things about your strategy) so strategies become easier to work with for Gekko. The goal of these changes are:

- Better dealing with strategy parameters (no more TOML files)
- More information so Gekko can display all strategies in a nice page so people can read about more conviently. Specifically so Gekko can render this page: https://app.gekkoplus.com/strategies/macd

[Image: 47197991-54734700-d39c-11e8-9d5c-017ff04cd1ac.png]


See the link above for the full page.

New strategy format proposal

That page currently needs a JSON structure that describes the meta of the strategy, this is the JSON structure:

Code:
{
  "name": "MACD",
  "slug": "macd",
  "description": "\n\n  <p>The MACD is one of the most popular trend watching <strong>indicators</strong> in finance, it was created by Gerald Appel in the late 1970s. By using multiple price averages (EMAs) of different periods (one that follows the market more closely and one that lags behind, only catching bigger price swings). The indicator itself ouputs multiple numbers, when comparing them they can be interepted as signals that show when the trend of the price is changing.</p>\n\n  <p><img src='/assets/MACD-pic.gif' alt='the MACD visualized in a candle chart' /></p>\n\n  <p>The MACD <strong>strategy</strong> in Gekko is a simple strategy that implements the indicator. By comparing the difference between the EMAs from the signal the strategy triggers buy and sell signals. The strategy does come with additional logic:</p>\n\n  <ul>\n    <li><strong>thresholds:</strong> a signal will be triggered as soon as the difference goes above or below a configurable threshold, making the strategy more flexible than simply checking if the difference is above or below zero.</li>\n    <li><strong>persistance:</strong> instead of trading as soon the difference is above or below the threshold, the strategy will wait a few candles to see if the difference keeps persisting. Only if it does the strategy will actually signal to Gekko to buy or sell. By setting persistance to 0 this behaviour is disabled.</li>\n  </ul>\n\n  ",
  "intro": "The MACD is one of the most popular trend watching indicators in finance, it was created by Gerald Appel in the late 1970s. By using ...",
  "quant": "1337quant",
  "exchanges": [
    {
      "slug": "kraken",
      "name": "Kraken",
      "markets": [
        "USD/BTC",
        "USD/ETH",
        "USD/BCH"
      ]
    },
    {
      "slug": "poloniex",
      "name": "Poloniex",
      "markets": [
        "USDT/BTC",
        "USDT/ETH",
        "USDT/BCH",
        "USDC/BTC",
        "USDC/ETH",
        "USDC/BCH"
      ]
    }
  ],
  "frequencies": {
    "min": 30,
    "mid": 60,
    "max": 360
  },
  "indicators": [
    "MACD"
  ],
  "parameters": {
    "thresholds": {
      "up": {
        "type": "float",
        "min": 0,
        "max": 1,
        "default": 0.025
      },
      "down": {
        "type": "float",
        "min": 0,
        "max": -1,
        "default": -0.025
      }
    },
    "MACD indicator": {
      "short": {
        "type": "int",
        "min": 1,
        "max": 100,
        "default": 10
      },
      "long": {
        "type": "int",
        "min": 1,
        "max": 100,
        "default": 21
      },
      "signal": {
        "type": "int",
        "min": 1,
        "max": 100,
        "default": 9
      }
    }
  },
  "highlightedBacktest": {
    "id": "/backtest-MACD-basic-profit",
    "performanceReport": {
      "startTime": "2018-07-03 00:16:00",
      "endTime": "2018-08-02 03:16:00",
      "timespan": "a month",
      "market": 15.805757433037172,
      "balance": 8440.8606609821,
      "profit": 1837.5706609821,
      "relativeProfit": 27.828107821738854,
      "yearlyProfit": 22279.133681120486,
      "relativeYearlyProfit": 337.3944455130773,
      "startPrice": 6603.29,
      "endPrice": 7646.99,
      "trades": 7,
      "startBalance": 6603.29,
      "exposure": 0.4426002766251729,
      "sharpe": 50.99866402802568,
      "downside": null,
      "alpha": 1821.7649035490629,
      "risk": 8
    },
    "market": {
      "exchange": "binance",
      "currency": "USD",
      "asset": "BTC"
    },
    "tradingAdvisor": {
      "candleSize": 60
    }
  }
}

- market and tradingAdvisor are the "default" market & candleSize.
- "highlightedBacktest" is the performanceReport of a backtest using this strategy (over the default market and configSize).
- "parameters" is now in JSON.
- rest is meta

That's a draft, does anyone think we need anything else? Maybe we can pull out the HTML and put it in a readme MD file?


RE: New Strategy Format - tommiehansen - 11-15-2018

Just add an optional json file for a strategy and let the rest be as is, therefor no compatbility issues?

/strategies/
myStrat.js
myStrat.toml
myStrat.json

if( !myStrat.json )
desc = 'No description available',
title = filename,

etc ..


RE: New Strategy Format - askmike - 11-22-2018

Yeah either that or make the JSON part of the strategy under strat.meta or something. However we end up implementing it, it will be backwords compatible and not break existing strategies.