DeviaVir / zenbot

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

Genetic back tester fails to fetch test results because of ansi codes #578

Closed JensvdHeydt closed 7 years ago

JensvdHeydt commented 7 years ago

There's a problem regarding #577 and the output containing ansi format codes (for colors).

The processOutput function constantly fails with the error message "Bad output detected" because the analysed simulation results contain ansi format codes and the corresponding regex functions to filter the results don't support these.

It's easily fixed with the npm module strip-ansi (https://www.npmjs.com/package/strip-ansi) at line 101 of of darwin.js:

let strippedOutput = StripAnsi(output); let output2 = strippedOutput.substr(strippedOutput.length - 3500);

and

let StripAnsi = require('strip-ansi');

in the head of the file.

An even better solution would be to introduce a zenbot parameter called "--no-ansi" that would prevent zenbot from even using ansi color codes in it's results in the first place.

Please let me know if you're interested in a small pull request regarding solution 1 or 2.

Cheers, Jens

JensvdHeydt commented 7 years ago

just saw that auto_backtester has the same problem

DeviaVir commented 7 years ago

Hi @JensvdHeydt, excellent finding and thanks for doing the leg work on finding a solution for it.

I think your suggestion for adding --no-ansi (or perhaps --no-colors) would be the best, and would gladly merge a PR.

JensvdHeydt commented 7 years ago

Hi @DeviaVir,

I'll submit a PR shortly. I'm glad I could help