askmike / gekko

A bitcoin trading bot written in node - https://gekko.wizb.it/
MIT License
10.07k stars 3.94k forks source link

OS X - native talibindicators produce no results #1453

Closed magicdude4eva closed 6 years ago

magicdude4eva commented 6 years ago

Note: for support questions, please join our Discord server

Wrote a own strategy which initialises a number of talib indicators:

  this.addTalibIndicator('stochrsi', 'stochrsi', this.settings.stochrsi);
  this.addTalibIndicator('macd', 'macd', this.settings.macd);
  this.addTalibIndicator('bbands', 'bbands', this.settings.bbands);
askmike commented 6 years ago

Hey, Could you provide the following:

magicdude4eva commented 6 years ago

Config for strategy:

let candleFactor = 1;

config.tradingAdvisor = {
  enabled: true,
  method: 'magicdudecrypto',
  candleSize: 3,
  historySize: 25 * candleFactor,
  adapter: 'sqlite'
}

// ======================================================================
// BBands:
// MATType: SMA   = 0, EMA   = 1, WMA   = 2, DEMA  = 3, TEMA  = 4, TRIMA = 5, KAMA  = 6, MAMA  = 7, T3    = 8
config.magicdudecrypto = {
  minTrendDuration: 3,
  stochrsi: {
    optInTimePeriod: 14 * candleFactor,
    optInFastK_Period: 5 * candleFactor,
    optInFastD_Period: 5 * candleFactor,
    optInFastD_MAType: 0
  },

  macd: {
    optInFastPeriod: 6 * candleFactor,
    optInSlowPeriod: 12 * candleFactor,
    optInSignalPeriod: 5 * candleFactor
  },

  bbands: {
    optInTimePeriod: 20 * candleFactor,
    optInNbDevUp: 2,
    optInNbDevDn: 2,
    optInMAType: 0
  },
  requiredHistory: config.tradingAdvisor.historySize
}

Strat-init:

strat.init = function() {

  this.name = 'MD4E-Bot';
  this.input = 'candle';

  this.requiredHistory = this.settings.requiredHistory;

<SNIP>

  this.addTalibIndicator('stochrsi', 'stochrsi', this.settings.stochrsi);
  this.addTalibIndicator('macd', 'macd', this.settings.macd);
  this.addTalibIndicator('bbands', 'bbands', this.settings.bbands);
}

Strat update:

// What happens on every new candle?
strat.update = function(candle) {

  let macd     = this.talibIndicators.macd;
  let stochrsi = this.talibIndicators.stochrsi;
  let bbands   = this.talibIndicators.bbands;

  log.info('MACD=', macd);
  log.info('stochrsi=', stochrsi);
  log.info('bbands=', bbands);

<SNIP>
}
askmike commented 6 years ago

Very strange, for me it's working fine..

Here is the config snippet and the complete strat I tested: https://gist.github.com/askmike/bc60f3483c09163ded586e1484350b55

It outputs:

{ stochrsi: 
   { run: [Function],
     result: { outFastK: 6.355306266244574, outFastD: 1.2710612532489347 } },
  macd: 
   { run: [Function],
     result: 
      { outMACD: -0.15695440522040371,
        outMACDSignal: -0.013204418703371787,
        outMACDHist: -0.1437499865170319 } },
  bbands: 
   { run: [Function],
     result: 
      { outRealUpperBand: 1020.5776305104915,
        outRealMiddleBand: 1019.2174999999995,
        outRealLowerBand: 1017.8573694895075 } } }

/Users/pear/projects/gekko/strategies/magicdudecrypto.js:21
      throw 'a';

Can you check whether my gist works for you?

magicdude4eva commented 6 years ago

@askmike thanks I will check later - Bitfinex is giving me trouble and I don't get enough data. Just to confirm when I test tonight: Is there a possibility that perhaps Bitfinex is the issue (i.e. that the indicators don't read the details).

Can you also confirm the coin-pair you tested against? Also - how did you manage to test this so quick. I started the above config around 4:30pm, and now at 8:20pm it is only through loop 57 out of 100).

magicdude4eva commented 6 years ago

I can confirm that your Gist worked. Let me re-run my strategy tomorrow

2017-12-11 22:36:15 (DEBUG):    Processing 47 new trades. From 2017-12-11 20:29:49 UTC to 2017-12-11 20:30:06 UTC. (a few seconds)
{ stochrsi:
   { run: [Function],
     result: { outFastK: 39.858578010765854, outFastD: 76.88968905335278 } },
  macd:
   { run: [Function],
     result:
      { outMACD: -0.0033713326892392814,
        outMACDSignal: -0.007245580267472204,
        outMACDHist: 0.0038742475782329224 } },
  bbands:
   { run: [Function],
     result:
      { outRealUpperBand: 4.3855918543191805,
        outRealMiddleBand: 4.2969599999999994,
        outRealLowerBand: 4.208328145680818 } } }
magicdude4eva commented 6 years ago

Sorry for all the hassles. I was just too impatient. Having the strategy run for at least 2 hours will produce results.