From 8d97fce41c873f93eaac47dfd9fab146b2832567 Mon Sep 17 00:00:00 2001 From: cryptooda Date: Wed, 12 Nov 2025 00:50:16 +0700 Subject: [PATCH] Refactor TradingBotBase to streamline recovery logic for recently canceled positions. Removed redundant recovery call and added comments for clarity in position management. --- src/Managing.Application/Bots/TradingBotBase.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Managing.Application/Bots/TradingBotBase.cs b/src/Managing.Application/Bots/TradingBotBase.cs index 96e77df9..81e8faa8 100644 --- a/src/Managing.Application/Bots/TradingBotBase.cs +++ b/src/Managing.Application/Bots/TradingBotBase.cs @@ -372,6 +372,9 @@ public class TradingBotBase : ITradingBot private async Task ManagePositions() { + // Recovery Logic: Check for recently canceled positions that might need recovery + await RecoverRecentlyCanceledPositions(); + // Early exit optimization - skip if no positions to manage // Optimized: Use for loop to avoid multiple iterations bool hasOpenPositions = false; @@ -400,8 +403,7 @@ public class TradingBotBase : ITradingBot if (!hasOpenPositions && !hasWaitingSignals) return; - // Recovery Logic: Check for recently canceled positions that might need recovery - await RecoverRecentlyCanceledPositions(); + // First, process all existing positions that are not finished // Optimized: Inline the filter to avoid LINQ overhead