code cleanup

dev
vlad zverzhkhovskiy 2025-09-17 17:22:16 +03:00
parent 941e00e346
commit 43ba83aa90
3 changed files with 11 additions and 12 deletions

View File

@ -20,7 +20,6 @@ using System.Collections.Concurrent;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Threading.Channels; using System.Threading.Channels;
using Tinkoff.InvestApi; using Tinkoff.InvestApi;
using Tinkoff.InvestApi.V1;
using AssetType = KLHZ.Trader.Core.Exchange.Models.AssetsAccounting.AssetType; using AssetType = KLHZ.Trader.Core.Exchange.Models.AssetsAccounting.AssetType;
namespace KLHZ.Trader.Core.Exchange.Services namespace KLHZ.Trader.Core.Exchange.Services
@ -198,7 +197,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
{ {
await LogPrice(message, "trading_mode", (decimal)mode); await LogPrice(message, "trading_mode", (decimal)mode);
} }
//continue; //continue;
#endregion #endregion
if (message.Figi == "BBG004730N88") if (message.Figi == "BBG004730N88")
@ -267,7 +266,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
} }
} }
} }
catch(Exception e) catch (Exception e)
{ {
} }
@ -448,11 +447,11 @@ namespace KLHZ.Trader.Core.Exchange.Services
var sells = sberSells.Sum(s => s.Value); var sells = sberSells.Sum(s => s.Value);
var buys = sberBuys.Sum(s => s.Value); var buys = sberBuys.Sum(s => s.Value);
var su = sells + buys; var su = sells + buys;
if (su!=0) if (su != 0)
{ {
var dsell = (sells / su - 0.5m) * 2; var dsell = (sells / su - 0.5m) * 2;
} }
var mavTask = CheckByWindowAverageMean(data, message, windowMaxSize, -1, 2m); var mavTask = CheckByWindowAverageMean(data, message, windowMaxSize, -1, 2m);
@ -629,7 +628,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
ExchangeState state, ExchangeState state,
INewPrice message, int windowMaxSize) INewPrice message, int windowMaxSize)
{ {
if (data.timestamps.Length <= 4 || state!=ExchangeState.Open) if (data.timestamps.Length <= 4 || state != ExchangeState.Open)
{ {
return; return;
} }
@ -713,7 +712,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
ExchangeState state, ExchangeState state,
INewPrice message, int windowMaxSize, decimal step) INewPrice message, int windowMaxSize, decimal step)
{ {
if (data.timestamps.Length <= 4 && state !=ExchangeState.Open) if (data.timestamps.Length <= 4 && state != ExchangeState.Open)
{ {
return; return;
} }
@ -948,9 +947,9 @@ namespace KLHZ.Trader.Core.Exchange.Services
if (largeData.isFullIntervalExists && smallData.isFullIntervalExists) if (largeData.isFullIntervalExists && smallData.isFullIntervalExists)
{ {
if (LocalTrends.TryCalcTrendDiff(largeData.timestamps, largeData.prices, out var largeDataRes) if (LocalTrends.TryCalcTrendDiff(largeData.timestamps, largeData.prices, out var largeDataRes)
&& LocalTrends.TryCalcTrendDiff(smallData.timestamps, smallData.prices, out var smallDataRes)) && LocalTrends.TryCalcTrendDiff(smallData.timestamps, smallData.prices, out var smallDataRes))
{ {
if (largeDataRes>0 && largeDataRes <= 4 && System.Math.Abs(smallDataRes)<3) if (largeDataRes > 0 && largeDataRes <= 4 && System.Math.Abs(smallDataRes) < 3)
{ {
res = TradingMode.Stable; res = TradingMode.Stable;
} }
@ -958,7 +957,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
{ {
res = TradingMode.SlowDropping; res = TradingMode.SlowDropping;
} }
if (largeDataRes>5 && smallDataRes > 0) if (largeDataRes > 5 && smallDataRes > 0)
{ {
res = TradingMode.Growing; res = TradingMode.Growing;
} }

View File

@ -100,7 +100,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
AccountId = tradeCommand.AccountId, AccountId = tradeCommand.AccountId,
Figi = tradeCommand.Figi, Figi = tradeCommand.Figi,
OrderId = res.OrderId, OrderId = res.OrderId,
Ticker = _tradeDataProvider.GetTickerByFigi(tradeCommand.Figi), Ticker = _tradeDataProvider.GetTickerByFigi(tradeCommand.Figi),
Count = res.LotsRequested, Count = res.LotsRequested,
Direction = (DealDirection)(int)dir, Direction = (DealDirection)(int)dir,
ExpirationTime = DateTime.UtcNow.AddMinutes(2), ExpirationTime = DateTime.UtcNow.AddMinutes(2),

View File

@ -34,7 +34,7 @@ namespace KLHZ.Trader.Service.Controllers
//var figi1 = "BBG004730N88"; //var figi1 = "BBG004730N88";
var figi2 = "BBG004730N88"; var figi2 = "BBG004730N88";
//var figi2 = "FUTIMOEXF000"; //var figi2 = "FUTIMOEXF000";
var time1 = startDate?? DateTime.UtcNow.AddDays(-17); var time1 = startDate ?? DateTime.UtcNow.AddDays(-17);
//var time1 = new DateTime(2025, 9, 4, 14, 0, 0, DateTimeKind.Utc); //var time1 = new DateTime(2025, 9, 4, 14, 0, 0, DateTimeKind.Utc);
//var time2 = DateTime.UtcNow.AddMinutes(18); //var time2 = DateTime.UtcNow.AddMinutes(18);
using var context1 = await _dbContextFactory.CreateDbContextAsync(); using var context1 = await _dbContextFactory.CreateDbContextAsync();