Drakkar-Software / OctoBot

Open source crypto trading bot
https://www.octobot.cloud
GNU General Public License v3.0
3.46k stars 787 forks source link

Proffit and Loss is incorrect and is double counting closed positions #2711

Open cbabione opened 3 months ago

cbabione commented 3 months ago

Describe your environment:

Describe the problem: Closed order fees are being double counted using the Grid Trading strategy. These fees were already assessed and accounted for in previous transactions. The result is that the PNL reports are inaccurate and show a lower profit (or a loss). The PNL report is inconsistent with what is actually being reported on the exchange (Coinbase in my case). The exchange is showing a correct profit summary from the same trading pairs. I have attached a screenshot highlighting the incorrect entries. Screenshot 2024-08-21 114554

Expected behavior Orders should only appear once in the PNL report and graph. Either a coupling of Buy-to-Open and Sell-to-Close, or Sell-to-Open and Buy-to-Close. Once a position is closed, it should not have any more reporting in the PNL report. Closed entries should not bridge to the next open position.

Steps to reproduce:

  1. Set up a Grid Trade strategy bot assigning a profitable spread and increment after fees
  2. Let bot run until you have cycled between two parts of the spread a few times
  3. See the double entries in the PNL report
GuillaumeDSM commented 3 months ago

Nice find, thank you @cbabione ! We will work on fixing this