From c0e29c06a521a3fd5810cf01bedf696f3f4bec8f Mon Sep 17 00:00:00 2001 From: vlad zverzhkhovskiy Date: Tue, 9 Sep 2025 10:48:18 +0300 Subject: [PATCH] code cleanup --- KLHZ.Trader.Core.Math/Common/Lines.cs | 4 ++-- KLHZ.Trader.Core.Math/Declisions/Utils/MovingAverage.cs | 4 ++-- .../Declisions/Utils/ShapeAreaCalculator.cs | 4 +--- KLHZ.Trader.Core/Exchange/Services/Trader.cs | 4 ++-- KLHZ.Trader.Core/Exchange/Services/TraderDataProvider.cs | 5 ++--- KLHZ.Trader.Core/TG/Services/BotMessagesHandler.cs | 4 ++-- KLHZ.Trader.Service/Controllers/PlayController.cs | 1 - 7 files changed, 11 insertions(+), 15 deletions(-) diff --git a/KLHZ.Trader.Core.Math/Common/Lines.cs b/KLHZ.Trader.Core.Math/Common/Lines.cs index 4584703..3e054fe 100644 --- a/KLHZ.Trader.Core.Math/Common/Lines.cs +++ b/KLHZ.Trader.Core.Math/Common/Lines.cs @@ -10,10 +10,10 @@ return (x, y); } - public static (bool res,DateTime x, decimal y) IsLinesCrossing(DateTime time1, DateTime time2, decimal val1_1, decimal val1_2, decimal val2_1, decimal val2_2) + public static (bool res, DateTime x, decimal y) IsLinesCrossing(DateTime time1, DateTime time2, decimal val1_1, decimal val1_2, decimal val2_1, decimal val2_2) { var dtime = (decimal)(time2 - time1).TotalSeconds; - if (dtime == 0) return (false, DateTime.MinValue,0); + if (dtime == 0) return (false, DateTime.MinValue, 0); var dval1 = val1_2 - val1_1; var k1 = dval1 / dtime; var b1 = val1_1; diff --git a/KLHZ.Trader.Core.Math/Declisions/Utils/MovingAverage.cs b/KLHZ.Trader.Core.Math/Declisions/Utils/MovingAverage.cs index e7458dd..25a1d85 100644 --- a/KLHZ.Trader.Core.Math/Declisions/Utils/MovingAverage.cs +++ b/KLHZ.Trader.Core.Math/Declisions/Utils/MovingAverage.cs @@ -63,7 +63,7 @@ namespace KLHZ.Trader.Core.Math.Declisions.Utils twavbs[i2 + 1]); if (shift == 1 && !isCrossing.res) //если нет пересечения скользящих средний с окном 120 и 15 секунд между - //текущей и предыдущей точкой - можно не продолжать выполнение. + //текущей и предыдущей точкой - можно не продолжать выполнение. { break; } @@ -112,7 +112,7 @@ namespace KLHZ.Trader.Core.Math.Declisions.Utils // если фильтрация окном 120 наползает на окно 15 сверху, потенциальное время открытия лонга и закрытия шорта if (twavss[size - 1] >= twavbs[size - 1] && twavss[size - 2] < twavbs[size - 2]) { - if (pricesForFinalComparison[crossings[0]] - pricesForFinalComparison[crossings[1]] <= - meanfullStep + if (pricesForFinalComparison[crossings[0]] - pricesForFinalComparison[crossings[1]] <= -meanfullStep && times[crossings[0]] - times[crossings[1]] >= timeForUptreandStart) { res |= TradingEvent.UptrendStart; diff --git a/KLHZ.Trader.Core.Math/Declisions/Utils/ShapeAreaCalculator.cs b/KLHZ.Trader.Core.Math/Declisions/Utils/ShapeAreaCalculator.cs index 712ca8a..60f07be 100644 --- a/KLHZ.Trader.Core.Math/Declisions/Utils/ShapeAreaCalculator.cs +++ b/KLHZ.Trader.Core.Math/Declisions/Utils/ShapeAreaCalculator.cs @@ -1,6 +1,4 @@ -using System; - -namespace KLHZ.Trader.Core.Math.Declisions.Utils +namespace KLHZ.Trader.Core.Math.Declisions.Utils { public static class ShapeAreaCalculator { diff --git a/KLHZ.Trader.Core/Exchange/Services/Trader.cs b/KLHZ.Trader.Core/Exchange/Services/Trader.cs index 1d06e1f..df6008b 100644 --- a/KLHZ.Trader.Core/Exchange/Services/Trader.cs +++ b/KLHZ.Trader.Core/Exchange/Services/Trader.cs @@ -129,7 +129,7 @@ namespace KLHZ.Trader.Core.Exchange.Services { AccountId = asset.AccountId, Figi = message.Figi, - CommandType = asset.Count < 0? Contracts.Messaging.Dtos.Enums.TradeCommandType.MarketBuy + CommandType = asset.Count < 0 ? Contracts.Messaging.Dtos.Enums.TradeCommandType.MarketBuy : Contracts.Messaging.Dtos.Enums.TradeCommandType.MarketSell, Count = (long)asset.Count, RecomendPrice = null, @@ -180,7 +180,7 @@ namespace KLHZ.Trader.Core.Exchange.Services var max = fullData.prices.Max(); var min = fullData.prices.Min(); - if (max - min < 15 && fullData.prices.Last() - fullData.prices.First() < 4 && fullData.prices.Last() - fullData.prices.First()>-4) + if (max - min < 15 && fullData.prices.Last() - fullData.prices.First() < 4 && fullData.prices.Last() - fullData.prices.First() > -4) { if (!message.IsHistoricalData && BotModeSwitcher.CanPurchase()) { diff --git a/KLHZ.Trader.Core/Exchange/Services/TraderDataProvider.cs b/KLHZ.Trader.Core/Exchange/Services/TraderDataProvider.cs index eb2429f..10c9615 100644 --- a/KLHZ.Trader.Core/Exchange/Services/TraderDataProvider.cs +++ b/KLHZ.Trader.Core/Exchange/Services/TraderDataProvider.cs @@ -1,5 +1,4 @@ -using Google.Protobuf.WellKnownTypes; -using KLHZ.Trader.Core.Contracts.Declisions.Interfaces; +using KLHZ.Trader.Core.Contracts.Declisions.Interfaces; using KLHZ.Trader.Core.Contracts.Messaging.Dtos; using KLHZ.Trader.Core.Contracts.Messaging.Dtos.Interfaces; using KLHZ.Trader.Core.DataLayer; @@ -166,7 +165,7 @@ namespace KLHZ.Trader.Core.Exchange.Services _ = WritePricesTask(); } - catch(Exception ex) + catch (Exception ex) { } diff --git a/KLHZ.Trader.Core/TG/Services/BotMessagesHandler.cs b/KLHZ.Trader.Core/TG/Services/BotMessagesHandler.cs index f08a802..9628b3c 100644 --- a/KLHZ.Trader.Core/TG/Services/BotMessagesHandler.cs +++ b/KLHZ.Trader.Core/TG/Services/BotMessagesHandler.cs @@ -21,7 +21,7 @@ namespace KLHZ.Trader.Core.TG.Services private readonly TraderDataProvider _traderDataProvider; public BotMessagesHandler(IDataBus eventBus, IOptions options, ILogger logger, TraderDataProvider traderDataProvider) { - _traderDataProvider = traderDataProvider; + _traderDataProvider = traderDataProvider; _logger = logger; _eventBus = eventBus; _admins = ImmutableArray.CreateRange(options.Value.Admins); @@ -79,7 +79,7 @@ namespace KLHZ.Trader.Core.TG.Services { var assets = await _traderDataProvider.GetAssetsByFigi("FUTIMOEXF000"); - foreach(var asset in assets) + foreach (var asset in assets) { if (asset.Count > 0) { diff --git a/KLHZ.Trader.Service/Controllers/PlayController.cs b/KLHZ.Trader.Service/Controllers/PlayController.cs index 5c6b924..f733497 100644 --- a/KLHZ.Trader.Service/Controllers/PlayController.cs +++ b/KLHZ.Trader.Service/Controllers/PlayController.cs @@ -1,7 +1,6 @@ using KLHZ.Trader.Core.Contracts.Messaging.Dtos; using KLHZ.Trader.Core.Contracts.Messaging.Interfaces; using KLHZ.Trader.Core.DataLayer; -using KLHZ.Trader.Core.DataLayer.Entities.Prices; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore;