perf: remove debug logging and optimize rolling window maintenance (+5.0%)

This commit is contained in:
2025-11-11 12:26:44 +07:00
parent 46966cc5d8
commit 61fdcec902
3 changed files with 15 additions and 14 deletions

View File

@@ -428,7 +428,16 @@ public class TradingBotBase : ITradingBot
}
// Check if we already have a position for this signal (in case it was added but not processed yet)
var existingPosition = Positions.Values.FirstOrDefault(p => p.SignalIdentifier == signal.Identifier);
// Optimized: Avoid LINQ FirstOrDefault overhead
Position existingPosition = null;
foreach (var pos in Positions.Values)
{
if (pos.SignalIdentifier == signal.Identifier)
{
existingPosition = pos;
break;
}
}
if (existingPosition != null)
{