Fix bot + disable position fetcher

This commit is contained in:
2025-04-26 01:30:27 +07:00
parent 6579bbc06f
commit 5eb401dc80
3 changed files with 46 additions and 21 deletions

View File

@@ -593,7 +593,6 @@ public class TradingBot : Bot, ITradingBot
var lastPosition = Positions.LastOrDefault(p => p.IsFinished()
&& p.SignalIdentifier != signal.Identifier
&& p.ProfitAndLoss.Realized < 0
&& p.OriginDirection == signal.Direction);
if (lastPosition == null)
@@ -665,13 +664,9 @@ public class TradingBot : Bot, ITradingBot
{
if (Positions.Any(p => p.Identifier == position.Identifier))
{
var previousPosition = Positions.First(p => p.Identifier == position.Identifier);
var positionIndex = Positions.IndexOf(previousPosition);
position.SignalIdentifier = previousPosition.SignalIdentifier;
Positions[positionIndex] = position;
SetSignalStatus(position.SignalIdentifier, SignalStatus.Expired);
await SetPositionStatus(position.SignalIdentifier, PositionStatus.Finished);
Logger.LogInformation(
$"Position {position.SignalIdentifier} type correctly close. Pnl on position : {position.ProfitAndLoss.Realized}");
$"Position {position.SignalIdentifier} type correctly close. Pnl on position : {position.ProfitAndLoss?.Realized}");
}
else
{
@@ -719,6 +714,7 @@ public class TradingBot : Bot, ITradingBot
catch (Exception ex)
{
Logger.LogError(ex, "Error during cancelOrders");
SentrySdk.CaptureException(ex);
}
}
}