DeviaVir / zenbot

Zenbot is a command-line cryptocurrency trading bot using Node.js and MongoDB.
MIT License
8.22k stars 2.04k forks source link

Strat weird behaviour #1407

Open fdk0 opened 6 years ago

fdk0 commented 6 years ago

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.

defkev commented 6 years ago

I am not seeing anything.

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

fdk0 commented 6 years ago

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

defkev commented 6 years ago

Odd

Does your system time change or anything?

fdk0 commented 6 years ago

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 commented 6 years ago

This is with --debug

screen shot 2018-02-22 at 21 32 44

defkev commented 6 years ago

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.

fdk0 commented 6 years ago

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

fdk0 commented 6 years ago

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.

jasdjensen commented 6 years ago

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)

defkev commented 6 years ago

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 commented 6 years ago

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.

fdk0 commented 6 years ago

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

fdk0 commented 6 years ago

@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.

primoz990 commented 3 years ago

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.