Fix loop when trying to recover the cancelled position
This commit is contained in:
@@ -2935,8 +2935,8 @@ public class TradingBotBase : ITradingBot
|
||||
return; // No positions at all
|
||||
}
|
||||
|
||||
// Only attempt recovery if the last position is cancelled
|
||||
if (lastPosition.Status != PositionStatus.Canceled)
|
||||
// Only attempt recovery if the last position is cancelled and recovery hasn't been attempted yet
|
||||
if (lastPosition.Status != PositionStatus.Canceled || lastPosition.RecoveryAttempted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2955,6 +2955,9 @@ public class TradingBotBase : ITradingBot
|
||||
return;
|
||||
}
|
||||
|
||||
// Mark recovery as attempted before proceeding
|
||||
lastPosition.RecoveryAttempted = true;
|
||||
|
||||
// Attempt recovery for the last position only
|
||||
bool recovered = await RecoverOpenPositionFromBroker(signal, lastPosition);
|
||||
if (recovered)
|
||||
|
||||
Reference in New Issue
Block a user