rodrigo-brito / ninjabot

A fast trading bot platform for cryptocurrency in Go (Binance)
https://rodrigo-brito.github.io/ninjabot/
MIT License
1.36k stars 172 forks source link

Incorrect slice usage in Summary method #332

Closed ramilexe closed 1 week ago

ramilexe commented 2 weeks ago

In the bot.Summary() method, you allocate slice for returnsPercent with fixed length https://github.com/rodrigo-brito/ninjabot/blob/2325ed95bb6f0bac3d011443c4596b4329e9a695/ninjabot.go#L243

Then you use append method to add elements to the slice and it increases size of the slice and, probably, calculate histogram incorrectly: https://github.com/rodrigo-brito/ninjabot/blob/2325ed95bb6f0bac3d011443c4596b4329e9a695/ninjabot.go#L245

ramilexe commented 2 weeks ago

Before fix: image

After fix:

image

rodrigo-brito commented 1 week ago

You are right, this is a big mistake! Thank you for the report and pull request

rodrigo-brito commented 1 week ago

Closed by https://github.com/rodrigo-brito/ninjabot/pull/333