zenbot icon indicating copy to clipboard operation
zenbot copied to clipboard

Strat weird behaviour

Open fdk0 opened this issue 7 years ago • 14 comments

Hi guys,

I would like to know if someone has an idea of why, when I use neural strat it does this weird thing in the time line. img_0185 trim When refresh the time goes back one day.. The picture is not very clear because of the size limit for attached files.. I have tried other strat but it seems that it does it only with neural. The command is ./zenbot.sh trade --manual --strategy neural --period 1m gdax.ETH-EUR. Hope someone can help since I am stuck to a 15 days old version and it would be nice to be able to pull to the latest and still use the neural strat. Thanks.

fdk0 avatar Feb 22 '18 19:02 fdk0

I am not seeing anything.

Create a higher res webm and upload it to gfycat.com or something.

defkev avatar Feb 22 '18 19:02 defkev

Sorry about that, this is a screenshot.. As you can see the last line is a day back screen shot 2018-02-22 at 21 03 26

fdk0 avatar Feb 22 '18 20:02 fdk0

Odd

Does your system time change or anything?

defkev avatar Feb 22 '18 20:02 defkev

No, it is synced and actually I tried in 2 different machine and it does the same.. I am using an old version in live mode, it is on 24/7 and it works nice with same strat. I don't know exactly in which commit this started..

fdk0 avatar Feb 22 '18 20:02 fdk0

This is with --debug

screen shot 2018-02-22 at 21 32 44

fdk0 avatar Feb 22 '18 20:02 fdk0

So the timestamp is actually jumping back and forth?

"Could" be a problem with the trade time reported by the exchange or the strategy. I suspect the former.

defkev avatar Feb 22 '18 20:02 defkev

I tried the same strat on Binance, Bittrex and Gdax and it does the same..

fdk0 avatar Feb 22 '18 21:02 fdk0

Ok, maybe some of you coders can tell me why, and maybe fix it. I narrowed down to this commits that is when it start to do this bug. It is between this #1324 and this one #1340. I am not sure which one because #1324 don't run so the next one is #1324 and after this it start to do what I described earlier.

What I did is checkout backwards until it started behave normally again.

Also I have tried this fork https://github.com/krystophv/zenbot.git -b eventemitter from which the commits came and also does it..

Maybe someone can understand what happened. Thanks.

fdk0 avatar Feb 23 '18 13:02 fdk0

Also to be noted with neural, it does some other odd things:

  1. Sims produce 0 stats.
  2. When starting neural trade it produces a webpage and port.. then does it's historical print out, then when it catches up to live, it produces another webpage and port.. then starts live trading.
  3. When completion of sim or live trading, it outputs to the screen several lines after stopping, so you get the prompt, then it gets buried in residual data.

image (showing remaining data output after the sim summary and a buried prompt)

image (showing difference in funds on output versus simulation result funds)

jasdjensen avatar Feb 23 '18 18:02 jasdjensen

There indeed seems to be a problem with neutral strat initiating trade twice causing the duplicate output and ultimately leading to the EADDRINUSE exception...

defkev avatar Feb 23 '18 19:02 defkev

Ok, looks like neutral strat will fork the main process (n times based on threads) causing the observed behavior, including the timestamp jumping back and forth which basically is nothing else than the output of the two running instances.

The EADDRINUSE can be overcome by simply only initializing the output for the master process. For everything else, including how this was/is supposed to work i'll have to go back to the current stable.

IMHO it doesn't make sense to output anything but the main process.

defkev avatar Feb 23 '18 20:02 defkev

Ok, I can't code so no help there, but I may do some testing if needed.

fdk0 avatar Feb 24 '18 10:02 fdk0

@defkev do you think you could put me in the right direction on what file should I edit to apply the solution that you propose for the timestamp jumping.. just to be able to live test the new neural strat so I may provide also some feedback on how this new strat works.. thank anyway.

fdk0 avatar Mar 13 '18 11:03 fdk0

I managed to find a workaround for this problem. Set the api port to 0 in conf.js, so the port is getting randomly chosen for each instance:

c.output.api.port = process.env.ZENBOT_API_PORT || 0

I gues its not optimal but works for me. The better solution would be starting output for only the main process like @defkev said above.

primoz990 avatar Dec 19 '20 06:12 primoz990