Push merge conflict

This commit is contained in:
2025-07-04 11:02:53 +07:00
parent 88f195c0ca
commit 59c5de7df7
27 changed files with 1133 additions and 1118 deletions

View File

@@ -1,17 +1,14 @@
using MediatR;
using static Managing.Common.Enums;
namespace Managing.Application.ManageBot.Commands
{
public class StopBotCommand : IRequest<string>
{
public string Name { get; }
public BotType BotType { get; }
public string Identifier { get; }
public StopBotCommand(BotType botType, string name)
public StopBotCommand(string identifier)
{
BotType = botType;
Name = name;
Identifier = identifier;
}
}
}
}

View File

@@ -70,37 +70,25 @@ namespace Managing.Application.ManageBot
Timeframe = request.Config.Timeframe,
IsForWatchingOnly = request.Config.IsForWatchingOnly,
BotTradingBalance = request.Config.BotTradingBalance,
BotType = request.Config.BotType,
IsForBacktest = request.Config.IsForBacktest,
CooldownPeriod =
request.Config.CooldownPeriod > 0 ? request.Config.CooldownPeriod : 1, // Default to 1 if not set
MaxLossStreak = request.Config.MaxLossStreak,
MaxPositionTimeHours = request.Config.MaxPositionTimeHours, // Properly handle nullable value
FlipOnlyWhenInProfit = request.Config.FlipOnlyWhenInProfit,
FlipPosition = request.Config.BotType == BotType.FlippingBot, // Set FlipPosition based on BotType
FlipPosition = request.Config.FlipPosition, // Set FlipPosition
Name = request.Config.Name ?? request.Name,
CloseEarlyWhenProfitable = request.Config.CloseEarlyWhenProfitable
};
switch (configToUse.BotType)
{
case BotType.SimpleBot:
var bot = _botFactory.CreateSimpleBot(request.Name, null);
bot.User = request.User;
_botService.AddSimpleBotToCache(bot);
return bot.GetStatus();
var tradingBot = _botFactory.CreateTradingBot(configToUse);
tradingBot.User = request.User;
case BotType.ScalpingBot:
case BotType.FlippingBot:
var tradingBot = _botFactory.CreateTradingBot(configToUse);
tradingBot.User = request.User;
// Log the configuration being used
await LogBotConfigurationAsync(tradingBot, $"{configToUse.Name} created");
// Log the configuration being used
await LogBotConfigurationAsync(tradingBot, $"{configToUse.BotType} created");
_botService.AddTradingBotToCache(tradingBot);
return tradingBot.GetStatus();
}
_botService.AddTradingBotToCache(tradingBot);
return tradingBot.GetStatus();
return botStatus.ToString();
}
@@ -116,7 +104,6 @@ namespace Managing.Application.ManageBot
{
var config = bot.GetConfiguration();
var logMessage = $"{context} - Bot: {config.Name}, " +
$"Type: {config.BotType}, " +
$"Account: {config.AccountName}, " +
$"Ticker: {config.Ticker}, " +
$"Balance: {config.BotTradingBalance}, " +

View File

@@ -15,7 +15,7 @@ namespace Managing.Application.ManageBot
public Task<string> Handle(StopBotCommand request, CancellationToken cancellationToken)
{
return _botService.StopBot(request.Name);
return _botService.StopBot(request.Identifier);
}
}
}