Add automatic swap when low ETH

This commit is contained in:
2025-08-28 06:49:14 +07:00
parent 2e4c18ff63
commit 28fef53ff8
3 changed files with 104 additions and 14 deletions

View File

@@ -141,18 +141,6 @@ public class TradingBotBase : ITradingBot
{
if (!Config.IsForBacktest)
{
// Check broker balance before running
await ServiceScopeHelpers.WithScopedService<IExchangeService>(_scopeFactory, async exchangeService =>
{
var balance = await exchangeService.GetBalance(Account, false);
if (balance < Constants.GMX.Config.MinimumPositionAmount && Positions.All(p => p.Value.IsFinished()))
{
await LogWarning(
$"Balance on broker is below {Constants.GMX.Config.MinimumPositionAmount} USD (actual: {balance}). Stopping bot {Identifier}.");
return;
}
});
await LoadLastCandle();
}
@@ -1380,7 +1368,7 @@ public class TradingBotBase : ITradingBot
$"🔄 **Watch Mode Toggle**\nBot: `{Config.Name}`\nWatch Only: `{(Config.IsForWatchingOnly ? "ON" : "OFF")}`");
}
private async Task LogInformation(string message)
public async Task LogInformation(string message)
{
Logger.LogInformation(message);
@@ -1397,7 +1385,7 @@ public class TradingBotBase : ITradingBot
}
}
private async Task LogWarning(string message)
public async Task LogWarning(string message)
{
message = $"[{Config.Name}] {message}";
SentrySdk.CaptureException(new Exception(message));