Trade closed on ByBit with a loss while it closed on Gainium with profits

Bug info: I saw that my bot closed a trade with profit. When I dived deeper into it I saw that the trade has been closed on ByBit with a loss while it closed on Gainium with profits.

On my account - at 2025-03-07 01:00:49 my trade on ONDOUSDT closed with a loss of -2.4395
On my Gainium platform at the exact same time - my trade closed with a profit of $11.232

Deal ID: 67c750dbfea2b224e102da5e

  • Bot URL → Gainium app
  • [Optional] Steps to reproduce →
  • Expected result →

We have received your bug report regarding the discrepancy in trade closures between ByBit and Gainium for Deal ID 67c750dbfea2b224e102da5e on bot URL Gainium app. We will investigate this issue and provide an update shortly.

Some more information:

the average price on Gainium is 1.0865
the average price on Bybit is 1.0598

Did ByBit miss an order or?
The close price was 1.0643 and the quantity on ByBit is the same as on Gainium.

Futures deals calculate avg price based on its own orders, if the position is used in othe bots/deals or exists before deal started the value on the exchange side and bot side will be different.

For the specific deal:
It has 7 filled orders, 516 ONDO, 560.6335 USDT. Making avg entry price 1.08649903 ONDO/USDT
And TP order 516 ONDO @ 1.0643 ONDO/USDT.

Profit based on orders inside deal and its calculations are correct approx. 11 USDT

That’s what I thought also. I’ve also opened a case with ByBit to investigate this.

Both ByBit and Gainium closed the same size on the same time so I think ByBit is wrong on their end.

I will update when I get more indormation from them.

1 Like

This is the update from my ByBit case:

1. Unrealized Profit and Loss description

Unrealized Profit/loss seen in the Position tab, does not consider any trading fee/ funding fee that had been paid for the position. Once the position has been closed, the Closed P&L records will then consolidate and calculate all relevant Trading fees and Funding fees (If any) incurred since the start of the position till it has been closed and this value will be reflected on the closed PnL record. This may be the reason why the closed Pnl value may be different.

  • Unrealized PnL (found in the position tab) is an estimation of how much PnL the position will make when the position is closed.

These fees are commonly the reason why the value of unrealized PnL is different compared to the realized PnL.

USDT contract Unrealized P&L formula
Long Position = Contract Qty x (Last Traded Price - Entry Price)
Short Position = Contract Qty x (Entry Price - Last Traded Price)

CTR04(01)

2. Record of Fees paid/received for the trade

You may refer to the trade history and check the “Fees Paid” Column for more details. The following data is the data extracted for the position that you have inquired about. You may use the trade ID to locate the transaction on your Trade History page.

P&L pic

3. Funding Fees

A position can remain open for as long as the user wishes. However, please take note of the funding fees involved while holding a position on Bybit. The Funding Fee is calculated by your position value based on the Mark price at the time of funding x the funding rate and it is applied every 0800, 1600, and 2400 UTC.​ You are able to locate them in Trade History as per the below screenshot. (Please also take note that a Negative fee = Received into your Bybit wallet and a Positive fee = paid out of your Bybit wallet.)

CTR04(03)

4. Closed P&L
When traders finally closed their position, the P&L becomes realized and is recorded inside the Closed P&L tab within the Assets page. Unlike unrealized P&L, there are some major differences in the calculation. Below summarizes the differences between the unrealized P&L and closed P&L.

CTR04(04)

​The formula for calculating Closed P&L is as follows:

Closed P&L = Position P&L (1) - Fee to open(2) - Fee to close(2) - Sum of all funding fees paid/received (3)

We hope that the above information will get you a better understanding of how to calculate the position Profit and loss which can be found in the Closed P&L tab.

Reported incident/issue: Inquiry about the breakdown of Profit and Loss for the position:

Closed P&L breakdown details:
Contracts Closed: 516
Entry Price: 1.05980712
Exit Price: 1.0643
Total Fee to Open: 0.14301487
Total Fee to Close: 0.10983576
Total Funding Fee: -0.13164197
Position Profit/Loss (without fees): 516 * (1.05980712 - 1.0643) = -2.31832608
Closed Profit/Loss: (with fees): -2.31832608 - 0.14301487 - 0.10983576 - (-0.13164197) = -2.43953338 (Loss)

Investigation result:
The Close Profit and Loss value has been calculated correctly with no issue. We would like to assure you that the system was fully functional at its optimal condition at the time of occurrence.

Perhaps the differene you see is because of the funding fee. Currently, we are not taking into account funding fees paid to calculate the average price. We have some talks about it but I guess most people trade spot and there wasn’t much push for it. I think you can make a feature request: Feature Requests - Gainium Community

It doesn’t really matter for me. It’s not that big of a deal; I’ll leave it as it is for now.
Was sharing the info from ByBit for information purpose.

1 Like

The problem with entry price. Was the leverage changed during bot running? Bot set up leverage on time, when bot started, if you or other bot changed leverge the calculation won’t be accurate.

Leverage was not changed. It completed +60 deals or so with the same settings before.