xFFFFF / Gekko-Strategies

Strategies to Gekko trading bot with backtests results and some useful tools.
1.33k stars 402 forks source link

uncaughtException` { TypeError: ema.result.toFixed is not a function #16

Open gbittoun opened 5 years ago

gbittoun commented 5 years ago

Hello, I have trouble executing backtest and livetest (thankfully leads to the same errors :) ):

uncaughtException` { TypeError: ema.result.toFixed is not a function
    at Base.method.log (/home/guite/Documents/gekko/strategies/EMA_OR_PRICE_DIV.js:40:38)
    at Base.bound [as log] (/home/guite/Documents/gekko/node_modules/lodash/dist/lodash.js:729:21)
    at Base.propogateTick (/home/guite/Documents/gekko/plugins/tradingAdvisor/baseTradingMethod.js:166:10)
    at Base.bound [as propogateTick] (/home/guite/Documents/gekko/node_modules/lodash/dist/lodash.js:729:21)
    at Base.calculateSyncIndicators (/home/guite/Documents/gekko/plugins/tradingAdvisor/baseTradingMethod.js:129:8)
    at Base.bound [as calculateSyncIndicators] (/home/guite/Documents/gekko/node_modules/lodash/dist/lodash.js:729:21)
    at afterAsync (/home/guite/Documents/gekko/plugins/tradingAdvisor/baseTradingMethod.js:94:10)
    at Base.tick (/home/guite/Documents/gekko/plugins/tradingAdvisor/baseTradingMethod.js:108:5)
    at Base.bound [as tick] (/home/guite/Documents/gekko/node_modules/lodash/dist/lodash.js:729:21)
    at Actor.emitStratCandle (/home/guite/Documents/gekko/plugins/tradingAdvisor/tradingAdvisor.js:103:17)
    at Actor.bound [as emitStratCandle] (/home/guite/Documents/gekko/node_modules/lodash/dist/lodash.js:729:21)
    at CandleBatcher.batcher.on._candle (/home/guite/Documents/gekko/plugins/tradingAdvisor/tradingAdvisor.js:82:12)
    at emitOne (events.js:116:13)
    at CandleBatcher.emit (events.js:211:7)
    at CandleBatcher.bound [as emit] (/home/guite/Documents/gekko/node_modules/lodash/dist/lodash.js:729:21)
    at _.each.candle (/home/guite/Documents/gekko/core/candleBatcher.js:55:20)
    at Function.forEach (/home/guite/Documents/gekko/node_modules/lodash/dist/lodash.js:3298:15)
    at CandleBatcher.flush (/home/guite/Documents/gekko/core/candleBatcher.js:53:5)
    at CandleBatcher.bound [as flush] (/home/guite/Documents/gekko/node_modules/lodash/dist/lodash.js:729:21)
    at Actor.processCandle (/home/guite/Documents/gekko/plugins/tradingAdvisor/tradingAdvisor.js:97:16)
    at Actor.bound [as processCandle] (/home/guite/Documents/gekko/node_modules/lodash/dist/lodash.js:729:21)
    at Gekko.<anonymous> (/home/guite/Documents/gekko/core/gekkoStream.js:59:9)
--> in Database#all('\n    SELECT * from candles_XBT_ETH\n    WHERE start <= 1561942485 AND start >= 1561942201\n    ORDER BY start ASC\n  ', [Function])
    at Reader.get (/home/guite/Documents/gekko/plugins/sqlite/reader.js:98:11)
    at Reader.bound [as get] (/home/guite/Documents/gekko/node_modules/lodash/dist/lodash.js:729:21)
    at Market.get (/home/guite/Documents/gekko/core/markets/leech.js:62:15)
    at Timeout.bound [as _onTimeout] (/home/guite/Documents/gekko/node_modules/lodash/dist/lodash.js:729:21)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5) __augmented: true }
RECEIVED ERROR IN GEKKO INSTANCE 2019-06-30-22-56-tradebot-2896762559368744
{ __augmented: true }
2019-07-01T03:21:39.328Z 'Service:Unavailable'

printed variable ema.result with a console.error(ema.result) and got: Indicator { weight: 50, result: false, age: 0 }

Might be a kraken configuration issue (I’m using kraken) but other “builtin” gekko strategies are working fine with my current configuration.

Thanks,

gbittoun commented 5 years ago

Just wanted to add two things: 1) the update function are all doing nothing… I don’t get why, I might be missing something in the doc 2) I have error when executing install.sh script, spaces in indicators/strategies paths are causing errors

I keep digging :)

femanzo commented 5 years ago

If ema.result is a boolean type, ema.result can't execute the ema.result.toFixed function, it would only work for number type. A quick fix is to force number type when you need to call it, replacing it like this: ema.result -> Number(ema.result)

now if ema.result === false then Number(ema.result) === 0 and Number(ema.result).toFixed can be called.

I'm not sure this would break the logic of the plugin, I think it doesn't.

gbittoun commented 5 years ago

Thanks dude :) In fact, it was more a problem of install script not working, spaces in paths caused errors in the script. I changed the script and re-did npm install --only=production in gekko repository and it fixed everything… I wonder if I should ask for a merge request for my change, I think my change could fix linux/ubuntu install (and maybe add an install procedure in README in the MR).

Cheers,