Fix config update + remove messages + Summary fix for not open position
This commit is contained in:
@@ -10,6 +10,7 @@ using Managing.Core;
|
||||
using Managing.Domain.Accounts;
|
||||
using Managing.Domain.Backtests;
|
||||
using Managing.Domain.Bots;
|
||||
using Managing.Domain.Indicators;
|
||||
using Managing.Domain.MoneyManagements;
|
||||
using Managing.Domain.Scenarios;
|
||||
using Managing.Domain.Strategies;
|
||||
@@ -479,13 +480,13 @@ public class BotController : BaseController
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manually opens a position for a specified bot with the given parameters.
|
||||
/// Manually create a signal for a specified bot with the given parameters.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing position parameters.</param>
|
||||
/// <returns>A response indicating the result of the operation.</returns>
|
||||
[HttpPost]
|
||||
[Route("OpenPosition")]
|
||||
public async Task<ActionResult<Position>> OpenPositionManually([FromBody] OpenPositionManuallyRequest request)
|
||||
[Route("CreateManualSignal")]
|
||||
public async Task<ActionResult<LightSignal>> CreateManualSignalAsync([FromBody] CreateManualSignalRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -507,16 +508,15 @@ public class BotController : BaseController
|
||||
return BadRequest($"Bot with identifier {request.Identifier} is not running");
|
||||
}
|
||||
|
||||
var position = await _botService.OpenPositionManuallyAsync(request.Identifier, request.Direction);
|
||||
var signal = await _botService.CreateManualSignalAsync(request.Identifier, request.Direction);
|
||||
|
||||
await NotifyBotSubscriberAsync();
|
||||
return Ok(position);
|
||||
return Ok(signal);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error opening position manually");
|
||||
_logger.LogError(ex, "Error creating signal manually");
|
||||
return StatusCode(500,
|
||||
$"Error opening position: {ex.Message}, {ex.InnerException?.Message} or {ex.StackTrace}");
|
||||
$"Error creating signal: {ex.Message}, {ex.InnerException?.Message} or {ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -664,17 +664,17 @@ public class BotController : BaseController
|
||||
Leverage = fullMoneyManagement.Leverage
|
||||
};
|
||||
}
|
||||
else if (request.MoneyManagement != null)
|
||||
else if (request.Config.MoneyManagement != null)
|
||||
{
|
||||
// Use provided money management object
|
||||
moneyManagement = request.MoneyManagement;
|
||||
// Format percentage values if using custom money management
|
||||
moneyManagement.FormatPercentage();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use existing bot's money management if no new one is provided
|
||||
moneyManagement = config.MoneyManagement;
|
||||
moneyManagement = new LightMoneyManagement
|
||||
{
|
||||
Name = request.Config.Name,
|
||||
Timeframe = request.Config.Timeframe,
|
||||
StopLoss = request.Config.MoneyManagement.StopLoss,
|
||||
TakeProfit = request.Config.MoneyManagement.TakeProfit,
|
||||
Leverage = request.Config.MoneyManagement.Leverage
|
||||
};
|
||||
}
|
||||
|
||||
// Validate CloseEarlyWhenProfitable requires MaxPositionTimeHours
|
||||
@@ -921,7 +921,7 @@ public class BotController : BaseController
|
||||
/// <summary>
|
||||
/// Request model for opening a position manually
|
||||
/// </summary>
|
||||
public class OpenPositionManuallyRequest
|
||||
public class CreateManualSignalRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// The identifier of the bot
|
||||
|
||||
Reference in New Issue
Block a user