Fix bot launch errors

This commit is contained in:
2024-06-26 19:14:32 +07:00
parent c25752c670
commit fb976d231a
13 changed files with 54 additions and 50 deletions

View File

@@ -99,7 +99,15 @@ public class TradingBot : Bot, ITradingBot
LoadScenario();
await PreloadCandles();
await CancelAllOrders();
await MessengerService.SendMessage($"Hi everyone, I'm going to run {Name}. \nI will send a message here everytime a signal is triggered by the {string.Join(",", Strategies.Select(s => s.Name))} strategies.");
try
{
await MessengerService.SendMessage($"Hi everyone, I'm going to run {Name}. \nI will send a message here everytime a signal is triggered by the {string.Join(",", Strategies.Select(s => s.Name))} strategies.");
}
catch (Exception ex)
{
Logger.LogError(ex, ex.Message);
}
await InitWorker(Run);
}
@@ -553,7 +561,7 @@ public class TradingBot : Bot, ITradingBot
private async Task CancelAllOrders()
{
if (!IsForBacktest)
if (!IsForBacktest && !IsForWatchingOnly)
{
try
{

View File

@@ -2,21 +2,16 @@
using MediatR;
using static Managing.Common.Enums;
using Managing.Application.Abstractions;
using Managing.Application.ManageBot.Commands;
using Managing.Domain.MoneyManagements;
namespace Managing.Application.ManageBot
{
public class BackupBotCommandHandler : IRequestHandler<BackupBotCommand, bool>
{
private readonly IBotFactory _botFactory;
private readonly ITaskCache _taskCache;
private readonly IMoneyManagementService _moneyManagementService;
private readonly IBotService _botService;
public BackupBotCommandHandler(IBotFactory botFactory, ITaskCache taskCache, IBotService botService)
public BackupBotCommandHandler(ITaskCache taskCache, IBotService botService)
{
_botFactory = botFactory;
_taskCache = taskCache;
_botService = botService;
}

View File

@@ -1,6 +1,4 @@
using Managing.Application.Abstractions;
using Newtonsoft.Json;
using System.IO;
namespace Managing.Application.ManageBot
{

View File

@@ -206,7 +206,7 @@ public class TradingService : ITradingService
return _cacheService.GetOrSave($"Fee-{account.Exchange}", () =>
{
return _tradingRepository.GetFee(TradingExchanges.Evm).Cost;
return _tradingRepository.GetFee(TradingExchanges.Evm)?.Cost ?? 0m;
}, TimeSpan.FromHours(2));
}