fix
This commit is contained in:
@@ -158,6 +158,46 @@ namespace Managing.Application.ManageBot
|
||||
return new SimpleBot(botName, _tradingBotLogger, workflow, this);
|
||||
}
|
||||
|
||||
public async Task<string> StopBot(string botName)
|
||||
{
|
||||
if (_botTasks.TryGetValue(botName, out var botWrapper))
|
||||
{
|
||||
if (botWrapper.BotInstance is IBot bot)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
bot.Stop()); // Assuming Stop is an asynchronous process wrapped in Task.Run for synchronous methods
|
||||
return bot.GetStatus();
|
||||
}
|
||||
}
|
||||
|
||||
return Enums.BotStatus.Down.ToString();
|
||||
}
|
||||
|
||||
public Task<bool> DeleteBot(string botName)
|
||||
{
|
||||
if (_botTasks.TryRemove(botName, out _))
|
||||
{
|
||||
_botRepository.DeleteBotBackup(botName);
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
|
||||
public Task<string> RestartBot(string botName)
|
||||
{
|
||||
if (_botTasks.TryGetValue(botName, out var botWrapper))
|
||||
{
|
||||
if (botWrapper.BotInstance is IBot bot)
|
||||
{
|
||||
bot.Restart();
|
||||
return Task.FromResult(bot.GetStatus());
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult(Enums.BotStatus.Down.ToString());
|
||||
}
|
||||
|
||||
public ITradingBot CreateScalpingBot(string accountName, MoneyManagement moneyManagement, string name,
|
||||
Enums.Ticker ticker, string scenario, Enums.Timeframe interval, bool isForWatchingOnly)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user