Fix position gas fee

This commit is contained in:
2025-09-26 17:16:41 +07:00
parent 8b0970fc7b
commit 6d91c75ec2
2 changed files with 20 additions and 11 deletions

View File

@@ -427,11 +427,12 @@ public class TradingBotBase : ITradingBot
} }
else else
{ {
if (!internalPosition.Status.Equals(PositionStatus.New)) // No position on the broker, the position have been closed by the exchange
if (internalPosition.Status.Equals(PositionStatus.Filled))
{ {
internalPosition.Status = PositionStatus.Filled; internalPosition.Status = PositionStatus.Finished;
// Update Open trade status when position becomes Filled // Update Open trade status when position becomes Finished
if (internalPosition.Open != null) if (internalPosition.Open != null)
{ {
internalPosition.Open.SetStatus(TradeStatus.Filled); internalPosition.Open.SetStatus(TradeStatus.Filled);

View File

@@ -46,6 +46,8 @@ namespace Managing.Application.Trading.Handlers
// Gas fee check for EVM exchanges // Gas fee check for EVM exchanges
decimal gasFeeUsd = 0; decimal gasFeeUsd = 0;
if (!request.IsForPaperTrading)
{
if (account.Exchange == TradingExchanges.Evm || account.Exchange == TradingExchanges.GmxV2) if (account.Exchange == TradingExchanges.Evm || account.Exchange == TradingExchanges.GmxV2)
{ {
gasFeeUsd = await exchangeService.GetFee(account); gasFeeUsd = await exchangeService.GetFee(account);
@@ -56,6 +58,12 @@ namespace Managing.Application.Trading.Handlers
InsufficientFundsType.InsufficientEth); InsufficientFundsType.InsufficientEth);
} }
} }
}
else
{
gasFeeUsd = Constants.GMX.Config.GasFeePerTransaction;
}
var price = request.IsForPaperTrading && request.Price.HasValue var price = request.IsForPaperTrading && request.Price.HasValue
? request.Price.Value ? request.Price.Value