Partial closing commission and profit calculation bug

Post Reply
Khan
Posts: 137
Joined: Wed Feb 22, 2023 10:21 am

Partial closing commission and profit calculation bug

Post by Khan »

Hello,

I noticed that sometimes (maybe always?) when I close a part of a position manually, profit and the remaining commission numbers are wrong. If I close, let's say, 50% of a position, commission should drop to half, but it doesn't. Last time I saw this happen, the commission was more than it should be. However when I totally closed out the position, commission was 10$ less and the profit was 10$ more under Account History.

Sadly I don't have any screenshots or backtests of this bug because I forgot to do that. If I happen to notice it again, I'll make sure to post it.
Khan
Posts: 137
Joined: Wed Feb 22, 2023 10:21 am

Re: Partial closing commission and profit calculation bug

Post by Khan »

Okay, attached is the backtest with the bug.

I have a small position open and commission was being shown as -10.08. I closed half of it and the commission didn't change, but when you look at Account History, the last trade listed there says its commission was -5.04 as it should. However, the position under Open Positions still shows -10.08.

In the backtest, half of the remaining position is still open.

Sadly, I wasn't looking at the current profit of the open position after closing half, but it might be buggy as well.
Attachments
EURUSD_2_again.zip
(223.87 KiB) Downloaded 71 times
Khan
Posts: 137
Joined: Wed Feb 22, 2023 10:21 am

Re: Partial closing commission and profit calculation bug

Post by Khan »

Here's possibly another bug regarding commissions.
commission_bug_2.png
commission_bug_2.png (2.17 KiB) Viewed 949 times
Here, the last 3 entries belong to the same position. First I closed 50%, then another 50% so only 25% of the original position remains. Then the last 25% part hit my SL and got closed. However, as seen in the screenshot, the last part has a huge commission, 10 times as much as it should be in fact.

Also second position shows -6.72, but it should be -13.51/2 = 6.76 (rounded up from 6.755). Maybe there are rounding errors which are compounding.
Attachments
EURUSD_2_again.zip
(189.89 KiB) Downloaded 69 times
Khan
Posts: 137
Joined: Wed Feb 22, 2023 10:21 am

Re: Partial closing commission and profit calculation bug

Post by Khan »

I just checked and saw that current profit of a position that is closed by 50% doesn't halve the profit in the terminal; the terminal shows a profit much greater than 50%. This might be because the original size of the position in lots was odd, like 0.23 so you can't divide it by half, but the difference looked more than what a 0.01 lot size would have.
Khan
Posts: 137
Joined: Wed Feb 22, 2023 10:21 am

Re: Partial closing commission and profit calculation bug

Post by Khan »

Here is the backtest that has the commission and profit calculation bug(s).
commissions_bug_1.png
commissions_bug_1.png (3 KiB) Viewed 942 times
Here I have a position open and it shows -17.29 for commission, 4 points and 108.67 profit. Net position is 91.28.
commissions_bug_2.jpg
commissions_bug_2.jpg (9.3 KiB) Viewed 942 times
This is when the position is closed fully in one go. Both commission and profit numbers are different, however the net position is 91.40.

Net totals are very close but they should be equal.

Overall conclusion of my previous analysis with these findings:
Commission display has at least one bug that makes it display wrong values. It sometimes shows more, sometimes shows less than it should.
Profit also has bugs, which is related to commissions.

In the backtest, the position is still open so you can debug the bug(s) properly.
Attachments
EURUSD_2_again.zip
(234.94 KiB) Downloaded 68 times
NakedMarkets
Posts: 248
Joined: Tue Feb 22, 2022 11:06 am

Re: Partial closing commission and profit calculation bug

Post by NakedMarkets »

It has been fixed in the latest release.
The commissions were not properly calculated when a partial order was closed and when commissions were set in the symbol properties.
Thanks Khan for your report, we remind you that commissions by default (when set) are added at the opening and the closing of the order
Khan
Posts: 137
Joined: Wed Feb 22, 2023 10:21 am

Re: Partial closing commission and profit calculation bug

Post by Khan »

That is correct. The issues seem to be fixed with this release.

Well done!
Post Reply