askmike / gekko

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

Backtracker and Trade Avisor are having a discussion. #530

Closed decoye closed 7 years ago

decoye commented 7 years ago

Hello and merry christmas to everyone!

today i noticed that my trade advisor was acting up on me, and did not at all work in the way that i had setup in my strategy.

so i stopped gekko. and did a backtest.

the backtest says this:

2016-12-25 15:12:24 (INFO): 2016-12-25 06:08:00: Profit simulator got advice to long    960.780 EUR => 1.149 XBT
2016-12-25 15:12:24 (DEBUG):    calculated MACD properties for candle:
2016-12-25 15:12:24 (DEBUG):         short: 835.72442504
2016-12-25 15:12:24 (DEBUG):         long: 838.12443043
2016-12-25 15:12:24 (DEBUG):         macd: -2.40000539
2016-12-25 15:12:24 (DEBUG):         signal: -2.55715712
2016-12-25 15:12:24 (DEBUG):         macdiff: 0.15715173
2016-12-25 15:12:24 (DEBUG):    In uptrend since 2 candle(s)

While the trade advisor at the same time did nothing. Instead the trade advisor thought its a good idea to go long here:

2016-12-25 06:55:18 (DEBUG):    Processing 1 new trades. From 2016-12-25 05:55:07 UTC to 2016-12-25 05:55:07 UTC. (a few seconds)
2016-12-25 06:55:18 (DEBUG):    calculated MACD properties for candle:
2016-12-25 06:55:18 (DEBUG):         short: 837.13943612
2016-12-25 06:55:18 (DEBUG):         long: 839.78341011
2016-12-25 06:55:18 (DEBUG):         macd: -2.64397399
2016-12-25 06:55:18 (DEBUG):         signal: -2.75161485
2016-12-25 06:55:18 (DEBUG):         macdiff: 0.10764085
2016-12-25 06:55:18 (DEBUG):    In uptrend since 1 candle(s)
2016-12-25 06:55:18 (INFO): Trader Received advice to go long.

And at 6:08 when the backtest thought its a good idea to go long

the advisor does think this:

2016-12-25 06:08:17 (DEBUG):    Processing 8 new trades. From 2016-12-25 05:08:08 UTC to 2016-12-25 05:08:09 UTC. (a few seconds)
2016-12-25 06:08:17 (DEBUG):    calculated MACD properties for candle:
2016-12-25 06:08:17 (DEBUG):         short: 838.77397247
2016-12-25 06:08:17 (DEBUG):         long: 841.76146317
2016-12-25 06:08:17 (DEBUG):         macd: -2.98749069
2016-12-25 06:08:17 (DEBUG):         signal: -2.84175462
2016-12-25 06:08:17 (DEBUG):         macdiff: -0.14573607
2016-12-25 06:08:17 (DEBUG):    In downtrend since 13 candle(s)
2016-12-25 06:08:17 (INFO): (PROFIT REPORT) original simulated balance:  962.43900 EUR
2016-12-25 06:08:17 (INFO): (PROFIT REPORT) current simulated balance:   955.42600 EUR
2016-12-25 06:08:17 (INFO): (PROFIT REPORT) simulated profit:        -7.01300 EUR (-0.72867%)

Im not too familiar with gekko yet, but this seems to be wrong to me, isnt it? So whats the cause, is it me, or Gekko?

Thanks and all the best.

Decoye.

askmike commented 7 years ago

Hey Decoye,

Merry christmas to you too!

A few tiny things:

Gekko aggregates data into candles, if your candleSize is 60 these are hourly (60 minute candles). However they do not go from 10:00 to 11:00, they are calculated based no the minute you start Gekko, if you start Gekko now (11:11) it would calculate hourly candles that start at the 11th minute of the hour. Your backtests can differ a little bit because of these tiny offsets (different candles -> different MACD results -> different advices).

Did you keep the advisor running? And if so, did it quickly change it's advice to long?


Finally, could you give the develop branch a go? A number of fixes/changes have gone into that backtest (including some strange race conditions).

decoye commented 7 years ago

Hey Mike,

im currently running the candlesize in 20. History size is still 22 as default as i am not sure what it actually really is the value for.

I kept it running for the last night to overview what the tradeadvisor is doing.

This night as well it happend, the trade advisor was giving an advice to go short almost 40 minute later than the backtester advised.

Even the backtester claims that with my setting he would have made 5 trades last night while the trade advisor was giving 2 advises to make trades.

It feels like it is not considering my strategy at all that i have setup for it.

I did try 2 min ago to give develop branch a go, but the develop throws me an error that module.js is missing.

askmike commented 7 years ago

Could you double check that you are running the exact same configuration (candleSize, histerySize, trading method parameters) in both scenarios?

but the develop throws me an error that module.js is missing.

Would you mind posting this exact error?

On Mon, Dec 26, 2016 at 8:27 AM, decoye notifications@github.com wrote:

Hey Mike,

im currently running the candlesize in 20. History size is still 22 as default as i am not sure what it actually really is the value for.

I kept it running for the last night to overview what the tradeadvisor is doing.

This night as well it happend, the trade advisor was giving an advice to go short almost 40 minute later than the backtester advised.

Even the backtester claims that with my setting he would have made 5 trades last night while the trade advisor was giving 2 advises to make trades.

It feels like it is not considering my strategy at all that i have setup for it.

I did try 2 min ago to give develop branch a go, but the develop throws me an error that module.js is missing.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/askmike/gekko/issues/530#issuecomment-269183084, or mute the thread https://github.com/notifications/unsubscribe-auth/AA7MD9ew3rfaG3-LvgjtxROHnyZeEsQ9ks5rL3pXgaJpZM4LVanz .

-- PGP key at keybase.io/mikevanrossum https://keybase.io/mikevanrossum/key.asc

decoye commented 7 years ago

The error that i get:

Error: Cannot find module 'moment' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object. (/Users/decoye/gekko-develop/core/util.js:1:76) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3)

askmike commented 7 years ago

and if you run npm install?

On Mon, Dec 26, 2016 at 12:19 PM, decoye notifications@github.com wrote:

The error that i get:

Error: Cannot find module 'moment' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object. (/Users/decoye/gekko-develop/core/util.js:1:76) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/askmike/gekko/issues/530#issuecomment-269206414, or mute the thread https://github.com/notifications/unsubscribe-auth/AA7MD_HEFg0rc4fktC4Jlirvh8LoF3kjks5rL7DegaJpZM4LVanz .

-- PGP key at keybase.io/mikevanrossum https://keybase.io/mikevanrossum/key.asc

decoye commented 7 years ago

npm install worked.

i let you know my updates. i have put my config file into the develope branch now. lets see how that turns out.

askmike commented 7 years ago

Great! Let me know your results :)