From 4b57c729119fe104b6bc8f2a057dc6d067b5371a Mon Sep 17 00:00:00 2001 From: vlad zverzhkhovskiy Date: Tue, 23 Sep 2025 11:32:18 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D1=82=D0=BE=D0=BF=D1=8B=20=D0=BD=D0=B0?= =?UTF-8?q?=20=D0=BC=D0=B0=D1=81=D1=81=D0=BE=D0=B2=D0=BE=D0=B5=20=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=B7?= =?UTF-8?q?=D0=B8=D1=86=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KLHZ.Trader.Core/Exchange/Services/Trader.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/KLHZ.Trader.Core/Exchange/Services/Trader.cs b/KLHZ.Trader.Core/Exchange/Services/Trader.cs index e53624e..952d018 100644 --- a/KLHZ.Trader.Core/Exchange/Services/Trader.cs +++ b/KLHZ.Trader.Core/Exchange/Services/Trader.cs @@ -281,7 +281,7 @@ namespace KLHZ.Trader.Core.Exchange.Services } await LogDeclision(DeclisionTradeAction.CloseShort, message); } - if (newMod == TradingMode.Growing && newMod != oldMod) + if (newMod == TradingMode.Growing && newMod != oldMod && !LongOpeningStops.ContainsKey(message.Figi)) { var stops = GetStops(message, PositionType.Long); if (!message.IsHistoricalData && BotModeSwitcher.CanPurchase()) @@ -292,12 +292,13 @@ namespace KLHZ.Trader.Core.Exchange.Services .Select(a => a.Value) .ToArray(); await OpenPositions(accounts, message, PositionType.Long, stops.stopLoss, stops.takeProfit, 1); + LongOpeningStops[message.Figi] = DateTime.UtcNow.AddMinutes(1); } await LogDeclision(DeclisionTradeAction.OpenLong, message); await LogDeclision(DeclisionTradeAction.OpenLong, message.Value + stops.takeProfit, message.Time.AddMilliseconds(-RandomNumberGenerator.GetInt32(300, 1000)), message); await LogDeclision(DeclisionTradeAction.OpenLong, message.Value - stops.stopLoss, message.Time.AddMilliseconds(RandomNumberGenerator.GetInt32(300, 1000)), message); } - if (newMod == TradingMode.Dropping && newMod != oldMod) + if (newMod == TradingMode.Dropping && newMod != oldMod && !ShortOpeningStops.ContainsKey(message.Figi)) { var stops = GetStops(message, PositionType.Short); if (!message.IsHistoricalData && BotModeSwitcher.CanSell()) @@ -308,6 +309,7 @@ namespace KLHZ.Trader.Core.Exchange.Services .Select(a => a.Value) .ToArray(); await OpenPositions(accounts, message, PositionType.Short, stops.stopLoss, stops.takeProfit, 1); + ShortOpeningStops[message.Figi] = DateTime.UtcNow.AddMinutes(1); } await LogDeclision(DeclisionTradeAction.OpenShort, message); await LogDeclision(DeclisionTradeAction.OpenShort, message.Value - stops.takeProfit, message.Time.AddMilliseconds(-RandomNumberGenerator.GetInt32(10, 100)), message); @@ -545,6 +547,7 @@ INewPrice message, int windowMaxSize, decimal uptrendStartingDetectionMeanfullSt .Select(a => a.Value) .ToArray(); await OpenPositions(accounts, message, PositionType.Long, stops.stopLoss, stops.takeProfit, 1); + LongOpeningStops[message.Figi] = DateTime.UtcNow.AddMinutes(1); } await LogDeclision(DeclisionTradeAction.OpenLong, message); @@ -565,6 +568,7 @@ INewPrice message, int windowMaxSize, decimal uptrendStartingDetectionMeanfullSt .Select(a => a.Value) .ToArray(); await OpenPositions(accounts, message, PositionType.Short, stops.stopLoss, stops.takeProfit, 1); + ShortOpeningStops[message.Figi] = DateTime.UtcNow.AddMinutes(1); } await LogDeclision(DeclisionTradeAction.OpenShort, message);